Skip to content

Commit e6e6da2

Browse files
committed
[PhpUnitBridge] Adjust output parsing for PHPUnit 9.3.
1 parent 105a685 commit e6e6da2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Tests/CoverageListenerTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ public function test()
3131
$dir = __DIR__.'/../Tests/Fixtures/coverage';
3232
$phpunit = $_SERVER['argv'][0];
3333

34-
exec("$php $phpunit -c $dir/phpunit-without-listener.xml.dist $dir/tests/ --coverage-text 2> /dev/null", $output);
34+
exec("$php $phpunit -c $dir/phpunit-without-listener.xml.dist $dir/tests/ --coverage-text --colors=never 2> /dev/null", $output);
3535
$output = implode("\n", $output);
36-
$this->assertStringContainsString('FooCov', $output);
36+
$this->assertMatchesRegularExpression('/FooCov\n\s*Methods:\s+100.00%[^\n]+Lines:\s+100.00%/', $output);
3737

38-
exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text 2> /dev/null", $output);
38+
exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text --colors=never 2> /dev/null", $output);
3939
$output = implode("\n", $output);
40-
$this->assertStringNotContainsString('FooCov', $output);
40+
41+
if (false === strpos($output, 'FooCov')) {
42+
$this->addToAssertionCount(1);
43+
} else {
44+
$this->assertMatchesRegularExpression('/FooCov\n\s*Methods:\s+0.00%[^\n]+Lines:\s+0.00%/', $output);
45+
}
46+
4147
$this->assertStringContainsString("SutNotFoundTest::test\nCould not find the tested class.", $output);
4248
$this->assertStringNotContainsString("CoversTest::test\nCould not find the tested class.", $output);
4349
$this->assertStringNotContainsString("CoversDefaultClassTest::test\nCould not find the tested class.", $output);

0 commit comments

Comments
 (0)