Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ManagestockTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ManagestockTest extends \PHPUnit\Framework\TestCase
9 {
12 
14  protected $model;
15 
16  protected function setUp()
17  {
18  $this->stockIndexerProcessor = $this->getMockBuilder(
19  \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class
20  )->disableOriginalConstructor()->getMock();
21  $this->model = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
22  \Magento\CatalogInventory\Model\Config\Backend\Managestock::class,
23  [
24  'stockIndexerProcessor' => $this->stockIndexerProcessor,
25  ]
26  );
27  }
28 
34  {
35  return [
36  [1, 1],
37  [0, 0],
38  ];
39  }
40 
47  public function testSaveAndRebuildIndex($newStockValue, $callCount)
48  {
49  $this->model->setValue($newStockValue);
50  $this->stockIndexerProcessor->expects($this->exactly($callCount))->method('markIndexerAsInvalid');
51  $this->model->afterSave();
52  }
53 }