* 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 * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer */ final class SingleClassElementPerStatementFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $configuration * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->fixer->configure($configuration); $this->doTest($expected, $input); } public static function provideFixCases(): iterable { yield [ ' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' [ <<<'EOT' ['const', 'property']], ]; yield [ <<<'EOT' ['const']], ]; yield [ <<<'EOT' ['property']], ]; yield 'anonymous class' => [ 'fixer->setWhitespacesConfig(new WhitespacesFixerConfig("\t", "\r\n")); $this->doTest( "doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix81Cases(): iterable { yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix82Cases(): iterable { yield [ 'expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches('/^\[single_class_element_per_statement\] Invalid configuration: The option "elements" .*\.$/'); $this->fixer->configure(['elements' => ['foo']]); // @phpstan-ignore-line } }