* 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\Basic; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Graham Campbell * @author Kuba Werłos * * @internal * * @covers \PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer */ final class PsrAutoloadingFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, ?string $filepath = null, ?string $dir = null): void { if (null === $filepath) { $filepath = __FILE__; } $file = new \SplFileInfo($filepath); if (null !== $dir) { $this->fixer->configure(['dir' => $dir]); } $this->doTest($expected, $input, $file); } /** * @return iterable */ public static function provideFixCases(): iterable { foreach (['class', 'interface', 'trait'] as $element) { yield \sprintf('%s with originally short name', $element) => [ \sprintf(' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' 'callable', 'T_FINALLY' => 'finally', 'T_INSTEADOF' => 'insteadof', 'T_TRAIT' => 'trait', 'T_TRAIT_C' => '__trait__', ] as $tokenType => $tokenValue) { if (\defined($tokenType)) { $cases[] = $tokenValue.'.php'; $cases[] = strtoupper($tokenValue).'.php'; } } yield from array_map(static fn ($case): array => [ ' [ ' [ ' [ ' [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield 'anonymous + annotation' => [ 'doTest($expected, $input, new \SplFileInfo(__FILE__)); } /** * @return iterable */ public static function provideFix81Cases(): iterable { yield 'enum with wrong casing' => [ '