Skip to content

Commit

Permalink
Avoid passing incompatible options to chunked PHPUnit executions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean85 committed Oct 3, 2024
1 parent 00ca886 commit 57862bb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased

## [1.3.1] - 2024-10-03
* Avoid passing `--testsuite` option to PHPUnit when running with chunks [#276](https://github.com/facile-it/paraunit/pull/276)

## [1.3.0] - 2022-06-15
### Added
* Add `--chunk-size` option [#164](https://github.com/facile-it/paraunit/pull/164)
Expand Down
4 changes: 4 additions & 0 deletions src/Process/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function getOptions(PHPUnitConfig $config): array
]);

foreach ($config->getPhpunitOptions() as $phpunitOption) {
if ($this->chunkSize->isChunked() && $phpunitOption->getName() === 'testsuite') {
continue;
}

$options[] = $this->buildPhpunitOptionString($phpunitOption);
}

Expand Down
47 changes: 45 additions & 2 deletions tests/Unit/Process/CommandLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,51 @@ public function testGetOptionsChunkedNotContainsConfiguration(): void
$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(true));
$options = $cli->getOptions($config->reveal());
$this->assertNotContains('--configuration=/path/to/phpunit.xml', $options);
foreach ($cli->getOptions($config->reveal()) as $option) {
$this->assertStringStartsNotWith('--configuration', $option);
}
}

public function testGetOptionsChunkedNotContainsTestsuite(): void
{
$config = $this->prophesize(PHPUnitConfig::class);
$config->getPhpunitOption('stderr')
->willReturn(null);

$config->getFileFullPath()
->willReturn('/path/to/phpunit.xml');

$incompatibleOption = new PHPUnitOption('testsuite');
$incompatibleOption->setValue('foo');
$config->getPhpunitOptions()
->willReturn([$incompatibleOption]);

$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(true));
foreach ($cli->getOptions($config->reveal()) as $option) {
$this->assertStringStartsNotWith('--testsuite', $option);
}
}

public function testGetOptionsNotChunkedContainsTestsuite(): void
{
$config = $this->prophesize(PHPUnitConfig::class);
$config->getPhpunitOption('stderr')
->willReturn(null);

$config->getFileFullPath()
->willReturn('/path/to/phpunit.xml');

$incompatibleOption = new PHPUnitOption('testsuite');
$incompatibleOption->setValue('foo');
$config->getPhpunitOptions()
->willReturn([$incompatibleOption]);

$phpunit = $this->prophesize(PHPUnitBinFile::class);

$cli = new CommandLine($phpunit->reveal(), $this->mockChunkSize(false));
$this->assertContains('--testsuite=foo', $cli->getOptions($config->reveal()));
}

private function mockChunkSize(bool $enabled): ChunkSize
Expand Down

0 comments on commit 57862bb

Please sign in to comment.