Skip to content

Commit

Permalink
phpunit: support data providers in children (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored Sep 25, 2024
1 parent 4d432b2 commit 41ee3cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/Provider/PhpUnitEntrypointProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public function getEntrypoints(ClassReflection $classReflection): array
$entrypoints = [];

foreach ($classReflection->getNativeReflection()->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() !== $classReflection->getName()) {
continue;
}

$dataProviders = array_merge(
$this->getDataProvidersFromAnnotations($method->getDocComment()),
$this->getDataProvidersFromAttributes($method),
Expand Down
18 changes: 18 additions & 0 deletions tests/Rule/data/DeadMethodRule/providers/phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,21 @@ public function beforeAnnotation(): void
}

}

abstract class TestCaseBase extends TestCase
{
abstract public static function providerTest(): array;

#[DataProvider('providerTest')]
public function testFoo(string|null $phpValue, string|null $serialized): void
{
}
}

final class SomeExtendingTest extends TestCaseBase
{
public static function providerTest(): array
{
return [];
}
}

0 comments on commit 41ee3cd

Please sign in to comment.