Skip to content

Commit

Permalink
Merge forwardport of #11054 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/11054.patch (created by @schmengler) based on commit(s):
  1. c3ea1f5
  2. 0c0393d
  3. 8cfd414
  • Loading branch information
magento-engcom-team authored Feb 5, 2018
2 parents 2edfe9a + 299109f commit ef5ddff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
*/
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
}

0 comments on commit ef5ddff

Please sign in to comment.