Skip to content

Commit ef5ddff

Browse files
Merge forwardport of #11054 to 2.3-develop branch
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
2 parents 2edfe9a + 299109f commit ef5ddff

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Command\Command;
99
use Symfony\Component\Console\Input\InputArgument;
1010
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213

1314
/**
@@ -22,6 +23,12 @@ class DevTestsRunCommand extends Command
2223
*/
2324
const INPUT_ARG_TYPE = 'type';
2425

26+
/**
27+
* PHPUnit arguments parameter
28+
*/
29+
const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments';
30+
const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c';
31+
2532
/**
2633
* command name
2734
*/
@@ -56,7 +63,13 @@ protected function configure()
5663
'Type of test to run. Available types: ' . implode(', ', array_keys($this->types)),
5764
'default'
5865
);
59-
66+
$this->addOption(
67+
self::INPUT_OPT_COMMAND_ARGUMENTS,
68+
self::INPUT_OPT_COMMAND_ARGUMENTS_SHORT,
69+
InputOption::VALUE_REQUIRED,
70+
'Additional arguments for PHPUnit. Example: "-c\'--filter=MyTest\'" (no spaces)',
71+
''
72+
);
6073
parent::configure();
6174
}
6275

@@ -87,6 +100,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
87100
$dirName = realpath(BP . '/dev/tests/' . $dir);
88101
chdir($dirName);
89102
$command = PHP_BINARY . ' ' . BP . '/' . $vendorDir . '/phpunit/phpunit/phpunit ' . $options;
103+
if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) {
104+
$command .= ' ' . $commandArguments;
105+
}
90106
$message = $dirName . '> ' . $command;
91107
$output->writeln(['', str_pad("---- {$message} ", 70, '-'), '']);
92108
passthru($command, $returnVal);

app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,20 @@ public function testExecuteBadType()
3434
$commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']);
3535
$this->assertContains('Invalid type: "bad"', $commandTester->getDisplay());
3636
}
37+
38+
public function testPassArgumentsToPHPUnit()
39+
{
40+
$commandTester = new CommandTester($this->command);
41+
$commandTester->execute(
42+
[
43+
DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
44+
'-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
45+
]
46+
);
47+
$this->assertContains(
48+
'phpunit --list-suites',
49+
$commandTester->getDisplay(),
50+
'Parameters should be passed to PHPUnit'
51+
);
52+
}
3753
}

0 commit comments

Comments
 (0)