File tree Expand file tree Collapse file tree
rules-tests/TypeDeclarationDocblocks/Rector/Class_/AddReturnDocblockDataProviderRector/Fixture
rules/TypeDeclarationDocblocks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \AddReturnDocblockDataProviderRector \Fixture ;
4+
5+ use Codeception \Attribute \DataProvider ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ final class CodeceptionDataProviderAttribute extends TestCase
9+ {
10+ #[DataProvider('provideData ' )]
11+ public function testSomething ()
12+ {
13+ }
14+
15+ public static function provideData ()
16+ {
17+ return [
18+ ['data1 ' ],
19+ ['data2 ' ],
20+ ];
21+ }
22+ }
23+
24+ ?>
25+ -----
26+ <?php
27+
28+ namespace Rector \Tests \TypeDeclarationDocblocks \Rector \Class_ \AddReturnDocblockDataProviderRector \Fixture ;
29+
30+ use Codeception \Attribute \DataProvider ;
31+ use PHPUnit \Framework \TestCase ;
32+
33+ final class CodeceptionDataProviderAttribute extends TestCase
34+ {
35+ #[DataProvider('provideData ' )]
36+ public function testSomething ()
37+ {
38+ }
39+
40+ /**
41+ * @return string[][]
42+ */
43+ public static function provideData ()
44+ {
45+ return [
46+ ['data1 ' ],
47+ ['data2 ' ],
48+ ];
49+ }
50+ }
51+
52+ ?>
Original file line number Diff line number Diff line change 66
77final class TestClassName
88{
9- public const string DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider ' ;
9+ public const string PHPUNIT_DATA_PROVIDER = 'PHPUnit\Framework\Attributes\DataProvider ' ;
10+
11+ public const string CODECEPTION_DATA_PROVIDER = 'Codeception\Attribute\DataProvider ' ;
1012}
Original file line number Diff line number Diff line change 1515
1616final readonly class DataProviderMethodsFinder
1717{
18+ private const array DATA_PROVIDER_ATTRIBUTES = [
19+ TestClassName::PHPUNIT_DATA_PROVIDER ,
20+ TestClassName::CODECEPTION_DATA_PROVIDER ,
21+ ];
22+
1823 public function __construct (
1924 private PhpDocInfoFactory $ phpDocInfoFactory ,
2025 private NodeNameResolver $ nodeNameResolver
@@ -62,7 +67,7 @@ private function findDataProviderAttributes(ClassMethod $classMethod): array
6267
6368 foreach ($ classMethod ->attrGroups as $ attrGroup ) {
6469 foreach ($ attrGroup ->attrs as $ attribute ) {
65- if (! $ this ->nodeNameResolver ->isName ($ attribute ->name , TestClassName:: DATA_PROVIDER )) {
70+ if (! $ this ->nodeNameResolver ->isNames ($ attribute ->name , self :: DATA_PROVIDER_ATTRIBUTES )) {
6671 continue ;
6772 }
6873
You can’t perform that action at this time.
0 commit comments