Skip to content

Commit

Permalink
⏫ Forwardport of #11054 to 2.3-develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bystritsky committed Jan 24, 2018
1 parent 8e77e2f commit 299109f
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 299109f

Please sign in to comment.