Ejemplo n.º 1
0
 public function testAddInventoryDataToCollection()
 {
     $productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Collection')->disableOriginalConstructor()->getMock();
     $this->event->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection));
     $this->stockHelper->expects($this->once())->method('addStockStatusToProducts')->with($productCollection)->will($this->returnSelf());
     $this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
     $this->assertEquals($this->observer, $this->observer->addStockStatusToCollection($this->eventObserver));
 }
Ejemplo n.º 2
0
 public function testAddStockStatusToCollectionRequireStockItems()
 {
     $requireStockItems = true;
     $productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Collection')->disableOriginalConstructor()->setMethods(['hasFlag'])->getMock();
     $this->event->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection));
     $productCollection->expects($this->once())->method('hasFlag')->with('require_stock_items')->will($this->returnValue($requireStockItems));
     $stock = $this->getMockBuilder('Magento\\CatalogInventory\\Model\\Stock')->disableOriginalConstructor()->getMock();
     $this->stockFactory->expects($this->once())->method('create')->will($this->returnValue($stock));
     $stock->expects($this->once())->method('addItemsToProducts')->with($productCollection)->will($this->returnSelf());
     $this->assertEquals($this->model, $this->model->addStockStatusToCollection($this->eventObserver));
 }