|
8 | 8 | use PHPUnit\Framework\Attributes\DataProvider; |
9 | 9 | use Rector\Configuration\Option; |
10 | 10 | use Rector\Configuration\Parameter\SimpleParameterProvider; |
| 11 | +use Rector\Contract\Rector\RectorInterface; |
11 | 12 | use Rector\Skipper\Skipper\Skipper; |
12 | 13 | use Rector\Testing\PHPUnit\AbstractLazyTestCase; |
13 | 14 | use Rector\Tests\Skipper\Skipper\Fixture\Element\FifthElement; |
14 | | -use Rector\Tests\Skipper\Skipper\Fixture\Element\ThreeMan; |
15 | 15 | use Rector\Tests\Skipper\Skipper\Source\AnotherClassToSkip; |
16 | | -use Rector\Tests\Skipper\Skipper\Source\NotSkippedClass; |
17 | 16 |
|
18 | 17 | final class SkipperTest extends AbstractLazyTestCase |
19 | 18 | { |
@@ -69,44 +68,18 @@ public static function provideDataShouldSkipFilePath(): Iterator |
69 | 68 | yield [__DIR__ . '/Fixture/PathSkippedWithMask/another_file.txt', true]; |
70 | 69 | } |
71 | 70 |
|
72 | | - /** |
73 | | - * @param object|class-string $element |
74 | | - */ |
75 | | - #[DataProvider('provideDataShouldSkipElement')] |
76 | | - public function testSkipElement(string|object $element, bool $expectedSkip): void |
| 71 | + #[DataProvider('provideRectorAndFile')] |
| 72 | + public function testSkipElementAndFilePath(RectorInterface $rector, string $filePath, bool $expectedSkip): void |
77 | 73 | { |
78 | | - $resultSkip = $this->skipper->shouldSkipElement($element); |
79 | | - $this->assertSame($expectedSkip, $resultSkip); |
80 | | - } |
81 | | - |
82 | | - #[DataProvider('provideCheckerAndFile')] |
83 | | - public function testSkipElementAndFilePath(string $element, string $filePath, bool $expectedSkip): void |
84 | | - { |
85 | | - $resolvedSkip = $this->skipper->shouldSkipRectorAndFile($element, $filePath); |
| 74 | + $resolvedSkip = $this->skipper->shouldSkipRectorAndFile($rector, $filePath); |
86 | 75 | $this->assertSame($expectedSkip, $resolvedSkip); |
87 | 76 | } |
88 | 77 |
|
89 | | - /** |
90 | | - * @return Iterator<array<array<int, mixed>, mixed>> |
91 | | - */ |
92 | | - public static function provideCheckerAndFile(): Iterator |
| 78 | + public static function provideRectorAndFile(): Iterator |
93 | 79 | { |
94 | | - yield [FifthElement::class, __DIR__ . '/Fixture', true]; |
| 80 | + yield [new FifthElement(), __DIR__ . '/Fixture', true]; |
95 | 81 |
|
96 | | - yield [AnotherClassToSkip::class, __DIR__ . '/Fixture/someFile', true]; |
97 | | - yield [AnotherClassToSkip::class, __DIR__ . '/Fixture/someDirectory/anotherFile.php', true]; |
98 | | - |
99 | | - yield [NotSkippedClass::class, __DIR__ . '/Fixture/someFile', false]; |
100 | | - yield [NotSkippedClass::class, __DIR__ . '/Fixture/someOtherFile', false]; |
101 | | - } |
102 | | - |
103 | | - /** |
104 | | - * @return Iterator<array<array<int, mixed>, mixed>> |
105 | | - */ |
106 | | - public static function provideDataShouldSkipElement(): Iterator |
107 | | - { |
108 | | - yield [ThreeMan::class, false]; |
109 | | - yield [FifthElement::class, true]; |
110 | | - yield [new FifthElement(), true]; |
| 82 | + yield [new AnotherClassToSkip(), __DIR__ . '/Fixture/someFile', true]; |
| 83 | + yield [new AnotherClassToSkip(), __DIR__ . '/Fixture/someDirectory/anotherFile.php', true]; |
111 | 84 | } |
112 | 85 | } |
0 commit comments