PhpdocTrimConsecutiveBlankLineSeparationFixerTest.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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\Phpdoc;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Nobu Funaki <nobu.funaki@gmail.com>
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. *
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer
  21. */
  22. final class PhpdocTrimConsecutiveBlankLineSeparationFixerTest extends AbstractFixerTestCase
  23. {
  24. /**
  25. * @dataProvider provideFixCases
  26. */
  27. public function testFix(string $expected, ?string $input = null): void
  28. {
  29. $this->doTest($expected, $input);
  30. }
  31. public static function provideFixCases(): iterable
  32. {
  33. return [
  34. 'no changes' => ['<?php /** Summary. */'],
  35. 'only Summary and Description' => [
  36. '<?php
  37. /**
  38. * Summary.
  39. *
  40. * Description.
  41. *
  42. *
  43. *
  44. */',
  45. '<?php
  46. /**
  47. * Summary.
  48. *
  49. *
  50. * Description.
  51. *
  52. *
  53. *
  54. */',
  55. ],
  56. 'basic phpdoc' => [
  57. '<?php
  58. /**
  59. * Summary.
  60. *
  61. * Description.
  62. *
  63. * @var int
  64. *
  65. * @return int
  66. *
  67. * foo
  68. *
  69. * bar
  70. *
  71. *
  72. */',
  73. '<?php
  74. /**
  75. * Summary.
  76. *
  77. *
  78. * Description.
  79. *
  80. *
  81. * @var int
  82. *
  83. *
  84. *
  85. *
  86. * @return int
  87. *
  88. *
  89. * foo
  90. *
  91. *
  92. * bar
  93. *
  94. *
  95. */',
  96. ],
  97. 'extra blank lines in description' => [
  98. '<?php
  99. /**
  100. * Summary.
  101. *
  102. * Description has multiple blank lines:
  103. *
  104. *
  105. *
  106. * End.
  107. *
  108. * @var int
  109. */',
  110. ],
  111. 'extra blank lines after annotation' => [
  112. '<?php
  113. /**
  114. * Summary without description.
  115. *
  116. * @var int
  117. *
  118. * This is still @var annotation description...
  119. *
  120. * But this is not!
  121. *
  122. * @internal
  123. */',
  124. '<?php
  125. /**
  126. * Summary without description.
  127. *
  128. *
  129. * @var int
  130. *
  131. * This is still @var annotation description...
  132. *
  133. *
  134. *
  135. *
  136. * But this is not!
  137. *
  138. *
  139. *
  140. *
  141. *
  142. * @internal
  143. */',
  144. ],
  145. 'extra blank lines between annotations when no Summary no Description' => [
  146. '<?php
  147. /**
  148. * @param string $expected
  149. * @param string $input
  150. *
  151. * @dataProvider provideFix56Cases
  152. */',
  153. '<?php
  154. /**
  155. * @param string $expected
  156. * @param string $input
  157. *
  158. *
  159. * @dataProvider provideFix56Cases
  160. */',
  161. ],
  162. ];
  163. }
  164. }