public function testUpdateItemsStockUponConfigChange() { $websiteId = 1; $this->resourceStock->expects($this->once())->method('updateSetOutOfStock'); $this->resourceStock->expects($this->once())->method('updateSetInStock'); $this->resourceStock->expects($this->once())->method('updateLowStockDate'); $this->event->expects($this->once())->method('getWebsite')->will($this->returnValue($websiteId)); $this->observer->execute($this->eventObserver); }
public function testGetProductsCollection() { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ $productCollection = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', [], [], '', false); $this->product->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection)); $productCollection->expects($this->once())->method('addAttributeToSelect')->will($this->returnSelf()); $productCollection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf()); $productCollection->expects($this->once())->method('setOrder')->will($this->returnSelf()); $this->eventManager->expects($this->once())->method('dispatch')->with('rss_catalog_notify_stock_collection_select'); $this->stock->expects($this->once())->method('addLowStockFilter')->with($productCollection); $products = $this->notifyStock->getProductsCollection(); $this->assertEquals($productCollection, $products); }
/** * @expectedException \Magento\Framework\Exception\CouldNotDeleteException * @expectedExceptionMessage Stock with id "1" does not exist. */ public function testDeleteByIdException() { $id = 1; $this->stockFactoryMock->expects($this->once())->method('create')->willReturn($this->stockMock); $this->stockResourceMock->expects($this->once())->method('load')->with($this->stockMock, $id); $this->stockMock->expects($this->once())->method('getId')->willReturn(null); $this->assertTrue($this->model->deleteById($id)); }