rectorphp / rector-phpunit

Rector upgrade rules for PHPUnit
https://getrector.com/find-rule?activeRectorSetGroup=phpunit
MIT License
68 stars 47 forks source link

Data providers may come from extended classes #142

Closed marmichalski closed 1 year ago

marmichalski commented 1 year ago

Imagine a Test class, let's call it A, extending some other (potentially) abstract Test class, B, that has defined example dataProvider methods and class A is using data providers from class B.
This makes DataProviderClassMethodFinder throw exception as the docblock referenced method is not contained in the same class.

The simplest solution would be to change exception throwing into a continue step, disadvantage is that the extended class method won't be recognized as a data provider - but this is already happening for the base class that provides the data provider methods only 🙈.

Very basic code sample ```php abstract class SomeAbstractTest extends TestCase { public function provideData() { yield [1]; } } final class SomeTest extends SomeAbstractTest { /** * @dataProvider provideData() */ public function test() { } } ```
TomasVotruba commented 1 year ago

Resolved in https://github.com/rectorphp/rector-phpunit/pull/143

Thank you :+1: