From d3520efe6390852a8b3b02df615384c42b622a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 7 Jul 2022 13:43:43 +0200 Subject: [PATCH] Fix coverage when no assertion is expected (#355) --- src/Phpunit/TestCase.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Phpunit/TestCase.php b/src/Phpunit/TestCase.php index 88aee7fa..a16a4333 100644 --- a/src/Phpunit/TestCase.php +++ b/src/Phpunit/TestCase.php @@ -63,6 +63,12 @@ protected function tearDown(): void gc_collect_cycles(); } gc_collect_cycles(); + + // fix coverage when no assertion is expected + // https://github.com/sebastianbergmann/phpunit/pull/5010 + if ($this->getNumAssertions() === 0 && $this->doesNotPerformAssertions()) { + $this->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false); + } } /**