NoTrailingWhitespaceInCommentFixerTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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\Fixer\Comment;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer
  20. */
  21. final class NoTrailingWhitespaceInCommentFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @dataProvider provideFixCases
  25. */
  26. public function testFix(string $expected, ?string $input = null): void
  27. {
  28. $this->doTest($expected, $input);
  29. }
  30. public function provideFixCases()
  31. {
  32. return [
  33. [
  34. '<?php
  35. /*
  36. //
  37. //
  38. //
  39. //
  40. //
  41. //
  42. //
  43. //
  44. */
  45. ',
  46. '<?php
  47. /*
  48. //
  49. //
  50. '.'
  51. //
  52. //
  53. //
  54. '.'
  55. //
  56. //
  57. '.'
  58. //
  59. */
  60. ',
  61. ],
  62. [
  63. '<?php
  64. // This is'.'
  65. //'.'
  66. //'.'
  67. // multiline comment.
  68. //',
  69. '<?php
  70. // This is '.'
  71. // '.'
  72. // '.'
  73. // multiline comment. '.'
  74. // ',
  75. ],
  76. [
  77. '<?php
  78. /*
  79. * This is another'.'
  80. *'.'
  81. *'.'
  82. * multiline comment.'.'
  83. */',
  84. '<?php
  85. /* '.'
  86. * This is another '.'
  87. * '.'
  88. * '.'
  89. * multiline comment. '.'
  90. */',
  91. ],
  92. [
  93. '<?php
  94. /**
  95. * Summary'.'
  96. *'.'
  97. *'.'
  98. * Description.'.'
  99. *
  100. * @annotation
  101. * Foo
  102. */',
  103. '<?php
  104. /** '.'
  105. * Summary '.'
  106. * '.'
  107. * '.'
  108. * Description. '.'
  109. * '.'
  110. * @annotation '.'
  111. * Foo '.'
  112. */',
  113. ],
  114. [
  115. str_replace(
  116. "\n",
  117. "\r\n",
  118. '<?php
  119. /**
  120. * Summary
  121. *'.'
  122. * Description
  123. */'
  124. ),
  125. str_replace(
  126. "\n",
  127. "\r\n",
  128. '<?php
  129. /**
  130. * Summary
  131. * '.'
  132. * Description
  133. */'
  134. ),
  135. ],
  136. [
  137. str_replace(
  138. "\n",
  139. "\r",
  140. '<?php
  141. /**
  142. * Summary
  143. *'.'
  144. * Description
  145. */'
  146. ),
  147. str_replace(
  148. "\n",
  149. "\r",
  150. '<?php
  151. /**
  152. * Summary
  153. * '.'
  154. * Description
  155. */'
  156. ),
  157. ],
  158. ];
  159. }
  160. }