From 888b9c9e4cbf4d4c565b5fd2621d32e268fb2615 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 1 Apr 2022 13:55:31 +0200 Subject: [PATCH] Closes #4947 --- ChangeLog-9.5.md | 1 + src/Util/Test.php | 6 ++++-- tests/unit/Util/TestClassTest.php | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog-9.5.md b/ChangeLog-9.5.md index f80d8de4609..250621750f5 100644 --- a/ChangeLog-9.5.md +++ b/ChangeLog-9.5.md @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 9.5 release series are documented in this fil ### Fixed * [#4938](https://github.com/sebastianbergmann/phpunit/issues/4938): Test Double code generator does not handle `void` return type declaration on `__clone()` methods +* [#4947](https://github.com/sebastianbergmann/phpunit/issues/4947): Test annotated with `@coversNothing` may lead to files missing from code coverage report ## [9.5.19] - 2022-03-15 diff --git a/src/Util/Test.php b/src/Util/Test.php index 0778f2f52d1..1de7e9d439f 100644 --- a/src/Util/Test.php +++ b/src/Util/Test.php @@ -150,7 +150,8 @@ public static function requiresCodeCoverageDataCollection(TestCase $test): bool // If there is no @covers annotation but a @coversNothing annotation on // the test method then code coverage data does not need to be collected if (isset($annotations['method']['coversNothing'])) { - return false; + // @see https://github.com/sebastianbergmann/phpunit/issues/4947#issuecomment-1084480950 + // return false; } // If there is at least one @covers annotation then @@ -162,7 +163,8 @@ public static function requiresCodeCoverageDataCollection(TestCase $test): bool // If there is no @covers annotation but a @coversNothing annotation // then code coverage data does not need to be collected if (isset($annotations['class']['coversNothing'])) { - return false; + // @see https://github.com/sebastianbergmann/phpunit/issues/4947#issuecomment-1084480950 + // return false; } // If there is no @coversNothing annotation then diff --git a/tests/unit/Util/TestClassTest.php b/tests/unit/Util/TestClassTest.php index 4d0d140a2ee..cc08397cc47 100644 --- a/tests/unit/Util/TestClassTest.php +++ b/tests/unit/Util/TestClassTest.php @@ -1548,8 +1548,9 @@ public function canSkipCoverageProvider(): array [CoverageClassTest::class, false], [CoverageClassWithoutAnnotationsTest::class, false], [CoverageCoversOverridesCoversNothingTest::class, false], - [CoverageClassNothingTest::class, true], - [CoverageMethodNothingTest::class, true], + // @see https://github.com/sebastianbergmann/phpunit/issues/4947#issuecomment-1084480950 + // [CoverageClassNothingTest::class, true], + // [CoverageMethodNothingTest::class, true], ]; }