|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Rector\Tests\Configuration; |
| 6 | + |
| 7 | +use PHPUnit\Framework\Attributes\RunClassInSeparateProcess; |
| 8 | +use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; |
| 9 | +use Rector\Testing\PHPUnit\AbstractLazyTestCase; |
| 10 | +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector; |
| 11 | + |
| 12 | +#[RunClassInSeparateProcess] |
| 13 | +final class RectorConfigBuilderTest extends AbstractLazyTestCase |
| 14 | +{ |
| 15 | + public function testWithImport(): void |
| 16 | + { |
| 17 | + $rectorConfig = self::getContainer(); |
| 18 | + |
| 19 | + $rectorConfig->configure() |
| 20 | + ->withImport(__DIR__ . '/config/imported_config.php')($rectorConfig); |
| 21 | + |
| 22 | + $this->assertTrue($rectorConfig->has(ReturnTypeFromReturnNewRector::class)); |
| 23 | + } |
| 24 | + |
| 25 | + public function testWithMultipleImports(): void |
| 26 | + { |
| 27 | + $rectorConfig = self::getContainer(); |
| 28 | + |
| 29 | + $rectorConfig->configure() |
| 30 | + ->withImport( |
| 31 | + __DIR__ . '/config/imported_config.php', |
| 32 | + __DIR__ . '/config/second_imported_config.php' |
| 33 | + )($rectorConfig); |
| 34 | + |
| 35 | + $this->assertTrue($rectorConfig->has(ReturnTypeFromReturnNewRector::class)); |
| 36 | + $this->assertTrue($rectorConfig->has(RemoveUnusedPrivateMethodRector::class)); |
| 37 | + } |
| 38 | + |
| 39 | + public function testWithNestedImport(): void |
| 40 | + { |
| 41 | + $rectorConfig = self::getContainer(); |
| 42 | + |
| 43 | + $rectorConfig->configure() |
| 44 | + ->withImport(__DIR__ . '/config/nested_import_config.php')($rectorConfig); |
| 45 | + |
| 46 | + $this->assertTrue($rectorConfig->has(ReturnTypeFromReturnNewRector::class)); |
| 47 | + } |
| 48 | +} |
0 commit comments