public function test_getQueryToSelect() { $res = $this->_obj->getQueryToSelect(); /** @var \Magento\Framework\App\ResourceConnection $resource */ $resource = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\App\ResourceConnection::class); $conn = $resource->getConnection(); $data = $conn->fetchAll($res); }
public function test_getQueryToSelect() { /** === Setup Mocks === */ // $result = $this->_conn->select(); $mResult = $this->_mockDbSelect(['from', 'joinLeft', 'where']); $this->mConn->shouldReceive('select')->once()->andReturn($mResult); // ... $this->_resource->getTableName(...) $this->mResource->shouldReceive('getTableName'); /** === Call and asserts === */ $res = $this->obj->getQueryToSelect(); $this->assertTrue($res instanceof \Magento\Framework\DB\Select); }
public function test_getSelectQuery() { /** === Setup Mocks === */ // $result = $this->_conn->select(); $mResult = $this->_mockDbSelect(); $this->mConn->shouldReceive('select')->once()->andReturn($mResult); // $tblStock = [$asStock => $this->_resource->getTableName(Cfg::ENTITY_MAGE_CATALOGINVENTORY_STOCK)]; // $tblWrhs = [$asWrhs => $this->_resource->getTableName(EntityWarehouse::ENTITY_NAME)]; $this->mResource->shouldReceive('getTableName')->twice(); // $result->from($tblStock, $cols); $mResult->shouldReceive('from', 'joinLeft'); /** === Call and asserts === */ $this->obj->getQueryToSelect(); }
public function test_getQueryToSelect() { /** === Setup Mocks === */ // $result = $this->_conn->select(); $mQuery = $this->_mockDbSelect(); $this->mConn->shouldReceive('select')->once()->andReturn($mQuery); // $tblWrhs = [$asWrhs => $this->_resource->getTableName(EntityWrhsLot::ENTITY_NAME)]; // $tblOdoo = [$asOdoo => $this->_resource->getTableName(EntityLot::ENTITY_NAME)]; $this->mResource->shouldReceive('getTableName')->twice(); // $result->from($tblWrhs, $cols); $mQuery->shouldReceive('from')->once(); // $result->joinLeft($tblOdoo, $on, $cols); $mQuery->shouldReceive('joinLeft')->once(); /** === Call and asserts === */ $res = $this->obj->getQueryToSelect(); $this->assertTrue($res instanceof \Magento\Framework\DB\Select); }