Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderGridUpdaterTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PHPUnit_Framework_MockObject_MockObject as MockObject;
12 
13 class OrderGridUpdaterTest extends \PHPUnit\Framework\TestCase
14 {
18  private $orderGrid;
19 
23  private $globalConfig;
24 
28  private $model;
29 
33  protected function setUp()
34  {
35  $this->orderGrid = $this->getMockBuilder(GridInterface::class)
36  ->getMockForAbstractClass();
37  $this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
38  ->getMockForAbstractClass();
39 
40  $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
41  }
42 
43  public function testUpdateInSyncMode()
44  {
45  $orderId = 1;
46 
47  $this->globalConfig->expects($this->once())
48  ->method('getValue')
49  ->with('dev/grid/async_indexing', 'default', null)
50  ->willReturn(false);
51  $this->orderGrid->expects($this->once())
52  ->method('refresh')
53  ->with($orderId);
54 
55  $this->model->update($orderId);
56  }
57 
58  public function testUpdateInAsyncMode()
59  {
60  $orderId = 1;
61 
62  $this->globalConfig->expects($this->once())
63  ->method('getValue')
64  ->with('dev/grid/async_indexing', 'default', null)
65  ->willReturn(true);
66  $this->orderGrid->expects($this->never())
67  ->method('refresh')
68  ->with($orderId);
69 
70  $this->model->update($orderId);
71  }
72 }