Skip to content

Commit 425b12d

Browse files
committed
[BUGFIX] Normalize CodeCoverage objects
phpunit/php-code-coverage >= 9.2 expects an option "fromTestcase" in its test data.
1 parent 8507584 commit 425b12d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/PhpunitMerger/Command/CoverageCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6565
if (!$coverage instanceof CodeCoverage) {
6666
throw new \RuntimeException($file->getRealPath() . ' doesn\'t return a valid ' . CodeCoverage::class . ' object!');
6767
}
68+
$this->normalizeCoverage($coverage);
6869
$codeCoverage->merge($coverage);
6970
}
7071

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

95+
private function normalizeCoverage(CodeCoverage $coverage)
96+
{
97+
$tests = $coverage->getTests();
98+
foreach ($tests as &$test) {
99+
$test['fromTestcase'] = $test['fromTestcase'] ?? false;
100+
}
101+
$coverage->setTests($tests);
102+
}
103+
94104
private function writeCodeCoverage(CodeCoverage $codeCoverage, OutputInterface $output, $file = null)
95105
{
96106
$writer = new Clover();

0 commit comments

Comments
 (0)