Skip to content

Commit ba61d89

Browse files
bug #38094 [PhpUnitBridge] Skip internal classes in CoverageListenerTrait (sanmai)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] Skip internal classes in CoverageListenerTrait PHPUnit 9+ is picky about test covering, say, a `\RuntimeException`. Fails with the likes: "@Covers RuntimeException" is invalid Judging by the commit sebastianbergmann/phpunit@e06850c this change is required for PHPUnit 9.1 and up. [Here's it being tested.](https://github.com/sebastianbergmann/code-unit/blob/60c6fb972b3262e423be3000e7b8c67cbc477580/tests/unit/ClassMethodUnitTest.php#L49-L54) | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Follow-up to #38054 | License | MIT Commits ------- a0dedb9 [PhpUnitBridge] Skip internal classes in CoverageListenerTrait
2 parents f8fddf3 + a0dedb9 commit ba61d89

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

+7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ private function addCoversForDocBlockInsideRegistry($test, $covers)
107107
$symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations');
108108
$symbolAnnotations->setAccessible(true);
109109

110+
// Exclude internal classes; PHPUnit 9.1+ is picky about tests covering, say, a \RuntimeException
111+
$covers = array_filter($covers, function ($class) {
112+
$reflector = new ReflectionClass($class);
113+
114+
return $reflector->isUserDefined();
115+
});
116+
110117
$symbolAnnotations->setValue($docBlock, array_replace($docBlock->symbolAnnotations(), [
111118
'covers' => $covers,
112119
]));

0 commit comments

Comments
 (0)