diff --git a/src/Rector/Contrib/Nette/Helper/ServiceFromEnvironmentResolver.php b/src/Rector/Contrib/Nette/Helper/ServiceFromEnvironmentResolver.php deleted file mode 100644 index c09297f2e24..00000000000 --- a/src/Rector/Contrib/Nette/Helper/ServiceFromEnvironmentResolver.php +++ /dev/null @@ -1,12 +0,0 @@ -createWithConfig( - __DIR__ . '/config/rector.yml' + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong.php.inc', + __DIR__ . '/correct/correct.php.inc' ); - $this->fileProcessor = $container->get(FileProcessor::class); - $this->classReplacerRector = $container->get(ClassReplacerRector::class); - } - - public function testConfiguration(): void - { - $oldToNewClasses = Assert::getObjectAttribute($this->classReplacerRector, 'oldToNewClasses'); - $this->assertNotSame([], $oldToNewClasses); - } - - /** - * @dataProvider provideTestFiles() - */ - public function testProcessing(string $testedFile, string $expectedFile): void - { - $refactoredFileContent = $this->fileProcessor->processFileWithRectorsToString( - new SplFileInfo($testedFile), - [ClassReplacerRector::class] + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong2.php.inc', + __DIR__ . '/correct/correct2.php.inc' ); + } - $this->assertStringEqualsFile($expectedFile, $refactoredFileContent); + protected function provideConfig(): string + { + return __DIR__ . '/config/rector.yml'; } /** - * @return string[][] + * @return string[] */ - public function provideTestFiles(): array + protected function getRectorClasses(): array { - return [ - [__DIR__ . '/wrong/wrong.php.inc', __DIR__ . '/correct/correct.php.inc'], - [__DIR__ . '/wrong/wrong2.php.inc', __DIR__ . '/correct/correct2.php.inc'], - ]; + return [ClassReplacerRector::class]; } } diff --git a/tests/Rector/Dynamic/MethodArgumentChangerRector/Test.php b/tests/Rector/Dynamic/MethodArgumentChangerRector/Test.php index 567be521a5d..527e8c01e4c 100644 --- a/tests/Rector/Dynamic/MethodArgumentChangerRector/Test.php +++ b/tests/Rector/Dynamic/MethodArgumentChangerRector/Test.php @@ -2,49 +2,34 @@ namespace Rector\Tests\Rector\Dynamic\MethodArgumentChangerRector; -use PHPUnit\Framework\TestCase; -use Rector\Application\FileProcessor; -use Rector\DependencyInjection\ContainerFactory; use Rector\Rector\Dynamic\MethodArgumentChangerRector; -use SplFileInfo; +use Rector\Testing\PHPUnit\AbstractConfigurableRectorTestCase; -final class Test extends TestCase +final class Test extends AbstractConfigurableRectorTestCase { - /** - * @var FileProcessor - */ - private $fileProcessor; - - protected function setUp(): void + protected function provideConfig(): string { - $container = (new ContainerFactory)->createWithConfig( - __DIR__ . '/config/rector.yml' + return __DIR__ . '/config/rector.yml'; + } + + public function test(): void + { + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong.php.inc', + __DIR__ . '/correct/correct.php.inc' ); - $this->fileProcessor = $container->get(FileProcessor::class); + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong2.php.inc', + __DIR__ . '/correct/correct2.php.inc' + ); } /** - * @dataProvider provideTestFiles() + * @return string[] */ - public function testProcessing(string $testedFile, string $expectedFile): void + protected function getRectorClasses(): array { - $refactoredFileContent = $this->fileProcessor->processFileWithRectorsToString( - new SplFileInfo($testedFile), - [MethodArgumentChangerRector::class] - ); - - $this->assertStringEqualsFile($expectedFile, $refactoredFileContent); - } - - /** - * @return string[][] - */ - public function provideTestFiles(): array - { - return [ - [__DIR__ . '/wrong/wrong.php.inc', __DIR__ . '/correct/correct.php.inc'], - [__DIR__ . '/wrong/wrong2.php.inc', __DIR__ . '/correct/correct2.php.inc'], - ]; + return [MethodArgumentChangerRector::class]; } } diff --git a/tests/Rector/Dynamic/NamespaceReplacerRector/Test.php b/tests/Rector/Dynamic/NamespaceReplacerRector/Test.php index 89fbac7adbb..d49fcaa83b3 100644 --- a/tests/Rector/Dynamic/NamespaceReplacerRector/Test.php +++ b/tests/Rector/Dynamic/NamespaceReplacerRector/Test.php @@ -2,51 +2,44 @@ namespace Rector\Tests\Rector\Dynamic\NamespaceReplacerRector; -use PHPUnit\Framework\TestCase; -use Rector\Application\FileProcessor; -use Rector\DependencyInjection\ContainerFactory; use Rector\Rector\Dynamic\NamespaceReplacerRector; -use SplFileInfo; +use Rector\Testing\PHPUnit\AbstractConfigurableRectorTestCase; -final class Test extends TestCase +final class Test extends AbstractConfigurableRectorTestCase { - /** - * @var FileProcessor - */ - private $fileProcessor; - - protected function setUp(): void + public function test(): void { - $container = (new ContainerFactory)->createWithConfig( - __DIR__ . '/config/rector.yml' + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong.php.inc', + __DIR__ . '/correct/correct.php.inc' ); - $this->fileProcessor = $container->get(FileProcessor::class); + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong2.php.inc', + __DIR__ . '/correct/correct2.php.inc' + ); + + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong3.php.inc', + __DIR__ . '/correct/correct3.php.inc' + ); + + $this->doTestFileMatchesExpectedContent( + __DIR__ . '/wrong/wrong4.php.inc', + __DIR__ . '/correct/correct4.php.inc' + ); + } + + protected function provideConfig(): string + { + return __DIR__ . '/config/rector.yml'; } /** - * @dataProvider provideTestFiles() + * @return string[] */ - public function test(string $testedFile, string $expectedFile): void + protected function getRectorClasses(): array { - $refactoredFileContent = $this->fileProcessor->processFileWithRectorsToString( - new SplFileInfo($testedFile), - [NamespaceReplacerRector::class] - ); - - $this->assertStringEqualsFile($expectedFile, $refactoredFileContent); - } - - /** - * @return string[][] - */ - public function provideTestFiles(): array - { - return [ - [__DIR__ . '/wrong/wrong.php.inc', __DIR__ . '/correct/correct.php.inc'], - [__DIR__ . '/wrong/wrong2.php.inc', __DIR__ . '/correct/correct2.php.inc'], - [__DIR__ . '/wrong/wrong3.php.inc', __DIR__ . '/correct/correct3.php.inc'], - [__DIR__ . '/wrong/wrong4.php.inc', __DIR__ . '/correct/correct4.php.inc'], - ]; + return [NamespaceReplacerRector::class]; } }