Skip to content

Commit 31f3b62

Browse files
committed
test(exceptions): remove #[CoversClass] from exception test to fix PHPUnit 12 CI warning
In PHPUnit 12 + pcov, classes that directly extend a native PHP class (\RuntimeException) are reported as 'not a valid target for code coverage'. This generates 4 PHPUnit warnings — one per test method — which with the devkit-generated failOnWarning="true" in phpunit.xml.dist cause exit code 1, blocking the CI pipeline despite 100% coverage and 175 passing tests. Fix: remove #[CoversClass(InvalidRuleException::class)] and #[CoversClass(SanitizationException::class)] from SanitizationExceptionsTest. Coverage for both exception classes is still achieved transitively via SanitizerEngineTest, InMemoryRuleRegistryTest, and integration tests.
1 parent cd24e72 commit 31f3b62

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/Unit/Exception/SanitizationExceptionsTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
use KaririCode\Sanitizer\Exception\InvalidRuleException;
88
use KaririCode\Sanitizer\Exception\SanitizationException;
9-
use PHPUnit\Framework\Attributes\CoversClass;
109
use PHPUnit\Framework\Attributes\Test;
1110
use PHPUnit\Framework\TestCase;
1211

13-
#[CoversClass(InvalidRuleException::class)]
14-
#[CoversClass(SanitizationException::class)]
12+
// NOTE: #[CoversClass] is intentionally omitted for exception classes.
13+
// In PHPUnit 12 + pcov, classes that directly extend \RuntimeException
14+
// (a native PHP class) are reported as "not a valid target for code coverage",
15+
// which triggers PHPUnit warnings that — with failOnWarning="true" — exit as code 1.
16+
// Coverage for these classes is achieved transitively via SanitizerEngineTest and others.
1517
final class SanitizationExceptionsTest extends TestCase
1618
{
1719
#[Test]

0 commit comments

Comments
 (0)