You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: #[CoversNothing] is ignored in Cest tests with PHPUnit 13 / php-code-coverage 12 #6940
Expected: test does not contribute to code coverage. Actual:TypeError crash — or, if getLinesToBeCovered() returns [],
the test silently contributes to coverage as if the attribute were absent.
Root cause (two-part)
Part 1 — Cest::getLinesToBeCovered() does not handle CoversNothing
PHPUnit\Metadata\Api\CodeCoverage::coversTargets() in PHPUnit 13 handles only CoversClass, CoversMethod, CoversTrait, etc.
It does not handle #[CoversNothing] — it simply returns an empty TargetCollection.
The correct PHPUnit 13 API for CoversNothing is shouldCodeCoverageBeCollectedFor():
But Cest::getLinesToBeCovered() never calls it, so CoversNothing is lost.
Part 2 — CodeCoverage trait does not handle false return value for php-code-coverage ≥ 12
Historically getLinesToBeCovered() returned false for @coversNothing.
In Feature/CodeCoverage.php, when php-code-coverage >= 12, the result is passed
directly to TargetCollection::fromArray(), which does not accept false:
Proposed fix
1. src/Codeception/Test/Cest.php — check CoversNothing before delegating to coversTargets():
Both changes are needed: the first makes CoversNothing detectable again,
the second prevents the TypeError crash when the false value reaches fromArray().
Activity