public function testGetProductsCollection() { /** @var \Magento\Catalog\Model\Resource\Product\Collection $productCollection */ $productCollection = $this->getMock('Magento\\Catalog\\Model\\Resource\\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)); }
public function testUpdateItemsStockUponConfigChange() { $websiteId = 1; $this->resourceStock->expects($this->once())->method('updateSetOutOfStock')->willReturn(null); $this->resourceStock->expects($this->once())->method('updateSetInStock')->willReturn(null); $this->resourceStock->expects($this->once())->method('updateLowStockDate')->willReturn(null); $this->event->expects($this->once())->method('getWebsite')->will($this->returnValue($websiteId)); $this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event)); $this->observer->updateItemsStockUponConfigChange($this->eventObserver); }