Exemplo n.º 1
0
 public function setUp()
 {
     $this->_connectionFactory = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Type\\Db\\ConnectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->_config = $this->getMockBuilder('Magento\\Framework\\App\\Resource\\ConfigInterface')->disableOriginalConstructor()->setMethods(['getConnectionName'])->getMock();
     $this->_config->expects($this->any())->method('getConnectionName')->with(self::RESOURCE_NAME)->will($this->returnValue(self::CONNECTION_NAME));
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->deploymentConfig->expects($this->any())->method('get')->will($this->returnValue(['default' => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username'], self::CONNECTION_NAME => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username']]));
     $this->connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->connection->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
     $this->resource = new Resource($this->_config, $this->_connectionFactory, $this->deploymentConfig, self::TABLE_PREFIX);
 }
Exemplo n.º 2
0
 /**
  * Initialise data for configuration
  * @return void
  */
 protected function initData()
 {
     $data = $this->cache->load($this->cacheId);
     if (false === $data) {
         $singleQuery = $this->config->getConnectionName('checkout_setup') == 'default' ? true : false;
         $data['checkout'] = $singleQuery;
         $this->cache->save(serialize($data), $this->cacheId, $this->cacheTags);
     } else {
         $data = unserialize($data);
     }
     $this->merge($data);
 }
Exemplo n.º 3
0
 /**
  * Retrieve connection to resource specified by $resourceName
  *
  * @param string $resourceName
  * @return \Magento\Framework\DB\Adapter\AdapterInterface|false
  */
 public function getConnection($resourceName)
 {
     $connectionName = $this->_config->getConnectionName($resourceName);
     if (isset($this->_connections[$connectionName])) {
         return $this->_connections[$connectionName];
     }
     $connection = $this->_connectionFactory->create($connectionName);
     if (!$connection) {
         return false;
     }
     $connection->setCacheAdapter($this->_cache->getFrontend());
     $this->_connections[$connectionName] = $connection;
     return $connection;
 }
Exemplo n.º 4
0
 /**
  * Retrieve connection to resource specified by $resourceName
  *
  * @param string $resourceName
  * @return \Magento\Framework\DB\Adapter\AdapterInterface|false
  */
 public function getConnection($resourceName)
 {
     $connectionName = $this->_config->getConnectionName($resourceName);
     return $this->getConnectionByName($connectionName);
 }