WhitespacesFixerConfigTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests;
  13. use PhpCsFixer\WhitespacesFixerConfig;
  14. /**
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\WhitespacesFixerConfig
  20. */
  21. final class WhitespacesFixerConfigTest extends TestCase
  22. {
  23. /**
  24. * @dataProvider provideTestCases
  25. */
  26. public function testCases(string $indent, string $lineEnding, ?string $exceptionRegExp = null): void
  27. {
  28. if (null !== $exceptionRegExp) {
  29. $this->expectException(\InvalidArgumentException::class);
  30. $this->expectExceptionMessageMatches('%^'.preg_quote($exceptionRegExp, '%').'$%');
  31. }
  32. $config = new WhitespacesFixerConfig($indent, $lineEnding);
  33. static::assertSame($indent, $config->getIndent());
  34. static::assertSame($lineEnding, $config->getLineEnding());
  35. }
  36. public function provideTestCases(): array
  37. {
  38. return [
  39. [' ', "\n"],
  40. ["\t", "\n"],
  41. [' ', "\r\n"],
  42. ["\t", "\r\n"],
  43. [' ', 'asd', 'Invalid "lineEnding" param, expected "\n" or "\r\n".'],
  44. ['std', "\n", 'Invalid "indent" param, expected tab or two or four spaces.'],
  45. ];
  46. }
  47. }