* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Fixer\Import; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @internal * * @covers \PhpCsFixer\Fixer\Import\NoUnusedImportsFixer */ final class NoUnusedImportsFixerTest extends AbstractFixerTestCase { /** * @param string $expected * @param null|string $input * * @dataProvider provideFixCases */ public function testFix($expected, $input = null) { $this->doTest($expected, $input); } public function provideFixCases() { return [ 'simple' => [ <<<'EOF' toArray(); /** @var ArrayInterface $bar */ } } EOF , <<<'EOF' toArray(); /** @var ArrayInterface $bar */ } } EOF , ], 'with_indents' => [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' repo = $repo; } } EOF , <<<'EOF' repo = $repo; } } EOF , ], 'variable_name' => [ <<<'EOF' [ <<<'EOF' bar = null; $foo->bar(); $foo::bar(); $foo::bar; EOF , <<<'EOF' bar = null; $foo->bar(); $foo::bar(); $foo::bar; EOF , ], 'constant_name' => [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ 'inline content', 'inline content', ], 'close_tag_2' => [ '', '', ], 'close_tag_3' => [ '', '', ], 'with_comments' => [ ' [ ' [ ' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ ' [ ' [ ' [' [' ['ABC::Test; ', ], 'imported_class_name_is_prefix_with_dash_of_constant' => [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ $expected = <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' [ <<<'EOF' doTest($expected); } /** * @param string $expected * @param null|string $input * * @dataProvider provideFix72Cases * @requires PHP 7.2 */ public function testFix72($expected, $input = null) { $this->doTest($expected, $input); } public function provideFix72Cases() { return [ [ // TODO test shows lot of cases where imports are not removed while could be '