|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Rector\PHPUnit\Tests\Issues\AnnotationParsing\Fixture; |
| 4 | + |
| 5 | +use PHPUnit\Framework\TestCase; |
| 6 | + |
| 7 | +final class SomeTest extends TestCase |
| 8 | +{ |
| 9 | + #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')] |
| 10 | + public function test(?bool $param1, string $param2, bool $param3) |
| 11 | + { |
| 12 | + $this->assertTrue($param1); |
| 13 | + $this->assertSame('string', $param2); |
| 14 | + $this->assertTrue($param3); |
| 15 | + } |
| 16 | + |
| 17 | + /** |
| 18 | + * @return array<array{0: bool|null, 1: string, 2: bool}> |
| 19 | + */ |
| 20 | + public static function dataProvider(): array |
| 21 | + { |
| 22 | + return [ |
| 23 | + 'data1' => [null, 'string', false], |
| 24 | + 'data2' => [false, 'string', false], |
| 25 | + ]; |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +?> |
| 30 | +----- |
| 31 | +<?php |
| 32 | + |
| 33 | +namespace Rector\PHPUnit\Tests\Issues\AnnotationParsing\Fixture; |
| 34 | + |
| 35 | +use PHPUnit\Framework\TestCase; |
| 36 | + |
| 37 | +final class SomeTest extends TestCase |
| 38 | +{ |
| 39 | + #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')] |
| 40 | + public function test(?bool $param1, string $param2, bool $param3) |
| 41 | + { |
| 42 | + $this->assertTrue($param1); |
| 43 | + $this->assertSame('string', $param2); |
| 44 | + $this->assertTrue($param3); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @return \Iterator<(int | string), array{(bool | null), string, bool}> |
| 49 | + */ |
| 50 | + public static function dataProvider(): \Iterator |
| 51 | + { |
| 52 | + yield 'data1' => [null, 'string', false]; |
| 53 | + yield 'data2' => [false, 'string', false]; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +?> |
0 commit comments