public function testAddInventoryData()
 {
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $this->event->expects($this->once())->method('getProduct')->will($this->returnValue($product));
     $this->stockHelper->expects($this->once())->method('assignStatusToProduct')->with($product)->will($this->returnSelf());
     $this->observer->execute($this->eventObserver);
 }
 /**
  * @dataProvider stockStatusDataProvider
  */
 public function testAfterGetProductCollectionShow($status, $callCount)
 {
     list($collectionMock, $subjectMock) = $this->buildMocks();
     $this->configMock->expects($this->once())->method('isShowOutOfStock')->will($this->returnValue($status));
     $this->stockHelperMock->expects($this->exactly($callCount))->method('addInStockFilterToCollection')->with($collectionMock);
     $this->assertEquals($collectionMock, $this->model->afterGetProductCollection($subjectMock, $collectionMock));
 }
 public function testAddStockStatusToCollection()
 {
     $productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\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->observer->execute($this->eventObserver);
 }
 /**
  *  Test add stock status to collection with 'display out of stock' option enabled
  */
 public function testAddStockStatusEnabledShow()
 {
     $this->_scopeConfigMock->expects($this->once())->method('isSetFlag')->with('cataloginventory/options/show_out_of_stock')->will($this->returnValue(false));
     $collectionMock = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', [], [], '', false);
     $this->_stockHelperMock->expects($this->once())->method('addIsInStockFilterToCollection')->with($collectionMock);
     $subjectMock = $this->getMock('\\Magento\\Catalog\\Model\\Layer', [], [], '', false);
     $this->_model->beforePrepareProductCollection($subjectMock, $collectionMock);
 }
 public function testGetProductCollection()
 {
     $this->stockHelperMock->expects($this->once())->method('addInStockFilterToCollection')->with($this->productCollection);
     $this->assertInstanceOf('Magento\\Catalog\\Model\\ResourceModel\\Product\\Link\\Product\\Collection', $this->model->getProductCollection());
 }
 public function testAddStockStatusToCollection()
 {
     $productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->disableOriginalConstructor()->getMock();
     $this->stockHelper->expects($this->once())->method('addIsInStockFilterToCollection')->with($productCollection)->will($this->returnSelf());
     $this->plugin->beforeLoad($productCollection);
 }