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