diff --git a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php index f26f0d5e79325..5b8b79ef41392 100644 --- a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php +++ b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -22,6 +23,12 @@ class DevTestsRunCommand extends Command */ const INPUT_ARG_TYPE = 'type'; + /** + * PHPUnit arguments parameter + */ + const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments'; + const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c'; + /** * command name */ @@ -56,7 +63,13 @@ protected function configure() 'Type of test to run. Available types: ' . implode(', ', array_keys($this->types)), 'default' ); - + $this->addOption( + self::INPUT_OPT_COMMAND_ARGUMENTS, + self::INPUT_OPT_COMMAND_ARGUMENTS_SHORT, + InputOption::VALUE_REQUIRED, + 'Additional arguments for PHPUnit. Example: "-c\'--filter=MyTest\'" (no spaces)', + '' + ); parent::configure(); } @@ -87,6 +100,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $dirName = realpath(BP . '/dev/tests/' . $dir); chdir($dirName); $command = PHP_BINARY . ' ' . BP . '/' . $vendorDir . '/phpunit/phpunit/phpunit ' . $options; + if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) { + $command .= ' ' . $commandArguments; + } $message = $dirName . '> ' . $command; $output->writeln(['', str_pad("---- {$message} ", 70, '-'), '']); passthru($command, $returnVal); diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php index 8ba3bd50ef301..862cdc336b803 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php @@ -34,4 +34,20 @@ public function testExecuteBadType() $commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']); $this->assertContains('Invalid type: "bad"', $commandTester->getDisplay()); } + + public function testPassArgumentsToPHPUnit() + { + $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' + ); + } }