Beispiel #1
0
 public function testExecutePageDirectAccess()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(null);
     $this->request->expects($this->any())->method('getParams')->willReturn([]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn(null);
     $resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->setMethods(['setPath'])->disableOriginalConstructor()->getMock();
     $resultRedirect->expects($this->any())->method('setPath')->with('catalog/product/', ['_current' => true])->willReturnSelf();
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($resultRedirect);
     $this->assertSame($resultRedirect, $this->object->execute());
 }
Beispiel #2
0
 public function testExecuteThatProductIdsAreObtainedFromAttributeHelper()
 {
     $this->attributeHelper->expects($this->any())->method('getProductIds')->will($this->returnValue([5]));
     $this->attributeHelper->expects($this->any())->method('getSelectedStoreId')->will($this->returnValue([1]));
     $this->inventoryHelper->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([]));
     $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true));
     $this->stockItemService->expects($this->any())->method('getStockItem')->with(5)->will($this->returnValue($this->stockItem));
     $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['inventory', [], [7]]]));
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->object->execute();
 }
Beispiel #3
0
 public function testExecuteThatProductIdsAreObtainedFromAttributeHelper()
 {
     $this->attributeHelper->expects($this->any())->method('getProductIds')->will($this->returnValue([5]));
     $this->attributeHelper->expects($this->any())->method('getSelectedStoreId')->will($this->returnValue([1]));
     $this->attributeHelper->expects($this->any())->method('getStoreWebsiteId')->will($this->returnValue(1));
     $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([]));
     $this->dataObjectHelperMock->expects($this->any())->method('populateWithArray')->with($this->stockItem, $this->anything(), '\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterface')->willReturnSelf();
     $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true));
     $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1)->will($this->returnValue($this->stockItem));
     $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['inventory', [], [7]]]));
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->object->execute();
 }
Beispiel #4
0
 public function testExecuteThatProductIdsAreObtainedFromAttributeHelper()
 {
     $this->attributeHelper->expects($this->any())->method('getProductIds')->will($this->returnValue([5]));
     $this->attributeHelper->expects($this->any())->method('getSelectedStoreId')->will($this->returnValue([1]));
     $this->attributeHelper->expects($this->any())->method('getStoreWebsiteId')->will($this->returnValue(1));
     $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([]));
     $itemToSave = $this->getMockBuilder('Magento\\CatalogInventory\\Api\\Data\\StockItemInterface')->disableOriginalConstructor()->setMethods(['setItemId', 'save'])->getMockForAbstractClass();
     $this->stockItemBuilder->expects($this->any())->method('mergeDataObjectWithArray')->withAnyParameters()->willReturnSelf();
     $this->stockItemBuilder->expects($this->any())->method('create')->willReturn($itemToSave);
     $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true));
     $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1)->will($this->returnValue($this->stockItem));
     $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['inventory', [], [7]]]));
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->object->execute();
 }