Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddStockStatusToCollectionTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class AddStockStatusToCollectionTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $plugin;
16 
20  protected $stockHelper;
21 
22  protected function setUp()
23  {
24  $this->stockHelper = $this->createMock(\Magento\CatalogInventory\Helper\Stock::class);
25  $this->plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
26  \Magento\CatalogInventory\Model\AddStockStatusToCollection::class,
27  [
28  'stockHelper' => $this->stockHelper,
29  ]
30  );
31  }
32 
34  {
35  $productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class)
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $this->stockHelper->expects($this->once())
40  ->method('addIsInStockFilterToCollection')
41  ->with($productCollection)
42  ->will($this->returnSelf());
43 
44  $this->plugin->beforeLoad($productCollection);
45  }
46 }