10 use Symfony\Component\Console\Tester\CommandTester;
30 private $objectManagerMock;
34 $this->objectManagerMock = $this->getMockForAbstractClass(\
Magento\Framework\ObjectManagerInterface::class);
35 $this->modeMock = $this->createMock(\
Magento\Deploy\Model\Mode::class);
37 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
39 \
Magento\Deploy\Console\Command\SetModeCommand::class,
40 [
'objectManager' => $this->objectManagerMock]
43 $this->objectManagerMock->expects($this->once())->method(
'create')->willReturn($this->modeMock);
48 $this->modeMock->expects($this->once())->method(
'enableProductionMode');
50 $tester =
new CommandTester($this->command);
51 $tester->execute([
'mode' =>
'production']);
52 $this->assertContains(
60 $this->modeMock->expects($this->once())->method(
'enableDeveloperMode');
62 $tester =
new CommandTester($this->command);
63 $tester->execute([
'mode' =>
'developer']);
64 $this->assertContains(
72 $this->modeMock->expects($this->once())->method(
'enableDefaultMode');
74 $tester =
new CommandTester($this->command);
75 $tester->execute([
'mode' =>
'default']);
76 $this->assertContains(
84 $this->modeMock->expects($this->once())->method(
'enableProductionModeMinimal');
86 $tester =
new CommandTester($this->command);
87 $tester->execute([
'mode' =>
'production',
'--skip-compilation' =>
true]);
88 $this->assertContains(
96 $tester =
new CommandTester($this->command);
97 $tester->execute([
'mode' =>
'invalid-mode']);
98 $this->assertContains(
99 'The mode can\'t be switched to "invalid-mode".',
100 $tester->getDisplay()
testSetProductionSkipCompilation()