* 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\CastNotation; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @internal * * @covers \PhpCsFixer\Fixer\CastNotation\CastSpacesFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\CastNotation\CastSpacesFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\CastNotation\CastSpacesFixer */ final class CastSpacesFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $config * * @dataProvider provideInvalidConfigurationCases */ public function testInvalidConfiguration(array $config, string $expectedMessage): void { $this->expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessageMatches($expectedMessage); $this->fixer->configure($config); } /** * @return iterable, string}> */ public static function provideInvalidConfigurationCases(): iterable { yield 'missing key' => [ ['a' => 1], '#^\[cast_spaces\] Invalid configuration: The option "a" does not exist\. Defined options are: "space"\.$#', ]; yield 'invalid value' => [ ['space' => 'double'], '#^\[cast_spaces\] Invalid configuration: The option "space" with value "double" is invalid\. Accepted values are: "none", "single"\.$#', ]; } /** * @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 [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; yield [ ' 'none'], ]; } }