Skip to content

Commit

Permalink
add fixture for only importNames() without removeUnusedIMpotrs() (#5194)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Oct 23, 2023
1 parent 01fb666 commit 3e505e5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

/**
* @see \Rector\PostRector\Rector\NameImportingPostRector
*/
final class AutoImportNamesWithoutRemoveUnusedImportTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImportNamesWithoutRemoveUnusedImport');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/auto_import_names_without_remove_unused_use.php';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\FixtureAutoImportNamesWithoutRemoveUnusedImport;

use Interop\Container\ContainerInterface;

class FactoryInvokeTypehint
{
public function __invoke(ContainerInterface $container)
{
}
}

?>
-----
<?php

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\FixtureAutoImportNamesWithoutRemoveUnusedImport;

use Psr\Container\ContainerInterface;

class FactoryInvokeTypehint
{
public function __invoke(ContainerInterface $container)
{
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->importNames();

$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
'Interop\Container\ContainerInterface' => 'Psr\Container\ContainerInterface',
]);
};

0 comments on commit 3e505e5

Please sign in to comment.