Skip to content

Commit

Permalink
[BUGFIX] Normalize CodeCoverage objects
Browse files Browse the repository at this point in the history
phpunit/php-code-coverage >= 9.2 expects an option "fromTestcase" in its test data.
  • Loading branch information
IchHabRecht committed Oct 7, 2021
1 parent 62cbc53 commit 76e1b50
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/PhpunitMerger/Command/CoverageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$coverage instanceof CodeCoverage) {
throw new \RuntimeException($file->getRealPath() . ' doesn\'t return a valid ' . CodeCoverage::class . ' object!');
}
$this->normalizeCoverage($coverage);
$codeCoverage->merge($coverage);
}

Expand All @@ -91,6 +92,15 @@ private function getCodeCoverage()
return new CodeCoverage($driver, $filter);
}

private function normalizeCoverage(CodeCoverage $coverage)
{
$tests = $coverage->getTests();
foreach ($tests as &$test) {
$test['fromTestcase'] = $test['fromTestcase'] ?? false;
}
$coverage->setTests($tests);
}

private function writeCodeCoverage(CodeCoverage $codeCoverage, OutputInterface $output, $file = null)
{
$writer = new Clover();
Expand Down

0 comments on commit 76e1b50

Please sign in to comment.