Skip to content

Commit 95394e1

Browse files
committed
YieldDataProviderRector: Added failling test
1 parent 3ea365a commit 95394e1

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\YieldDataProviderRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class UseDataProviderTest extends TestCase
8+
{
9+
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
10+
public function test(string $val1, string $val2): void
11+
{
12+
}
13+
14+
public static function dataProvider(): iterable
15+
{
16+
yield from [
17+
['value3', 'value4'],
18+
['value5', 'value6'],
19+
['value7', 'value8'],
20+
];
21+
22+
if (PHP_VERSION_ID < 80100) {
23+
return;
24+
}
25+
26+
yield ['value1', 'value2'];
27+
}
28+
29+
}
30+
31+
?>
32+
-----
33+
<?php
34+
35+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\YieldDataProviderRector\Fixture;
36+
37+
use PHPUnit\Framework\TestCase;
38+
39+
final class UseDataProviderTest extends TestCase
40+
{
41+
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
42+
public function test(string $val1, string $val2): void
43+
{
44+
}
45+
46+
public static function dataProvider(): \Iterator
47+
{
48+
yield ['value3', 'value4'];
49+
yield ['value5', 'value6'];
50+
yield ['value7', 'value8'];
51+
52+
if (PHP_VERSION_ID < 80100) {
53+
return;
54+
}
55+
56+
yield ['value1', 'value2'];
57+
}
58+
59+
}
60+
61+
?>

0 commit comments

Comments
 (0)