/** * Test for getList() method * * @return void */ public function testGetList() { $this->assertEquals(0, $this->model->getVersion()); //the same that a table is empty $changelogName = $this->resource->getTableName($this->model->getName()); $testChengelogData = [['version_id' => 1, 'entity_id' => 1], ['version_id' => 2, 'entity_id' => 1], ['version_id' => 3, 'entity_id' => 2], ['version_id' => 4, 'entity_id' => 3], ['version_id' => 5, 'entity_id' => 1]]; foreach ($testChengelogData as $data) { $this->connection->insert($changelogName, $data); } $this->assertEquals(5, $this->model->getVersion()); $this->assertEquals(3, count($this->model->getList(0, 5))); //distinct entity_ids $this->assertEquals(3, count($this->model->getList(2, 5))); //distinct entity_ids $this->assertEquals(2, count($this->model->getList(0, 3))); //distinct entity_ids $this->assertEquals(1, count($this->model->getList(0, 2))); //distinct entity_ids $this->assertEquals(1, count($this->model->getList(2, 3))); //distinct entity_ids $this->assertEquals(0, count($this->model->getList(4, 3))); //because fromVersionId > toVersionId }
/** * Delete all product flat tables for not existing stores * * @return void */ public function deleteAbandonedStoreFlatTables() { $connection = $this->_resource->getConnection('write'); $existentTables = $connection->getTables($connection->getTableName('catalog_product_flat_%')); $this->_changelog->setViewId('catalog_product_flat'); foreach ($existentTables as $key => $tableName) { if ($this->_changelog->getName() == $tableName) { unset($existentTables[$key]); } } $actualStoreTables = []; foreach ($this->_storeManager->getStores() as $store) { $actualStoreTables[] = $this->getFlatTableName($store->getId()); } $tablesToDelete = array_diff($existentTables, $actualStoreTables); foreach ($tablesToDelete as $table) { $connection->dropTable($table); } }
/** * @expectedException \Exception * @expectedExceptionMessage View's identifier is not set */ public function testGetNameWithException() { $this->model->getName(); }