/** * @return void */ public function testCreateNoActiveConfig() { $config = ['foo' => 'bar']; $loggerMock = $this->getMockBuilder(LoggerInterface::class)->getMockForAbstractClass(); $connectionAdapterMock = $this->getMockBuilder(ConnectionAdapterInterface::class)->getMockForAbstractClass(); $this->objectManagerMock->expects($this->once())->method('create')->with(ConnectionAdapterInterface::class, ['config' => $config])->willReturn($connectionAdapterMock); $this->objectManagerMock->expects($this->once())->method('get')->with(LoggerInterface::class)->willReturn($loggerMock); $connectionAdapterMock->expects($this->once())->method('getConnection')->with($loggerMock)->willReturn('Expected result'); $this->assertEquals('Expected result', $this->model->create($config)); }
/** * Create connection adapter instance * * @param array $connectionConfig * @return \Magento\Framework\DB\Adapter\AdapterInterface * @throws \InvalidArgumentException */ public function create(array $connectionConfig) { $connection = parent::create($connectionConfig); /** @var \Magento\Framework\DB\Adapter\DdlCache $ddlCache */ $ddlCache = $this->objectManager->get(\Magento\Framework\DB\Adapter\DdlCache::class); $connection->setCacheAdapter($ddlCache); return $connection; }
/** * Create connection adapter instance * * @param array $connectionConfig * @return \Magento\Framework\DB\Adapter\AdapterInterface * @throws \InvalidArgumentException */ public function create(array $connectionConfig) { $connection = parent::create($connectionConfig); /** @var \Magento\Framework\App\Cache\Type\FrontendPool $pool */ $pool = $this->objectManager->get(\Magento\Framework\App\Cache\Type\FrontendPool::class); $connection->setCacheAdapter($pool->get(DdlCache::TYPE_IDENTIFIER)); return $connection; }