/** * @param int|\Magento\Catalog\Model\Product $product * @param int $expectedIdCall * @dataProvider affectedProductsDataProvider */ public function testAroundApplyAllRulesToProduct($product, $expectedIdCall) { $this->_priceProcessorMock->expects($this->once())->method('reindexRow')->with($expectedIdCall); $ruleMock = $this->getMock('Magento\\CatalogRule\\Model\\Rule', array(), array(), '', false); $this->_model->aroundApplyToProduct($ruleMock, function () { }, $product); }
public function testRefundOrderInventory() { $websiteId = 0; $ids = ['1', '14']; $items = []; $isAutoReturnEnabled = true; $itemsToUpdate = []; foreach ($ids as $id) { $item = $this->getCreditMemoItem($id); $items[] = $item; $itemsToUpdate[$item->getProductId()] = $item->getQty(); } $creditMemo = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', [], [], '', false); $creditMemo->expects($this->once())->method('getAllItems')->will($this->returnValue($items)); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId', '__wakeup'], [], '', false); $store->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId)); $creditMemo->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->stockConfiguration->expects($this->any())->method('isAutoReturnEnabled')->will($this->returnValue($isAutoReturnEnabled)); $this->stockManagement->expects($this->once())->method('revertProductsSale')->with($itemsToUpdate, $websiteId); $this->stockIndexerProcessor->expects($this->once())->method('reindexList')->with($ids); $this->priceIndexer->expects($this->once())->method('reindexList')->with($ids); $this->event->expects($this->once())->method('getCreditmemo')->will($this->returnValue($creditMemo)); $this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event)); $this->observer->refundOrderInventory($this->eventObserver); }
public function testRefreshSpecialPrices() { $idsToProcess = [1, 2, 3]; $this->metadataPool->expects($this->atLeastOnce())->method('getMetadata')->willReturn($this->metadataMock); $this->metadataMock->expects($this->atLeastOnce())->method('getLinkField')->willReturn('row_id'); $this->metadataMock->expects($this->atLeastOnce())->method('getIdentifierField')->willReturn('entity_id'); $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false); $selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $selectMock->expects($this->any())->method('joinLeft')->will($this->returnSelf()); $selectMock->expects($this->any())->method('where')->will($this->returnSelf()); $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $connectionMock->expects($this->any())->method('fetchCol')->will($this->returnValue($idsToProcess)); $this->_resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock)); $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('category')); $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false); $storeMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->_storeManagerMock->expects($this->once())->method('getStores')->with(true)->will($this->returnValue([$storeMock])); $this->_localeDateMock->expects($this->once())->method('scopeTimeStamp')->with($storeMock)->will($this->returnValue(32000)); $indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', [], [], '', false); $indexerMock->expects($this->exactly(2))->method('reindexList'); $this->_priceProcessorMock->expects($this->exactly(2))->method('getIndexer')->will($this->returnValue($indexerMock)); $attributeMock = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], '', false, true, true, ['__wakeup', 'getAttributeId']); $attributeMock->expects($this->any())->method('getAttributeId')->will($this->returnValue(1)); $this->_eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock)); $this->_model->execute(); }
public function testRefreshSpecialPrices() { $idsToProcess = array(1, 2, 3); $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', array(), array(), '', false); $selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $selectMock->expects($this->any())->method('where')->will($this->returnSelf()); $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', array(), array(), '', false); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $connectionMock->expects($this->any())->method('fetchCol')->with($selectMock, array('entity_id'))->will($this->returnValue($idsToProcess)); $this->_resourceMock->expects($this->once())->method('getConnection')->with('write')->will($this->returnValue($connectionMock)); $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', array(), array(), '', false); $storeMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->_storeManagerMock->expects($this->once())->method('getStores')->with(true)->will($this->returnValue(array($storeMock))); $this->_localeDateMock->expects($this->once())->method('scopeTimeStamp')->with($storeMock)->will($this->returnValue(32000)); $indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', array(), array(), '', false); $indexerMock->expects($this->exactly(2))->method('reindexList'); $this->_priceProcessorMock->expects($this->exactly(2))->method('getIndexer')->will($this->returnValue($indexerMock)); $attributeMock = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', array(), '', false, true, true, array('__wakeup', 'getAttributeId')); $attributeMock->expects($this->any())->method('getAttributeId')->will($this->returnValue(1)); $this->_eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock)); $this->_model->refreshSpecialPrices(); }
public function testPriceReindexCallback() { $this->model = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product', ['catalogProductType' => $this->productTypeInstanceMock, 'categoryIndexer' => $this->categoryIndexerMock, 'productFlatIndexerProcessor' => $this->productFlatProcessor, 'productPriceIndexerProcessor' => $this->productPriceProcessor, 'catalogProductOption' => $this->optionInstanceMock, 'resource' => $this->resource, 'registry' => $this->registry, 'categoryRepository' => $this->categoryRepository, 'data' => []]); $this->productPriceProcessor->expects($this->once())->method('reindexRow'); $this->assertNull($this->model->priceReindexCallback()); }
public function testAfterDelete() { $this->_priceProcessorMock->expects($this->once())->method('markIndexerAsInvalid'); $websiteMock = $this->getMock('Magento\\Store\\Model\\Resource\\Website', [], [], '', false); $this->assertEquals('return_value', $this->_model->afterDelete($websiteMock, 'return_value')); }
public function testPriceReindexCallback() { $this->productPriceProcessor->expects($this->once())->method('reindexRow'); $this->assertNull($this->model->priceReindexCallback()); }