WhitespacesFixerConfigTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\Tests;
  12. use PhpCsFixer\WhitespacesFixerConfig;
  13. use PHPUnit\Framework\TestCase;
  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. * @param string $indent
  25. * @param string $lineEnding
  26. * @param null|string $exceptionRegExp
  27. *
  28. * @dataProvider provideTestCases
  29. */
  30. public function testCases($indent, $lineEnding, $exceptionRegExp = null)
  31. {
  32. if (null !== $exceptionRegExp) {
  33. $this->setExpectedExceptionRegExp(\InvalidArgumentException::class, $exceptionRegExp);
  34. }
  35. $config = new WhitespacesFixerConfig($indent, $lineEnding);
  36. $this->assertSame($indent, $config->getIndent());
  37. $this->assertSame($lineEnding, $config->getLineEnding());
  38. }
  39. public function provideTestCases()
  40. {
  41. return [
  42. [' ', "\n"],
  43. ["\t", "\n"],
  44. [' ', "\r\n"],
  45. ["\t", "\r\n"],
  46. [' ', 'asd', '/lineEnding/'],
  47. [' ', [], '/lineEnding/'],
  48. ['std', "\n", '/indent/'],
  49. [[], "\n", '/indent/'],
  50. ];
  51. }
  52. }