* 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 */ 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]); } public function testFixWithDefaultConfiguration(): void { $this->fixer->configure([]); $this->doTest( 'fixer->configure(['syntax' => 'long']); $this->doTest($expected, $input); } public static function provideFixLongSyntaxCases(): iterable { yield [' true) : array("f" => false)));', ' true] : ["f" => false])];']; yield [' [$x, $y]) {}']; } /** * @dataProvider provideFixShortSyntaxCases */ public function testFixShortSyntax(string $expected, ?string $input = null): void { $this->fixer->configure(['syntax' => 'short']); $this->doTest($expected, $input); } public static function provideFixShortSyntaxCases(): iterable { yield [' true] : ["f" => false])];', ' true) : array("f" => false)));']; yield ['