Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
IndexerResetStateCommandTest.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Tester\CommandTester;
11 
13 {
19  private $command;
20 
21  protected function setUp()
22  {
23  parent::setUp();
24  $this->stateMock->expects($this->once())->method('setAreaCode')->with(FrontNameResolver::AREA_CODE);
25  }
26 
27  public function testExecute()
28  {
29  $this->configureAdminArea();
30  $indexerOne = $this->getIndexerMock(
31  ['getState'],
32  ['indexer_id' => 'indexer_1', 'title' => 'Title_indexerOne']
33  );
34  $this->initIndexerCollectionByItems([$indexerOne]);
35 
36  $stateMock = $this->createMock(\Magento\Indexer\Model\Indexer\State::class);
37  $stateMock->expects($this->exactly(1))
38  ->method('setStatus')
39  ->with(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID)
40  ->will($this->returnSelf());
41 
42  $stateMock->expects($this->exactly(1))
43  ->method('save');
44 
45  $indexerOne->expects($this->once())
46  ->method('getState')
47  ->willReturn($stateMock);
48 
49  $this->command = new IndexerResetStateCommand($this->objectManagerFactory);
50  $commandTester = new CommandTester($this->command);
51  $commandTester->execute([]);
52  $actualValue = $commandTester->getDisplay();
53  $this->assertSame(sprintf('Title_indexerOne indexer has been invalidated.') . PHP_EOL, $actualValue);
54  }
55 }