/** * @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)); }