public function testApplyAllDataUpdates() { /*reset versions*/ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDbVersion('adminnotification_setup', false); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDataVersion('adminnotification_setup', false); $this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup'); $this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox')); $this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages')); /** @var \Magento\Framework\Cache\FrontendInterface $cache */ $cache = $this->_objectManager->get('Magento\\Framework\\App\\Cache\\Type\\Config'); $cache->clean(); try { /* This triggers plugin to be executed */ $this->dispatch('index/index'); } catch (\Exception $e) { $this->fail("Impossible to continue other tests, because database is broken: {$e}"); } try { $tableData = $this->_model->getConnection()->describeTable($this->_model->getTable('adminnotification_inbox')); $this->assertNotEmpty($tableData); } catch (\Exception $e) { $this->fail("Impossible to continue other tests, because database is broken: {$e}"); } $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version')); $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version')); }
public function testApplyAllDataUpdates() { /*reset versions*/ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\\Magento\\Framework\\Module\\ResourceInterface')->setDbVersion('adminnotification_setup', false); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\\Magento\\Framework\\Module\\ResourceInterface')->setDataVersion('adminnotification_setup', false); $this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup'); $this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox')); $this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages')); /** @var $updater \Magento\Framework\Module\Updater */ $updater = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Module\\Updater'); try { $updater->updateScheme(); $updater->updateData(); } catch (\Exception $e) { $this->fail("Impossible to continue other tests, because database is broken: {$e}"); } $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version')); $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version')); }
public function __construct(Setup $installer, Factory $helperFactory, Tables $tablesObject, $tableName) { $this->installer = $installer; $this->connection = $installer->getConnection(); $this->helperFactory = $helperFactory; $this->tablesObject = $tablesObject; if (!$this->tablesObject->isExists($tableName)) { throw new \Ess\M2ePro\Model\Exception\Setup("Table Name does not exist."); } $this->tableName = $this->tablesObject->getFullName($tableName); }
public function testGetConnection() { $this->assertSame($this->connection, $this->object->getConnection()); // Check that new connection is not created every time $this->assertSame($this->connection, $this->object->getConnection()); }
/** * Set order number prefix * * @param \Magento\Framework\Module\Setup $setupModel * @param string $orderIncrementPrefix * @return void */ protected function _setOrderIncrementPrefix(\Magento\Framework\Module\Setup $setupModel, $orderIncrementPrefix) { $select = $setupModel->getConnection()->select()->from($setupModel->getTable('eav_entity_type'), 'entity_type_id')->where('entity_type_code=?', 'order'); $data = array('entity_type_id' => $setupModel->getConnection()->fetchOne($select), 'store_id' => '1', 'increment_prefix' => $orderIncrementPrefix); $setupModel->getConnection()->insert($setupModel->getTable('eav_entity_store'), $data); }
public function __construct(Setup $installer, Factory $helperFactory) { $this->installer = $installer; $this->connection = $installer->getConnection(); $this->helperFactory = $helperFactory; }
/** * @return \Magento\Framework\DB\Adapter\AdapterInterface */ private function getConnection() { return $this->installer->getConnection(); }