Skip to content

Commit 41ee3cd

Browse files
authored
phpunit: support data providers in children (#97)
1 parent 4d432b2 commit 41ee3cd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Provider/PhpUnitEntrypointProvider.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ public function getEntrypoints(ClassReflection $classReflection): array
4343
$entrypoints = [];
4444

4545
foreach ($classReflection->getNativeReflection()->getMethods() as $method) {
46-
if ($method->getDeclaringClass()->getName() !== $classReflection->getName()) {
47-
continue;
48-
}
49-
5046
$dataProviders = array_merge(
5147
$this->getDataProvidersFromAnnotations($method->getDocComment()),
5248
$this->getDataProvidersFromAttributes($method),

tests/Rule/data/DeadMethodRule/providers/phpunit.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,21 @@ public function beforeAnnotation(): void
8080
}
8181

8282
}
83+
84+
abstract class TestCaseBase extends TestCase
85+
{
86+
abstract public static function providerTest(): array;
87+
88+
#[DataProvider('providerTest')]
89+
public function testFoo(string|null $phpValue, string|null $serialized): void
90+
{
91+
}
92+
}
93+
94+
final class SomeExtendingTest extends TestCaseBase
95+
{
96+
public static function providerTest(): array
97+
{
98+
return [];
99+
}
100+
}

0 commit comments

Comments
 (0)