Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigStatusCommandTest.php
Go to the documentation of this file.
1 <?php
7 
11 use Symfony\Component\Console\Tester\CommandTester;
12 
16 class ConfigStatusCommandTest extends \PHPUnit\Framework\TestCase
17 {
18 
22  private $command;
26  private $changeDetector;
27 
31  protected function setUp()
32  {
33  $this->changeDetector = $this->getMockBuilder(ChangeDetector::class)
34  ->disableOriginalConstructor()
35  ->getMock();
36 
37  $this->command = new ConfigStatusCommand($this->changeDetector);
38  }
39 
47  public function testExecute(bool $hasChanges, $expectedMessage, $expectedCode)
48  {
49  $this->changeDetector->expects($this->once())
50  ->method('hasChanges')
51  ->will($this->returnValue($hasChanges));
52 
53  $tester = new CommandTester($this->command);
54  $tester->execute([]);
55 
56  $this->assertEquals($expectedMessage, $tester->getDisplay());
57  $this->assertSame($expectedCode, $tester->getStatusCode());
58  }
59 
63  public function executeDataProvider()
64  {
65  return [
66  'Config is up to date' => [
67  false,
68  'Config files are up to date.' . PHP_EOL,
70  ],
71  'Config needs update' => [
72  true,
73  'Config files have changed. ' .
74  'Run app:config:import or setup:upgrade command to synchronize configuration.' . PHP_EOL,
76  ],
77  ];
78  }
79 }
testExecute(bool $hasChanges, $expectedMessage, $expectedCode)