コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: Observer.php プロジェクト: shabbirvividads/magento2
 /**
  * Update items stock status and low stock date.
  *
  * @param EventObserver $observer
  * @return void
  */
 public function updateItemsStockUponConfigChange($observer)
 {
     $website = $observer->getEvent()->getWebsite();
     $this->_resourceStock->updateSetOutOfStock($website);
     $this->_resourceStock->updateSetInStock($website);
     $this->_resourceStock->updateLowStockDate($website);
 }
コード例 #3
0
ファイル: Observer.php プロジェクト: Atlis/docker-magento2
 /**
  * Update items stock status and low stock date.
  *
  * @return $this
  */
 public function updateItemsStockUponConfigChange()
 {
     $this->_resourceStock->updateSetOutOfStock();
     $this->_resourceStock->updateSetInStock();
     $this->_resourceStock->updateLowStockDate();
     return $this;
 }
コード例 #4
0
 /**
  * @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));
 }
コード例 #5
0
 /**
  * @param StockInterface $stock
  * @return bool|true
  * @throws CouldNotDeleteException
  */
 public function delete(StockInterface $stock)
 {
     try {
         $this->resource->delete($stock);
     } catch (\Exception $exception) {
         throw new CouldNotDeleteException(__($exception->getMessage()));
     }
     return true;
 }
コード例 #6
0
 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);
 }