* 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\ArrayNotation; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Sebastiaan Stok * @author Gregor Harlan * * @internal * * @covers \PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer */ final class ArraySyntaxFixerTest extends AbstractFixerTestCase { public function testInvalidConfiguration(): void { $this->expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches('#^\[array_syntax\] Invalid configuration: The option "a" does not exist\. Defined options are: "syntax"\.$#'); $this->fixer->configure(['a' => 1]); } /** * @param _AutogeneratedInputConfiguration $configuration * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->fixer->configure($configuration); $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield 'default configuration' => [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' true) : array("f" => false)));', ' true] : ["f" => false])];', ['syntax' => 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' 'long'], ]; yield [ ' [$x, $y]) {}', null, ['syntax' => 'long'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' true] : ["f" => false])];', ' true) : array("f" => false)));', ['syntax' => 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; yield [ ' 'short'], ]; } }