diff --git a/src/Process/CommandLine.php b/src/Process/CommandLine.php index 1a73425e..0a8bd5a8 100644 --- a/src/Process/CommandLine.php +++ b/src/Process/CommandLine.php @@ -39,7 +39,7 @@ public function getExecutable(): array * * @return string[] */ - public function getOptions(PHPUnitConfig $config): array + public function getOptions(PHPUnitConfig $config, array $excludedPhpunitOptions = []): array { $options = []; @@ -59,7 +59,9 @@ public function getOptions(PHPUnitConfig $config): array ]); foreach ($config->getPhpunitOptions() as $phpunitOption) { - $options[] = $this->buildPhpunitOptionString($phpunitOption); + if(! in_array($phpunitOption->getName(), $excludedPhpunitOptions, true)) { + $options[] = $this->buildPhpunitOptionString($phpunitOption); + } } return $options; diff --git a/src/Process/ProcessFactory.php b/src/Process/ProcessFactory.php index 3448b31c..f858aa4c 100644 --- a/src/Process/ProcessFactory.php +++ b/src/Process/ProcessFactory.php @@ -15,15 +15,15 @@ class ProcessFactory implements ProcessFactoryInterface /** @var CommandLine */ private $cliCommand; - /** @var string[] */ - private $baseCommandLine; - /** @var string[] */ private $environmentVariables; /** @var ChunkSize */ private $chunkSize; + /** @var PHPUnitConfig */ + private $phpunitConfig; + public function __construct( CommandLine $cliCommand, PHPUnitConfig $phpunitConfig, @@ -31,24 +31,24 @@ public function __construct( ChunkSize $chunkSize ) { $this->cliCommand = $cliCommand; - $this->baseCommandLine = array_merge($this->cliCommand->getExecutable(), $this->cliCommand->getOptions($phpunitConfig)); $this->environmentVariables = [ EnvVariables::LOG_DIR => $tempFilenameFactory->getPathForLog(), ]; $this->chunkSize = $chunkSize; + $this->phpunitConfig = $phpunitConfig; } public function create(string $testFilePath): AbstractParaunitProcess { if ($this->chunkSize->isChunked()) { $command = array_merge( - $this->baseCommandLine, + array_merge($this->cliCommand->getExecutable(), $this->cliCommand->getOptions($this->phpunitConfig, ['testsuite'])), ['--configuration=' . $testFilePath], $this->cliCommand->getSpecificOptions($testFilePath) ); } else { $command = array_merge( - $this->baseCommandLine, + array_merge($this->cliCommand->getExecutable(), $this->cliCommand->getOptions($this->phpunitConfig)), [$testFilePath], $this->cliCommand->getSpecificOptions($testFilePath) ); diff --git a/tests/Functional/Runner/ChunkFileTest.php b/tests/Functional/Runner/ChunkFileTest.php index 824d7231..f511bf06 100644 --- a/tests/Functional/Runner/ChunkFileTest.php +++ b/tests/Functional/Runner/ChunkFileTest.php @@ -12,20 +12,6 @@ class ChunkFileTest extends BaseIntegrationTestCase { - public function testChunkedPlusTestSuiteOptions(): void - { - $this->setOption('chunk-size', '2'); - $this->setOption('testsuite', 'stubs'); - $this->setOption('debug', '1'); - $this->loadContainer(); - - $this->executeRunner(); - - $output = $this->getConsoleOutput(); - $this->assertStringNotContainsString('--testsuite', $output->getOutput()); - $this->assertStringContainsString('--configuration', $output->getOutput()); - } - public function testChunkedAllStubsSuite(): void { $chunkCount = 8; diff --git a/tests/Unit/Process/ProcessFactoryTest.php b/tests/Unit/Process/ProcessFactoryTest.php index 87194c49..cad1a8d9 100644 --- a/tests/Unit/Process/ProcessFactoryTest.php +++ b/tests/Unit/Process/ProcessFactoryTest.php @@ -10,6 +10,7 @@ use Paraunit\Process\AbstractParaunitProcess; use Paraunit\Process\CommandLine; use Paraunit\Process\ProcessFactory; +use Prophecy\Argument; use Tests\BaseUnitTestCase; class ProcessFactoryTest extends BaseUnitTestCase @@ -64,7 +65,7 @@ public function testCreateProcessChunked(): void $cliCommand = $this->prophesize(CommandLine::class); $cliCommand->getExecutable()->willReturn(['sapi', 'executable']); $cliCommand - ->getOptions($phpUnitConfig->reveal()) + ->getOptions($phpUnitConfig->reveal(), Argument::is(['testsuite'])) ->shouldBeCalled() ->willReturn([]); $cliCommand