* 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\Phpdoc; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Filippo Tessarotto * @author Andreas Möller * * @internal * * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocOrderByValueFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Phpdoc\PhpdocOrderByValueFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\Phpdoc\PhpdocOrderByValueFixer */ final class PhpdocOrderByValueFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideConfigureRejectsInvalidControlStatementCases * * @param mixed $annotation */ public function testConfigureRejectsInvalidControlStatement($annotation): void { $this->expectException(InvalidFixerConfigurationException::class); $this->fixer->configure([ 'annotations' => [ $annotation, ], ]); } public static function provideConfigureRejectsInvalidControlStatementCases(): iterable { yield 'null' => [null]; yield 'false' => [false]; yield 'true' => [true]; yield 'int' => [0]; yield 'float' => [3.14]; yield 'array' => [[]]; yield 'object' => [new \stdClass()]; yield 'unknown' => ['foo']; } /** * @dataProvider provideFixWithCoversCases */ public function testFixWithDefaultConfiguration(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @dataProvider provideFixWithAuthorCases */ public function testFixWithAuthor(string $expected, ?string $input = null): void { $this->fixer->configure([ 'annotations' => [ 'author', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithAuthorCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'covers', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithCoversCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'coversNothing', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithCoversNothingCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'dataProvider', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithDataProviderCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'depends', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithDependsCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'group', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithGroupCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'internal', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithInternalCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'method', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithMethodCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'mixin', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithMixinCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'property', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithPropertyCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'property-read', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithPropertyReadCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'property-write', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithPropertyWriteCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'requires', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithRequiresCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'throws', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithThrowsCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'uses', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithUsesCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ 'fixer->configure([ 'annotations' => [ 'covers', 'uses', ], ]); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixWithMultipleConfiguredAnnotationsCases(): iterable { yield 'skip on 1 or 0 occurrences' => [ ' [ ' [ ' [ ' [ '