* 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\LanguageConstruct; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer */ final class DeclareEqualNormalizeFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input, array $config): void { $this->fixer->configure($config); $this->doTest($expected, $input); } public function provideFixCases(): array { return [ 'minimal case remove whitespace (default config)' => [ ' [ ' 'none'], ], 'minimal case add whitespace' => [ ' 'single'], ], 'to much whitespace case add whitespace' => [ ' 'single'], ], 'repeating case remove whitespace (default config)' => [ '', '', [], ], 'repeating case add whitespace' => [ '', '', ['space' => 'single'], ], 'minimal case add whitespace comments, single' => [ ' 'single'], ], 'minimal case add whitespace comments, none' => [ ' 'none'], ], ]; } /** * @dataProvider provideInvalidConfigCases */ public function testInvalidConfig(array $config, string $expectedMessage): void { $this->expectException(InvalidFixerConfigurationException::class); $this->expectExceptionMessage(sprintf('[declare_equal_normalize] Invalid configuration: %s', $expectedMessage)); $this->fixer->configure($config); } public function provideInvalidConfigCases(): array { return [ [ [1, 2], 'The options "0", "1" do not exist.', ], [ ['space' => 'tab'], 'The option "space" with value "tab" is invalid.', ], ]; } }