public function testGetTriggerName() { $tableName = 'subject_table'; $time = 'before'; $event = 'insert'; $triggerName = 'trg_subject_table_before_insert'; $this->_connectionFactory->expects($this->once())->method('create')->will($this->returnValue($this->connection)); $this->connection->expects($this->once())->method('getTriggerName')->with($tableName, $time, $event)->willReturn($triggerName); $this->assertSame($triggerName, $this->resource->getTriggerName($tableName, $time, $event)); }
/** * Create connection adapter instance * * @param array $connectionConfig * @return \Magento\Framework\DB\Adapter\AdapterInterface * @throws \InvalidArgumentException */ public function create(array $connectionConfig) { $connection = parent::create($connectionConfig); if ($connection) { /** @var \Magento\Framework\App\Cache\Type\FrontendPool $pool */ $pool = $this->objectManager->get('Magento\\Framework\\App\\Cache\\Type\\FrontendPool'); $connection->setCacheAdapter($pool->get(DdlCache::TYPE_IDENTIFIER)); } return $connection; }
public function testGetFkName() { $table = 'table'; $calculatedTableName = self::TABLE_PREFIX . 'table'; $refTable = 'ref_table'; $calculatedRefTableName = self::TABLE_PREFIX . 'ref_table'; $columnName = 'columnName'; $refColumnName = 'refColumnName'; $this->connection->expects($this->once())->method('getForeignKeyName')->with($calculatedTableName, $columnName, $calculatedRefTableName, $refColumnName)->will($this->returnValue('fkName')); $this->_connectionFactory->expects($this->once())->method('create')->will($this->returnValue($this->connection)); $this->assertEquals('fkName', $this->resource->getFkName($table, $columnName, $refTable, $refColumnName)); }
/** * @param array $config * @dataProvider dataProviderCreateNoActiveConfig */ public function testCreateNoActiveConfig($config) { $this->assertNull($this->model->create($config)); }