* 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\PhpUnit; use PhpCsFixer\Fixer\PhpUnit\PhpUnitTargetVersion; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; use PhpCsFixer\Tokenizer\Tokens; /** * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Fixer\PhpUnit\PhpUnitNamespacedFixer */ final class PhpUnitNamespacedFixerTest extends AbstractFixerTestCase { /** * @param array $config * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield 'class_mapping' => [ ' [ ' [ ' [ ' PhpUnitTargetVersion::VERSION_4_8], ]; yield [ ' PhpUnitTargetVersion::VERSION_5_7], ]; yield [ ' PhpUnitTargetVersion::VERSION_6_0], ]; yield [ 'fixer->configure(['target' => PhpUnitTargetVersion::VERSION_NEWEST]); Tokens::clearCache(); $tokens = Tokens::fromCode(sprintf('fixer->fix(self::getTestFile(), $tokens); self::assertTrue($tokens->isChanged()); self::assertStringNotContainsString('_', $tokens->generateCode()); } public static function provideClassIsFixedCases(): iterable { $classmap = require __DIR__.'/../../../vendor/composer/autoload_classmap.php'; foreach ($classmap as $class => $file) { if (str_starts_with($class, 'PHPUnit_')) { yield $file => [$class]; } } } /** * @dataProvider provideFix81Cases * * @requires PHP 8.1 */ public function testFix81(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public static function provideFix81Cases(): iterable { yield [ '