NoTrailingWhitespaceInCommentFixerTest.php 3.0 KB

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