Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IndexersStatesApplyFixtureTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Setup\Fixtures\IndexersStatesApplyFixture;
10 
11 class IndexersStatesApplyFixtureTest extends \PHPUnit\Framework\TestCase
12 {
16  private $fixtureModelMock;
17 
21  private $model;
22 
23  public function setUp()
24  {
25  $this->fixtureModelMock = $this->createMock(\Magento\Setup\Fixtures\FixtureModel::class);
26 
27  $this->model = new IndexersStatesApplyFixture($this->fixtureModelMock);
28  }
29 
30  public function testExecute()
31  {
32  $cacheInterfaceMock = $this->createMock(\Magento\Framework\App\CacheInterface::class);
33  $indexerRegistryMock = $this->createMock(\Magento\Framework\Indexer\IndexerRegistry::class);
34  $indexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class);
35 
36  $indexerRegistryMock->expects($this->once())
37  ->method('get')
38  ->willReturn($indexerMock);
39 
40  $indexerMock->expects($this->once())
41  ->method('setScheduled');
42 
43  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
44  $objectManagerMock->expects($this->once())
45  ->method('get')
46  ->willReturn($cacheInterfaceMock);
47  $objectManagerMock->expects($this->once())
48  ->method('create')
49  ->willReturn($indexerRegistryMock);
50 
51  $this->fixtureModelMock
52  ->expects($this->once())
53  ->method('getValue')
54  ->willReturn([
55  'indexer' => ['id' => 1]
56  ]);
57  $this->fixtureModelMock
58  ->method('getObjectManager')
59  ->willReturn($objectManagerMock);
60 
61  $this->model->execute();
62  }
63 
64  public function testNoFixtureConfigValue()
65  {
66  $cacheInterfaceMock = $this->createMock(\Magento\Framework\App\CacheInterface::class);
67  $cacheInterfaceMock->expects($this->never())->method('clean');
68 
69  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
70  $objectManagerMock->expects($this->never())
71  ->method('get')
72  ->willReturn($cacheInterfaceMock);
73 
74  $this->fixtureModelMock
75  ->expects($this->never())
76  ->method('getObjectManager')
77  ->willReturn($objectManagerMock);
78  $this->fixtureModelMock
79  ->expects($this->once())
80  ->method('getValue')
81  ->willReturn(false);
82 
83  $this->model->execute();
84  }
85 
86  public function testGetActionTitle()
87  {
88  $this->assertSame('Indexers Mode Changes', $this->model->getActionTitle());
89  }
90 
91  public function testIntroduceParamLabels()
92  {
93  $this->assertSame([], $this->model->introduceParamLabels());
94  }
95 }