* 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\ClassNotation; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; use PhpCsFixer\WhitespacesFixerConfig; /** * @author Javier Spagnoletti * * @internal * * @covers \PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer */ final class SingleClassElementPerStatementFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield [ ' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' $configuration * * @dataProvider provideFixWithConfigurationCases */ public function testFixWithConfiguration(array $configuration, string $expected): void { static $input = <<<'EOT' fixer->configure(['elements' => $configuration]); $this->doTest($expected, $input); } public static function provideFixWithConfigurationCases(): iterable { yield [ ['const', 'property'], <<<'EOT' expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches('/^\[single_class_element_per_statement\] Invalid configuration: The option "elements" .*\.$/'); $this->fixer->configure(['elements' => ['foo']]); } /** * @dataProvider provideMessyWhitespacesCases */ public function testMessyWhitespaces(string $expected, ?string $input = null): void { $this->fixer->setWhitespacesConfig(new WhitespacesFixerConfig("\t", "\r\n")); $this->doTest($expected, $input); } public static function provideMessyWhitespacesCases(): iterable { yield [ "doTest( 'doTest($expected, $input); } public static function provideFix80Cases(): iterable { yield [ 'doTest($expected, $input); } public static function provideFix81Cases(): iterable { yield [ 'doTest($expected, $input); } public static function provideFix82Cases(): iterable { yield [ '