ShowModeCommandTest.php 1.7 KB

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