Пример #1
0
 /**
  * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
  * @expectedExceptionMessage Stock Item with id "1" does not exist.
  */
 public function testDeleteByIdException()
 {
     $id = 1;
     $this->stockItemFactoryMock->expects($this->once())->method('create')->willReturn($this->stockItemMock);
     $this->stockItemResourceMock->expects($this->once())->method('load')->with($this->stockItemMock, $id);
     $this->stockItemMock->expects($this->once())->method('getItemId')->willReturn(null);
     $this->assertTrue($this->model->deleteById($id));
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->stock = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\Data\\StockInterface', ['__wakeup', 'getStockId'], '', false);
     $this->stockItem = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\Data\\StockItemInterface', ['__wakeup', 'getItemId'], '', false);
     $this->stockStatus = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\Data\\StockStatusInterface', ['__wakeup', 'getProductId'], '', false);
     $this->stockFactory = $this->getMock('\\Magento\\CatalogInventory\\Api\\Data\\StockInterfaceFactory', ['create'], [], '', false);
     $this->stockFactory->expects($this->any())->method('create')->willReturn($this->stock);
     $this->stockItemFactory = $this->getMock('\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterfaceFactory', ['create'], [], '', false);
     $this->stockItemFactory->expects($this->any())->method('create')->willReturn($this->stockItem);
     $this->stockStatusFactory = $this->getMock('\\Magento\\CatalogInventory\\Api\\Data\\StockStatusInterfaceFactory', ['create'], [], '', false);
     $this->stockStatusFactory->expects($this->any())->method('create')->willReturn($this->stockStatus);
     $this->stockRepository = $this->getMockBuilder('\\Magento\\CatalogInventory\\Api\\StockRepositoryInterface')->disableOriginalConstructor()->getMock();
     $this->stockItemRepository = $this->getMockBuilder('\\Magento\\CatalogInventory\\Api\\StockItemRepositoryInterface')->disableOriginalConstructor()->getMock();
     $this->stockStatusRepository = $this->getMockBuilder('\\Magento\\CatalogInventory\\Api\\StockStatusRepositoryInterface')->disableOriginalConstructor()->getMock();
     $this->stockCriteriaFactory = $this->getMock('Magento\\CatalogInventory\\Api\\StockCriteriaInterfaceFactory', ['create'], [], '', false);
     $this->stockCriteria = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\StockCriteriaInterface', ['setScopeFilter'], '', false);
     $this->stockItemCriteriaFactory = $this->getMock('Magento\\CatalogInventory\\Api\\StockItemCriteriaInterfaceFactory', ['create'], [], '', false);
     $this->stockItemCriteria = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\StockItemCriteriaInterface', ['setProductsFilter', 'setScopeFilter'], '', false);
     $this->stockStatusCriteriaFactory = $this->getMock('Magento\\CatalogInventory\\Api\\StockStatusCriteriaInterfaceFactory', ['create'], [], '', false);
     $this->stockStatusCriteria = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\StockStatusCriteriaInterface', ['setProductsFilter', 'setScopeFilter'], '', false);
     $this->stockRegistryProvider = $this->objectManagerHelper->getObject('\\Magento\\CatalogInventory\\Model\\StockRegistryProvider', ['stockRepository' => $this->stockRepository, 'stockFactory' => $this->stockFactory, 'stockItemRepository' => $this->stockItemRepository, 'stockItemFactory' => $this->stockItemFactory, 'stockStatusRepository' => $this->stockStatusRepository, 'stockStatusFactory' => $this->stockStatusFactory, 'stockCriteriaFactory' => $this->stockCriteriaFactory, 'stockItemCriteriaFactory' => $this->stockItemCriteriaFactory, 'stockStatusCriteriaFactory' => $this->stockStatusCriteriaFactory]);
 }