Skip to content

Commit 4ce7f40

Browse files
committed
Add support for trait testing
1 parent 9121d2e commit 4ce7f40

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tests/AutoReview/PhpFilesProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private static function getSourceClasses(): array
7878
$file->getBasename('.php'),
7979
);
8080

81-
if (! class_exists($sourceClass)) {
81+
if (! class_exists($sourceClass) && ! trait_exists($sourceClass)) {
8282
continue;
8383
}
8484

tests/AutoReview/TestCodeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use PHPUnit\Framework\Attributes\CoversClass;
2525
use PHPUnit\Framework\Attributes\CoversFunction;
2626
use PHPUnit\Framework\Attributes\CoversNothing;
27+
use PHPUnit\Framework\Attributes\CoversTrait;
2728
use PHPUnit\Framework\Attributes\DataProvider;
2829
use PHPUnit\Framework\Attributes\Group;
2930
use PHPUnit\Framework\TestCase;
@@ -271,9 +272,10 @@ public function testEachTestClassHasCorrectCovers(string $class): void
271272
}
272273

273274
$functions = $rc->getAttributes(CoversFunction::class);
275+
$traits = $rc->getAttributes(CoversTrait::class);
274276
$classes = $rc->getAttributes(CoversClass::class);
275277

276-
if ([] !== $functions && [] === $classes) {
278+
if (([] !== $functions || [] !== $traits) && [] === $classes) {
277279
$this->expectNotToPerformAssertions();
278280

279281
return;

0 commit comments

Comments
 (0)