WhitespacesFixerConfigTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\WhitespacesFixerConfig
  19. */
  20. final class WhitespacesFixerConfigTest extends \PHPUnit_Framework_TestCase
  21. {
  22. /**
  23. * @param string $indent
  24. * @param string $lineEnding
  25. * @param null|string $exceptionRegExp
  26. *
  27. * @dataProvider provideTestCases
  28. */
  29. public function testCases($indent, $lineEnding, $exceptionRegExp = null)
  30. {
  31. if (null !== $exceptionRegExp) {
  32. $this->setExpectedExceptionRegExp(\InvalidArgumentException::class, $exceptionRegExp);
  33. }
  34. $config = new WhitespacesFixerConfig($indent, $lineEnding);
  35. $this->assertSame($indent, $config->getIndent());
  36. $this->assertSame($lineEnding, $config->getLineEnding());
  37. }
  38. public function provideTestCases()
  39. {
  40. return [
  41. [' ', "\n"],
  42. ["\t", "\n"],
  43. [' ', "\r\n"],
  44. ["\t", "\r\n"],
  45. [' ', 'asd', '/lineEnding/'],
  46. [' ', [], '/lineEnding/'],
  47. ['std', "\n", '/indent/'],
  48. [[], "\n", '/indent/'],
  49. ];
  50. }
  51. }