Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShowModeCommandTest.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Tester\CommandTester;
11 
15 class ShowModeCommandTest extends \PHPUnit\Framework\TestCase
16 {
20  private $modeMock;
21 
25  private $command;
26 
30  private $objectManagerMock;
31 
32  protected function setUp()
33  {
34  $this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
35  $this->modeMock = $this->createMock(\Magento\Deploy\Model\Mode::class);
36 
37  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
38  $this->command = $objectManager->getObject(
39  \Magento\Deploy\Console\Command\ShowModeCommand::class,
40  ['objectManager' => $this->objectManagerMock]
41  );
42 
43  $this->objectManagerMock->expects($this->once())->method('create')->willReturn($this->modeMock);
44  }
45 
46  public function testExecute()
47  {
48  $currentMode = 'application-mode';
49  $this->modeMock->expects($this->once())->method('getMode')->willReturn($currentMode);
50 
51  $tester = new CommandTester($this->command);
52  $tester->execute([]);
53  $this->assertContains(
54  $currentMode,
55  $tester->getDisplay()
56  );
57  }
58 }
$objectManager
Definition: bootstrap.php:17