NoTrailingWhitespaceFixerTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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\Fixer\Whitespace;
  12. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer
  19. */
  20. final class NoTrailingWhitespaceFixerTest extends AbstractFixerTestCase
  21. {
  22. /**
  23. * @param string $expected
  24. * @param null|string $input
  25. *
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix($expected, $input = null)
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. public function provideFixCases()
  33. {
  34. return [
  35. [
  36. '<?php
  37. $a = 1;',
  38. '<?php
  39. $a = 1; ',
  40. ],
  41. [
  42. '<?php
  43. $a = 1 ;',
  44. '<?php
  45. $a = 1 ; ',
  46. ],
  47. [
  48. '<?php
  49. $b = 1;',
  50. '<?php
  51. $b = 1; ',
  52. ],
  53. [
  54. "<?php \$b = 1;\n ",
  55. "<?php \$b = 1; \n ",
  56. ],
  57. [
  58. "<?php \$b = 1;\n\$c = 1;",
  59. "<?php \$b = 1; \n\$c = 1;",
  60. ],
  61. [
  62. "<?php\necho 1;\n \necho2;",
  63. ],
  64. [
  65. '<?php
  66. $b = 1;
  67. ',
  68. ],
  69. [
  70. "<?php\n\$a=1;\n \n\t\n\$b = 1;",
  71. ],
  72. [
  73. "<?php\necho 1;\n?>\n\n\n\n",
  74. ],
  75. [
  76. "<?php\n\techo 1;\n?>\n\n\t a \r\n b \r\n",
  77. ],
  78. [
  79. "<?php
  80. <<<'EOT'
  81. Il y eut un rire éclatant des écoliers qui décontenança le pauvre
  82. garçon, si bien qu'il ne savait s'il fallait garder sa casquette à
  83. la main, la laisser par terre ou la mettre sur sa tête. Il se
  84. rassit et la posa sur ses genoux.
  85. EOT;
  86. ",
  87. ],
  88. [
  89. "<?php\n\$string = 'x \ny';\necho (strlen(\$string) === 5);",
  90. ],
  91. [
  92. "<?php\necho <<<'EOT'\nInline Il y eut un \r\nrire éclatant \n \n \r\nEOT;\n\n",
  93. ],
  94. ];
  95. }
  96. }