123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- // @codingStandardsIgnoreStart
- namespace Magento\Developer\Console\Command {
- use Symfony\Component\Console\Tester\CommandTester;
- $devTestsRunCommandTestPassthruReturnVar = null;
- /**
- * Mock for PHP builtin passthtru function
- *
- * @param string $command
- * @param int|null $return_var
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- function passthru($command, &$return_var = null)
- {
- global $devTestsRunCommandTestPassthruReturnVar;
- $return_var = $devTestsRunCommandTestPassthruReturnVar;
- }
- /**
- * Class DevTestsRunCommandTest
- *
- * Tests dev:tests:run command. Only tests error case because DevTestsRunCommand calls phpunit with
- * passthru, so there is no good way to mock out running the tests.
- */
- class DevTestsRunCommandTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var DevTestsRunCommand
- */
- private $command;
- protected function setUp()
- {
- $this->command = new DevTestsRunCommand();
- }
- public function testExecuteBadType()
- {
- $commandTester = new CommandTester($this->command);
- $commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']);
- $this->assertContains('Invalid type: "bad"', $commandTester->getDisplay());
- }
- public function testPassArgumentsToPHPUnit()
- {
- global $devTestsRunCommandTestPassthruReturnVar;
- $devTestsRunCommandTestPassthruReturnVar = 0;
- $commandTester = new CommandTester($this->command);
- $commandTester->execute(
- [
- DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
- '-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
- ]
- );
- $this->assertContains(
- 'phpunit --list-suites',
- $commandTester->getDisplay(),
- 'Parameters should be passed to PHPUnit'
- );
- $this->assertContains(
- 'PASSED (',
- $commandTester->getDisplay(),
- 'PHPUnit runs should have passed'
- );
- }
- public function testPassArgumentsToPHPUnitNegative()
- {
- global $devTestsRunCommandTestPassthruReturnVar;
- $devTestsRunCommandTestPassthruReturnVar = 255;
- $commandTester = new CommandTester($this->command);
- $commandTester->execute(
- [
- DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
- '-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
- ]
- );
- $this->assertContains(
- 'phpunit --list-suites',
- $commandTester->getDisplay(),
- 'Parameters should be passed to PHPUnit'
- );
- $this->assertContains(
- 'FAILED - ',
- $commandTester->getDisplay(),
- 'PHPUnit runs should have passed'
- );
- }
- }
- }
|