예제 #1
0
 /**
  * Test that the model detects a connection when it becomes active
  */
 public function testGetConnectionInMemoryCaching()
 {
     $string = $this->getMock('Magento\\Framework\\Stdlib\\String', [], [], '', false);
     $dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', null, [], '', true);
     $logger = $this->getMockForAbstractClass('Magento\\Framework\\DB\\LoggerInterface');
     $connection = new \Magento\Framework\DB\Adapter\Pdo\Mysql($string, $dateTime, $logger, ['dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password']);
     $this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
     $this->assertFalse($this->_model->getReadConnection());
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
 }
예제 #2
0
 /**
  * Test that the model detects a connection when it becomes active
  */
 public function testGetConnectionInMemoryCaching()
 {
     $filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false);
     $string = $this->getMock('Magento\\Framework\\Stdlib\\String', array(), array(), '', false);
     $dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', null, array(), '', true);
     $connection = new \Magento\Framework\DB\Adapter\Pdo\Mysql($filesystem, $string, $dateTime, array('dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password'));
     $this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
     $this->assertFalse($this->_model->getReadConnection());
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
 }
예제 #3
0
 public function testGetReadAdapter()
 {
     $adapterInterfaceMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $adapterInterfaceMock->expects($this->once())->method('getTransactionLevel')->will($this->returnValue(1));
     $this->_resourcesMock->expects($this->any())->method('getConnection')->will($this->returnValue($adapterInterfaceMock));
     $this->assertInstanceOf('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', $this->_model->getReadConnection());
 }
예제 #4
0
 /**
  * Returns list of columns from fulltext index (doesn't support more then one FTI per table)
  *
  * @param DbResource $resource
  * @param string $indexTable
  * @return array
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function getFulltextIndexColumns(DbResource $resource, $indexTable)
 {
     $indexes = $resource->getReadConnection()->getIndexList($indexTable);
     foreach ($indexes as $index) {
         if (strtoupper($index['INDEX_TYPE']) == 'FULLTEXT') {
             return $index['COLUMNS_LIST'];
         }
     }
     return [];
 }