* 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\Whitespace; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; use PhpCsFixer\WhitespacesFixerConfig; /** * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Whitespace\IndentationTypeFixer> */ final class IndentationTypeFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield [ '\r\n\t\$a = ellow;", ]; } /** * @dataProvider provideMessyWhitespacesCases */ public function testMessyWhitespaces(string $expected, ?string $input = null): void { $this->fixer->setWhitespacesConfig(new WhitespacesFixerConfig("\t", "\r\n")); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideMessyWhitespacesCases(): iterable { yield [ " [ "fixer->setWhitespacesConfig(new WhitespacesFixerConfig(' ', "\r\n")); $this->doTest($input, $expected); } /** * @return iterable */ public static function provideMessyWhitespacesReversedCases(): iterable { foreach (self::provideMessyWhitespacesCases() as $name => $case) { if ('mix indentation' === $name) { continue; } yield $name => $case; } } /** * @dataProvider provideDoubleSpaceIndentCases */ public function testDoubleSpaceIndent(string $expected, ?string $input = null): void { $this->fixer->setWhitespacesConfig(new WhitespacesFixerConfig(' ')); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideDoubleSpaceIndentCases(): iterable { yield ['foo( "text", "text2" ); } }']; yield [ "foo( 'text', 'text2' ); } }", "foo( \t 'text', \t 'text2' \t); } }", ]; yield [ '