Exemple #1
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]);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function buildFilter(\Magento\Framework\Search\Request\FilterInterface $filter)
 {
     $adapter = $this->resource->getConnection(Resource::DEFAULT_READ_RESOURCE);
     /** @var \Magento\Framework\Search\Request\Filter\Term $filter */
     $condition = sprintf('%s = %s', $filter->getField(), $adapter->quote($filter->getValue()));
     return $condition;
 }
Exemple #3
0
 /**
  * Load customer log data by customer id
  *
  * @param int $customerId
  * @return array
  */
 protected function loadLogData($customerId)
 {
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
     $adapter = $this->resource->getConnection('read');
     $select = $adapter->select()->from(['cl' => $this->resource->getTableName('customer_log')])->joinLeft(['cv' => $this->resource->getTableName('customer_visitor')], 'cv.customer_id = cl.customer_id', ['last_visit_at'])->where('cl.customer_id = ?', $customerId)->order('cv.visitor_id DESC')->limit(1);
     return $adapter->fetchRow($select);
 }
Exemple #4
0
 /**
  * @magentoDataFixture Magento/Bundle/_files/product.php
  * @covers \Magento\Indexer\Model\Indexer::reindexAll
  * @covers \Magento\Bundle\Model\Product\Type::getSearchableData
  */
 public function testPrepareProductIndexForBundleProduct()
 {
     $this->indexer->reindexAll();
     $select = $this->adapter->select()->from($this->resource->getTableName('catalogsearch_fulltext_scope1'))->where('`data_index` LIKE ?', '%' . 'Bundle Product Items' . '%');
     $result = $this->adapter->fetchAll($select);
     $this->assertCount(1, $result);
 }
 /**
  * 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'));
 }
Exemple #6
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);
 }
Exemple #7
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();
 }
Exemple #8
0
 /**
  * Execute full indexation
  *
  * @return void
  */
 public function executeFull()
 {
     $results = [];
     foreach ($this->getTables() as $table => $columns) {
         if (!count($columns)) {
             continue;
         }
         foreach ($columns as $idx => $col) {
             $columns[$idx] = '`' . $col . '`';
         }
         $select = $this->connection->select();
         $fromColumns = new \Zend_Db_Expr('CONCAT(' . implode(",' ',", $columns) . ') as data_index');
         $select->from($table, $fromColumns);
         $result = $this->connection->query($select);
         while ($row = $result->fetch()) {
             $data = $row['data_index'];
             $this->split($data, $results);
         }
     }
     $indexTable = $this->resource->getTableName('mst_misspell_index');
     $this->connection->delete($indexTable);
     $rows = [];
     foreach ($results as $word => $freq) {
         $rows[] = ['keyword' => $word, 'trigram' => $this->text->getTrigram($word), 'frequency' => $freq / count($results)];
         if (count($rows) > 1000) {
             $this->connection->insertArray($indexTable, ['keyword', 'trigram', 'frequency'], $rows);
             $rows = [];
         }
     }
     if (count($rows) > 0) {
         $this->connection->insertArray($indexTable, ['keyword', 'trigram', 'frequency'], $rows);
     }
     $this->connection->delete($this->resource->getTableName('mst_misspell_suggest'));
 }
Exemple #9
0
 /**
  * Returns connection
  *
  * @return AdapterInterface
  */
 protected function getConnection()
 {
     if (!$this->connection) {
         $this->connection = $this->resource->getConnection($this->connectionName);
     }
     return $this->connection;
 }
Exemple #10
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]]);
 }
Exemple #11
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);
 }
Exemple #12
0
 /**
  * @return \Magento\Framework\DB\Adapter\AdapterInterface
  */
 protected function getConnection()
 {
     if (!$this->connection) {
         $this->connection = $this->resource->getConnection('sales_write');
     }
     return $this->connection;
 }
 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']);
 }
 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);
 }
 /**
  * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param TableDataInterface $tableData
  */
 public function __construct(\Magento\Catalog\Helper\Product\Flat\Indexer $productIndexerHelper, \Magento\Framework\App\Resource $resource, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Indexer\Product\Flat\TableDataInterface $tableData)
 {
     $this->_productIndexerHelper = $productIndexerHelper;
     $this->_connection = $resource->getConnection('write');
     $this->_config = $config;
     $this->_storeManager = $storeManager;
     $this->_tableData = $tableData;
 }
Exemple #16
0
 /**
  * Get table name (validated by db adapter) by table placeholder
  *
  * @param string|array $tableName
  * @return string
  */
 public function getTable($tableName)
 {
     $cacheKey = $this->_getTableCacheName($tableName);
     if (!isset($this->tables[$cacheKey])) {
         $this->tables[$cacheKey] = $this->resourceModel->getTableName($tableName);
     }
     return $this->tables[$cacheKey];
 }
Exemple #17
0
 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  * @param \Magento\Framework\Model\Resource\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  * @param \Magento\UrlRewrite\Helper\UrlRewrite $urlRewriteHelper
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\App\Resource $appResource
  * @param \Magento\UrlRewrite\Model\UrlFinderInterface $urlFinder
  * @param array $data
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\UrlRewrite\Helper\UrlRewrite $urlRewriteHelper, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\Resource $appResource, \Magento\UrlRewrite\Model\UrlFinderInterface $urlFinder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data);
     $this->urlRewriteHelper = $urlRewriteHelper;
     $this->connection = $appResource->getConnection(Resource::DEFAULT_WRITE_RESOURCE);
     $this->urlFinder = $urlFinder;
     $this->storeManager = $storeManager;
 }
 /**
  * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\App\Resource $resource
  */
 public function __construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\App\Resource $resource)
 {
     $this->_setIdFieldName('primary_id');
     parent::__construct($entityFactory, $logger, $fetchStrategy, $resource->getConnection('review_read'));
     $this->_summaryTable = $resource->getTableName('review_entity_summary');
     $this->_select->from($this->_summaryTable);
     $this->setItemObjectClass('Magento\\Review\\Model\\Review\\Summary');
 }
 /**
  * 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]);
 }
Exemple #20
0
 /**
  * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php
  */
 public function testAggregate()
 {
     $rating = $this->reviewCollection->getFirstItem();
     $this->reviewResource->aggregate($rating);
     $select = $this->adapter->select()->from($this->resource->getTableName('review_entity_summary'));
     $result = $this->adapter->fetchRow($select);
     $this->assertEquals(1, $result['reviews_count']);
     $this->assertEquals(40, $result['rating_summary']);
 }
Exemple #21
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]);
 }
Exemple #22
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);
 }
Exemple #23
0
 /**
  * @param Config $eavConfig
  * @param Resource $resource
  * @param \Magento\Catalog\Helper\Product $productHelper
  * @param StoreManagerInterface $storeManager
  * @param CategoryHelper $categoryHelper
  * @param Converter $converter
  */
 public function __construct(Config $eavConfig, Resource $resource, ProductHelper $productHelper, StoreManagerInterface $storeManager, CategoryHelper $categoryHelper, Converter $converter)
 {
     $this->eavConfig = $eavConfig;
     $this->connection = $resource->getConnection(Resource::DEFAULT_READ_RESOURCE);
     $this->productHelper = $productHelper;
     $this->storeManager = $storeManager;
     $this->categoryHelper = $categoryHelper;
     $this->converter = $converter;
 }
Exemple #24
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]);
 }
 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));
 }
Exemple #26
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]);
 }
 /**
  * @param \Magento\Framework\App\Resource $resource
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper
  * @param \Magento\Catalog\Model\Product\Type $productType
  * @param TableBuilder $tableBuilder
  * @param FlatTableBuilder $flatTableBuilder
  */
 public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper, \Magento\Catalog\Model\Product\Type $productType, TableBuilder $tableBuilder, FlatTableBuilder $flatTableBuilder)
 {
     $this->_storeManager = $storeManager;
     $this->_productIndexerHelper = $productHelper;
     $this->_productType = $productType;
     $this->_connection = $resource->getConnection('default');
     $this->_tableBuilder = $tableBuilder;
     $this->_flatTableBuilder = $flatTableBuilder;
 }
Exemple #28
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);
 }
Exemple #29
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());
 }
Exemple #30
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'));
 }