/**
  * @return void
  */
 public function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->resource = $this->objectManager->get('Magento\\Framework\\App\\ResourceConnection');
     $this->connection = $this->resource->getConnection();
     $this->model = $this->objectManager->create('Magento\\Framework\\Mview\\View\\Changelog', ['resource' => $this->resource]);
     $this->model->setViewId('test_view_id_1');
     $this->model->create();
 }
Beispiel #2
0
 public function testClearWithException()
 {
     $changelogTableName = 'viewIdtest_cl';
     $this->mockIsTableExists($changelogTableName, false);
     $this->mockGetTableName();
     $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
     $this->model->setViewId('viewIdtest');
     $this->model->clear(mt_rand(1, 200));
 }
Beispiel #3
0
 /**
  * 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);
     }
 }