/**
  * Test purge method
  */
 public function testPurge()
 {
     $this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $this->appResourceMock->expects($this->once())->method('getTableName')->will($this->returnValue('sales_flat_invoice_grid'));
     $this->adapterMock->expects($this->once())->method('delete')->with('sales_flat_invoice_grid', ['fi.field = ?' => 1])->will($this->returnValue(1));
     $this->assertEquals(1, $this->grid->purge(1, 'fi.field'));
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->helper = new Helper($this->resourceMock);
 }
Beispiel #3
0
 protected function setUp()
 {
     $this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
     $select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $select->expects($this->any())->method('from')->will($this->returnSelf());
     $select->expects($this->any())->method('where')->will($this->returnSelf());
     $select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
     $select->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($select));
     $this->connection->expects($this->any())->method('fetchPairs')->will($this->returnValue(['1' => '1', '2' => '2']));
     $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
     $this->connection->expects($this->any())->method('delete')->willReturnSelf();
     $this->connection->expects($this->any())->method('quoteInto')->willReturn('');
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', ['getConnection', 'getTableName'], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
     $this->attrSetColFac = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
     $this->setCollection = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
     $this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
     $this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
     $this->prodAttrColFac = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
     $attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\Collection', [], [], '', false);
     $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
     $this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
     $this->params = [0 => $this->entityModel, 1 => 'bundle'];
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->bundle = $this->objectManagerHelper->getObject('Magento\\BundleImportExport\\Model\\Import\\Product\\Type\\Bundle', ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
 }
 public function setUp()
 {
     $this->coreEntityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface', [], [], '', false);
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->configMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->coreResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceHelperMock = $this->getMock('Magento\\Eav\\Model\\Resource\\Helper', [], [], '', false);
     $this->validatorFactoryMock = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false);
     $this->entityFactoryMock = $this->getMock('Magento\\Eav\\Model\\EntityFactory', [], [], '', false);
     /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject */
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->statementMock = $this->getMock('Magento\\Framework\\DB\\Statement\\Pdo\\Mysql', ['fetch'], [], '', false);
     /** @var $selectMock \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject */
     $selectMock = $this->getMock('Zend_Db_Select', [], [], '', false);
     $this->coreEntityFactoryMock->expects($this->any())->method('create')->will($this->returnCallback([$this, 'getMagentoObject']));
     $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
     $connectionMock->expects($this->any())->method('query')->willReturn($this->statementMock);
     $this->coreResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock));
     $entityMock = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', [], [], '', false);
     $entityMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($connectionMock));
     $entityMock->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([]));
     $this->validatorFactoryMock->expects($this->any())->method('create')->with('test_entity_model')->will($this->returnValue($entityMock));
     $this->model = new AbstractCollectionStub($this->coreEntityFactoryMock, $this->loggerMock, $this->fetchStrategyMock, $this->eventManagerMock, $this->configMock, $this->coreResourceMock, $this->entityFactoryMock, $this->resourceHelperMock, $this->validatorFactoryMock, null);
 }
 protected function setUp()
 {
     $this->_adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->_resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->_resourceMock->expects($this->any())->method('getConnection')->with('prefix_read')->will($this->returnValue($this->_adapterMock));
     $this->_model = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Helper\\AbstractHelper', [$this->_resourceMock, 'prefix'], '', true, true, true, ['addLikeEscape']);
 }
Beispiel #6
0
 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', 'core_read')->willReturn('table_name_search_query');
     $this->adapter->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
     $result = $this->target->resetSearchResults();
     $this->assertEquals($this->target, $result);
 }
Beispiel #7
0
 protected function setUp()
 {
     $helper = new ObjectManager($this);
     $this->select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->setMethods(['group', 'limit', 'where', 'columns', 'from', 'join'])->disableOriginalConstructor()->getMock();
     $this->select->expects($this->any())->method('from')->willReturnSelf();
     $connectionAdapter = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->setMethods(['select'])->disableOriginalConstructor()->getMockForAbstractClass();
     $connectionAdapter->expects($this->any())->method('select')->will($this->returnValue($this->select));
     $this->resource = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->any())->method('getConnection')->with(Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($connectionAdapter));
     $this->scoreBuilder = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\ScoreBuilder')->setMethods(['clear'])->disableOriginalConstructor()->getMock();
     $this->scoreBuilderFactory = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\ScoreBuilderFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->scoreBuilderFactory->expects($this->any())->method('create')->will($this->returnValue($this->scoreBuilder));
     $this->request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->setMethods(['getQuery', 'getIndex', 'getSize'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->queryContainer = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\QueryContainer')->setMethods(['addMatchQuery', 'getDerivedQueries'])->disableOriginalConstructor()->getMock();
     $this->queryContainer->expects($this->any())->method('addMatchQuery')->willReturnArgument(0);
     $queryContainerFactory = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\QueryContainerFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $queryContainerFactory->expects($this->any())->method('create')->willReturn($this->queryContainer);
     $this->filterBuilder = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Filter\\Builder')->setMethods(['build'])->disableOriginalConstructor()->getMock();
     $this->matchBuilder = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\Builder\\Match')->setMethods(['build'])->disableOriginalConstructor()->getMock();
     $this->matchBuilder->expects($this->any())->method('build')->willReturnArgument(1);
     /** @var MockObject|\Magento\Framework\Search\Adapter\Mysql\IndexBuilderInterface $indexBuilder */
     $indexBuilder = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\IndexBuilderInterface')->disableOriginalConstructor()->setMethods(['build'])->getMockForAbstractClass();
     $indexBuilder->expects($this->any())->method('build')->will($this->returnValue($this->select));
     $index = self::INDEX_NAME;
     $this->request->expects($this->exactly(2))->method('getIndex')->will($this->returnValue($index));
     $this->mapper = $helper->getObject('Magento\\Framework\\Search\\Adapter\\Mysql\\Mapper', ['resource' => $this->resource, 'scoreBuilderFactory' => $this->scoreBuilderFactory, 'queryContainerFactory' => $queryContainerFactory, 'filterBuilder' => $this->filterBuilder, 'matchBuilder' => $this->matchBuilder, 'indexProviders' => [$index => $indexBuilder]]);
 }
Beispiel #8
0
 public function testCreate()
 {
     $triggerName = 'trigger_name';
     $this->resourceMock->expects($this->atLeastOnce())->method('getTriggerName')->willReturn($triggerName);
     $triggerMock = $this->getMockBuilder('Magento\\Framework\\DB\\Ddl\\Trigger')->disableOriginalConstructor()->getMock();
     $triggerMock->expects($this->exactly(3))->method('setName')->with($triggerName)->will($this->returnSelf());
     $triggerMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('triggerName'));
     $triggerMock->expects($this->exactly(3))->method('setTime')->with(\Magento\Framework\DB\Ddl\Trigger::TIME_AFTER)->will($this->returnSelf());
     $triggerMock->expects($this->exactly(3))->method('setEvent')->will($this->returnSelf());
     $triggerMock->expects($this->exactly(3))->method('setTable')->with($this->tableName)->will($this->returnSelf());
     $triggerMock->expects($this->exactly(6))->method('addStatement')->will($this->returnSelf());
     $changelogMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\View\\ChangelogInterface', [], '', false, false, true, []);
     $changelogMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('test_view_cl'));
     $changelogMock->expects($this->exactly(3))->method('getColumnName')->will($this->returnValue('entity_id'));
     $this->viewMock->expects($this->exactly(3))->method('getChangelog')->will($this->returnValue($changelogMock));
     $this->triggerFactoryMock->expects($this->exactly(3))->method('create')->will($this->returnValue($triggerMock));
     $otherChangelogMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\View\\ChangelogInterface', [], '', false, false, true, []);
     $otherChangelogMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('other_test_view_cl'));
     $otherChangelogMock->expects($this->exactly(3))->method('getColumnName')->will($this->returnValue('entity_id'));
     $otherViewMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\ViewInterface', [], '', false, false, true, []);
     $otherViewMock->expects($this->exactly(1))->method('getId')->will($this->returnValue('other_id'));
     $otherViewMock->expects($this->exactly(1))->method('getSubscriptions')->will($this->returnValue([['name' => $this->tableName], ['name' => 'otherTableName']]));
     $otherViewMock->expects($this->exactly(3))->method('getChangelog')->will($this->returnValue($otherChangelogMock));
     $this->viewMock->expects($this->exactly(3))->method('getId')->will($this->returnValue('this_id'));
     $this->viewMock->expects($this->never())->method('getSubscriptions');
     $this->viewCollectionMock->expects($this->exactly(1))->method('getViewsByStateMode')->with(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED)->will($this->returnValue([$this->viewMock, $otherViewMock]));
     $this->connectionMock->expects($this->exactly(3))->method('dropTrigger')->with('triggerName')->will($this->returnValue(true));
     $this->connectionMock->expects($this->exactly(3))->method('createTrigger')->with($triggerMock);
     $this->model->create();
 }
Beispiel #9
0
 public function testGetTable()
 {
     $tableName = 'table';
     $expectedTableName = 'expected_table';
     $this->resourceModel->expects($this->once())->method('getTableName')->with($tableName)->will($this->returnValue($expectedTableName));
     $this->assertSame($expectedTableName, $this->object->getTable($tableName));
     // Check that table name is cached
     $this->assertSame($expectedTableName, $this->object->getTable($tableName));
 }
Beispiel #10
0
 /**
  * @param string $flatTable
  * @param bool $isFlatTableExists
  * @param string $flatDropName
  * @param string $temporaryFlatTableName
  * @param array $expectedRenameTablesArgument
  * @dataProvider moveDataProvider
  */
 public function testMove($flatTable, $isFlatTableExists, $flatDropName, $temporaryFlatTableName, $expectedRenameTablesArgument)
 {
     $this->_connectionMock->expects($this->exactly(2))->method('dropTable')->with($flatDropName);
     $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue($isFlatTableExists));
     $this->_connectionMock->expects($this->once())->method('renameTablesBatch')->with($expectedRenameTablesArgument);
     $this->_resourceMock->expects($this->any())->method('getConnection')->with('write')->will($this->returnValue($this->_connectionMock));
     $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\TableData', array('resource' => $this->_resourceMock));
     $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
 }
Beispiel #11
0
 /**
  * Initialization
  */
 protected function setUp()
 {
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->appResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->appResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $this->appResourceMock->expects($this->any())->method('getTableName')->willReturnArgument(0);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->taxItem = $objectManager->getObject('Magento\\Sales\\Model\\Resource\\Order\\Tax\\Item', ['resource' => $this->appResourceMock]);
 }
Beispiel #12
0
 protected function setUp()
 {
     $this->config = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->select = $this->getMock('Magento\\Framework\\Db\\Select', [], [], '', false);
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
     $this->storeViewService = (new ObjectManager($this))->getObject('Magento\\CatalogUrlRewrite\\Service\\V1\\StoreViewService', ['eavConfig' => $this->config, 'resource' => $this->resource]);
 }
Beispiel #13
0
 public function setUp()
 {
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $contextMock = $this->getMock('\\Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
     $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
     $this->nonceResource = new \Magento\Integration\Model\Resource\Oauth\Nonce($contextMock);
 }
 /**
  * Set Up
  */
 protected function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->requestFilter = $this->getMockBuilder('Magento\\Framework\\Search\\Request\\Filter\\Range')->setMethods(['getField', 'getFrom', 'getTo'])->disableOriginalConstructor()->getMock();
     $this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->setMethods(['quote'])->getMockForAbstractClass();
     $this->resource = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->setMethods(['getConnection'])->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->once())->method('getConnection')->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($this->adapter));
     $this->filter = $objectManager->getObject('Magento\\Framework\\Search\\Adapter\\Mysql\\Filter\\Builder\\Range', ['resource' => $this->resource]);
 }
Beispiel #15
0
 protected function setUp()
 {
     $adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($adapter));
     $this->relation = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Relation', [], [], '', false);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->configurable = $this->objectManagerHelper->getObject('Magento\\ConfigurableProduct\\Model\\Resource\\Product\\Type\\Configurable', ['resource' => $this->resource, 'catalogProductRelation' => $this->relation]);
 }
Beispiel #16
0
 protected function setUp()
 {
     $this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->setMethods(['getConnection'])->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->atLeastOnce())->method('getConnection')->with('write')->willReturn($this->adapter);
     $this->indexScopeResolver = $this->getMockBuilder('\\Magento\\Indexer\\Model\\ScopeResolver\\IndexScopeResolver')->setMethods(['resolve'])->disableOriginalConstructor()->getMock();
     $this->flatScopeResolver = $this->getMockBuilder('\\Magento\\Indexer\\Model\\ScopeResolver\\FlatScopeResolver')->setMethods(['resolve'])->disableOriginalConstructor()->getMock();
     $objectManager = new ObjectManager($this);
     $this->target = $objectManager->getObject('\\Magento\\Indexer\\Model\\IndexStructure', ['resource' => $this->resource, 'indexScopeResolver' => $this->indexScopeResolver, 'flatScopeResolver' => $this->flatScopeResolver]);
 }
Beispiel #17
0
 public function setUp()
 {
     $this->consumerMock = $this->getMock('Magento\\Integration\\Model\\Oauth\\Consumer', ['setUpdatedAt', 'getId'], [], '', false);
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $contextMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
     $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
     $this->consumerResource = new \Magento\Integration\Model\Resource\Oauth\Consumer($contextMock, new \Magento\Framework\Stdlib\DateTime());
 }
Beispiel #18
0
 /**
  * Test table name getter
  *
  * @return void
  */
 public function testGetTableName()
 {
     $prefix = 'pre_';
     $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($tableName) use($prefix) {
         return $prefix . $tableName;
     }));
     $this->assertEquals('pre_test_tmp', $this->_model->getTableName('test'));
     $this->_model->setUseIdxTable(true);
     $this->assertEquals('pre_test_idx', $this->_model->getTableName('test'));
 }
 protected function mockBuild($index, $tableSuffix)
 {
     $this->request->expects($this->once())->method('getIndex')->will($this->returnValue($index));
     $this->resource->expects($this->any())->method('getTableName')->will($this->returnCallback(function ($index) {
         return is_array($index) ? $index[0] . $index[1] : $index;
     }));
     $this->select->expects($this->once())->method('from')->with(['search_index' => $index . $tableSuffix], ['entity_id' => 'product_id'])->will($this->returnSelf());
     $this->select->expects($this->at(1))->method('joinLeft')->with(['category_index' => 'catalog_category_product_index'], 'search_index.product_id = category_index.product_id' . ' AND search_index.store_id = category_index.store_id', [])->will($this->returnSelf());
     $this->select->expects($this->at(2))->method('joinLeft')->with(['cea' => 'catalog_eav_attribute'], 'search_index.attribute_id = cea.attribute_id', ['search_weight'])->will($this->returnSelf());
     $this->select->expects($this->at(3))->method('joinLeft')->with(['cpie' => $this->resource->getTableName('catalog_product_index_eav')], 'search_index.product_id = cpie.entity_id AND search_index.attribute_id = cpie.attribute_id', [])->willReturnSelf();
 }
 /**
  * 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');
 }
Beispiel #21
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');
 }
Beispiel #22
0
 protected function setUp()
 {
     $this->_selectMock = $this->getMock('\\Magento\\Framework\\DB\\Select', array(), array(), '', false);
     $this->_selectMock->expects($this->any())->method('from')->will($this->returnSelf());
     $this->_selectMock->expects($this->any())->method('where');
     $this->_adapterMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', array(), array(), '', false);
     $this->_adapterMock->expects($this->any())->method('select')->will($this->returnValue($this->_selectMock));
     $this->_resourceMock = $this->getMock('\\Magento\\Framework\\App\\Resource', array(), array(), '', false);
     $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->_adapterMock));
     $this->_configMock = $this->getMock('\\Magento\\Eav\\Model\\Config', array(), array(), '', false);
     $this->_model = new \Magento\Sales\Model\Resource\Quote($this->_resourceMock, new \Magento\Framework\Stdlib\DateTime(), $this->_configMock);
 }
 /**
  * @param string $indexName
  * @param Dimension[] $dimensions
  * @param string $expected
  * @dataProvider resolveDataProvider
  */
 public function testResolve($indexName, array $dimensions, $expected)
 {
     $dimensions = array_map(function ($demension) {
         return $this->createDimension($demension[0], $demension[1]);
     }, $dimensions);
     $scope = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $scope->expects($this->any())->method('getId')->willReturn(1);
     $this->resource->expects($this->once())->method('getTableName')->willReturnArgument(0);
     $this->scopeResolver->expects($this->any())->method('getScope')->willReturn($scope);
     $result = $this->target->resolve($indexName, $dimensions);
     $this->assertEquals($expected, $result);
 }
Beispiel #24
0
 public function setUp()
 {
     $this->appResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->validatorMock = $this->getMock('Magento\\Sales\\Model\\Order\\Status\\History\\Validator', [], [], '', false);
     $this->appResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
     $this->adapterMock->expects($this->any())->method('insert');
     $this->adapterMock->expects($this->any())->method('lastInsertId');
     $this->historyResource = $objectManager->getObject('Magento\\Sales\\Model\\Resource\\Order\\Status\\History', ['resource' => $this->appResourceMock, 'validator' => $this->validatorMock]);
 }
Beispiel #25
0
 protected function setUp()
 {
     $this->selectMock = $this->getMock('\\Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->selectMock->expects($this->any())->method('from')->will($this->returnSelf());
     $this->selectMock->expects($this->any())->method('where');
     $this->adapterMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->adapterMock->expects($this->any())->method('select')->will($this->returnValue($this->selectMock));
     $this->resourceMock = $this->getMock('\\Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $this->configMock = $this->getMock('\\Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->model = new \Magento\Quote\Model\Resource\Quote($this->resourceMock, $this->configMock);
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Expected Exception
  * @throws \Exception
  */
 public function testSaveFailed()
 {
     $this->modelMock->expects($this->any())->method('getEventPrefix')->will($this->returnValue('event_prefix'));
     $this->modelMock->expects($this->any())->method('getEventObject')->will($this->returnValue('event_object'));
     $this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $exception = new \Exception('Expected Exception');
     $this->modelMock->expects($this->any())->method('getId')->will($this->throwException($exception));
     $this->adapterMock->expects($this->once())->method('beginTransaction');
     $this->adapterMock->expects($this->once())->method('rollback');
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('event_prefix_save_attribute_before', ['event_object' => $this->attribute, 'object' => $this->modelMock, 'attribute' => ['attribute']]);
     $this->attribute->saveAttribute($this->modelMock, 'attribute');
 }
Beispiel #27
0
 protected function setUp()
 {
     $this->link = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Link', [], [], '', false);
     $this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resource->expects($this->once())->method('getConnection')->with('write')->will($this->returnValue($this->connection));
     $this->import = $this->getMock('Magento\\ImportExport\\Model\\Import', [], [], '', false);
     $this->importFactory = $this->getMock('Magento\\ImportExport\\Model\\ImportFactory', ['create'], [], '', false);
     $this->importFactory->expects($this->any())->method('create')->will($this->returnValue($this->import));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->links = $this->objectManagerHelper->getObject('Magento\\GroupedImportExport\\Model\\Import\\Product\\Type\\Grouped\\Links', ['productLink' => $this->link, 'resource' => $this->resource, 'importFactory' => $this->importFactory]);
 }
Beispiel #28
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Context')->disableOriginalConstructor()->getMock();
     $this->scopeConfigMock = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMock();
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->getMock();
     $this->storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
     $this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceMock);
     $this->event = new Event($this->contextMock, $this->scopeConfigMock, $this->storeManagerMock);
 }
Beispiel #29
0
 protected function setUp()
 {
     $this->selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $this->selectMock->expects($this->any())->method('from')->will($this->returnValue($this->selectMock));
     $this->selectMock->expects($this->any())->method('where')->will($this->returnValue($this->selectMock));
     $this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $this->adapterMock->expects($this->any())->method('select')->willReturn($this->selectMock);
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
     $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
     $this->integrationResourceModel = new \Magento\Integration\Model\Resource\Integration($this->contextMock);
 }
Beispiel #30
0
 protected function setUp()
 {
     $this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Query', ['fetchAll'], [], '', false);
     $this->entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', ['create'], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->adapterMock = $this->getMock('Zend_Db_Adapter_Pdo_Mysql', ['select', 'query'], [], '', false);
     $this->selectMock = $this->getMock('Magento\\Framework\\DB\\Select', ['from'], ['adapter' => $this->adapterMock]);
     $this->adapterMock->expects($this->once())->method('select')->will($this->returnValue($this->selectMock));
     $this->resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->adapterMock));
     $this->resourceMock->expects($this->once())->method('getTableName')->will($this->returnArgument(0));
     $this->collection = new Collection($this->entityFactoryMock, $this->loggerMock, $this->fetchStrategyMock, $this->resourceMock);
 }