public function testSave()
 {
     $params = [];
     $stockItemMock = $this->getMockBuilder('Magento\\CatalogInventory\\Api\\Data\\StockItemInterface')->disableOriginalConstructor()->getMock();
     $this->indexProcessorMock->expects($this->any())->method('reindexRow')->withAnyParameters();
     $this->assertInstanceOf('Magento\\CatalogInventory\\Api\\Data\\StockItemInterface', $this->model->save($stockItemMock, $params));
 }
Exemplo n.º 2
0
 /**
  * @expectedException \Magento\Framework\Exception\CouldNotSaveException
  */
 public function testSaveException()
 {
     $productId = 1;
     $this->stockItemMock->expects($this->any())->method('getProductId')->willReturn($productId);
     $this->productMock->expects($this->once())->method('load')->with($productId)->willReturnSelf();
     $this->productMock->expects($this->once())->method('getId')->willReturn($productId);
     $this->productMock->expects($this->once())->method('getTypeId')->willReturn('typeId');
     $this->stockConfigurationMock->expects($this->once())->method('isQty')->with('typeId')->willReturn(false);
     $this->stockItemMock->expects($this->once())->method('setQty')->with(0)->willReturnSelf();
     $this->stockItemMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->stockItemMock->expects($this->once())->method('setWebsiteId')->with(1)->willReturnSelf();
     $this->stockItemMock->expects($this->once())->method('getStockId')->willReturn(1);
     $this->stockItemMock->expects($this->once())->method('setStockId')->with(1)->willReturnSelf();
     $this->stockItemResourceMock->expects($this->once())->method('save')->with($this->stockItemMock)->willThrowException(new \Exception());
     $this->model->save($this->stockItemMock);
 }