Skip to content

Commit

Permalink
[PhpUnitBridge] Adjust output parsing for PHPUnit 9.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Sep 5, 2020
1 parent 105a685 commit e6e6da2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Tests/CoverageListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ public function test()
$dir = __DIR__.'/../Tests/Fixtures/coverage';
$phpunit = $_SERVER['argv'][0];

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

exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text 2> /dev/null", $output);
exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text --colors=never 2> /dev/null", $output);
$output = implode("\n", $output);
$this->assertStringNotContainsString('FooCov', $output);

if (false === strpos($output, 'FooCov')) {
$this->addToAssertionCount(1);
} else {
$this->assertMatchesRegularExpression('/FooCov\n\s*Methods:\s+0.00%[^\n]+Lines:\s+0.00%/', $output);
}

$this->assertStringContainsString("SutNotFoundTest::test\nCould not find the tested class.", $output);
$this->assertStringNotContainsString("CoversTest::test\nCould not find the tested class.", $output);
$this->assertStringNotContainsString("CoversDefaultClassTest::test\nCould not find the tested class.", $output);
Expand Down

0 comments on commit e6e6da2

Please sign in to comment.