1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Deploy\Test\Unit\Console\Command;
use Magento\Deploy\Console\Command\ShowModeCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Magento\Framework\App\State;
/**
* @package Magento\Deploy\Test\Unit\Console\Command
*/
class ShowModeCommandTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Deploy\Model\Mode|\PHPUnit_Framework_MockObject_MockObject
*/
private $modeMock;
/**
* @var ShowModeCommand
*/
private $command;
/**
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $objectManagerMock;
protected function setUp()
{
$this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
$this->modeMock = $this->createMock(\Magento\Deploy\Model\Mode::class);
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->command = $objectManager->getObject(
\Magento\Deploy\Console\Command\ShowModeCommand::class,
['objectManager' => $this->objectManagerMock]
);
$this->objectManagerMock->expects($this->once())->method('create')->willReturn($this->modeMock);
}
public function testExecute()
{
$currentMode = 'application-mode';
$this->modeMock->expects($this->once())->method('getMode')->willReturn($currentMode);
$tester = new CommandTester($this->command);
$tester->execute([]);
$this->assertContains(
$currentMode,
$tester->getDisplay()
);
}
}