/**
  * Run test getStoreWebsiteId method
  *
  * @return void
  */
 public function testGetStoreWebsiteId()
 {
     $storeId = 20;
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false);
     $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($storeMock));
     $storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('return-value'));
     $this->assertEquals('return-value', $this->attribute->getStoreWebsiteId($storeId));
 }
Exemple #2
0
 /**
  * Validate selection of products for mass update
  *
  * @return boolean
  */
 protected function _validateProducts()
 {
     $error = false;
     $productIds = $this->attributeHelper->getProductIds();
     if (!is_array($productIds)) {
         $error = __('Please select products for attributes update.');
     } elseif (!$this->_objectManager->create('Magento\\Catalog\\Model\\Product')->isProductsHasSku($productIds)) {
         $error = __('Please make sure to define SKU values for all processed products.');
     }
     if ($error) {
         $this->messageManager->addError($error);
     }
     return !$error;
 }
Exemple #3
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());
 }
Exemple #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->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();
 }
 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();
 }
Exemple #6
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();
 }
Exemple #7
0
 /**
  * Retrieve attributes for product mass update
  *
  * @return \Magento\Framework\Object[]
  */
 public function getAttributes()
 {
     return $this->_attributeAction->getAttributes()->getItems();
 }