MultilineCommentOpeningClosingFixerTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 Filippo Tessarotto <zoeslam@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\Comment\MultilineCommentOpeningClosingFixer
  20. */
  21. final class MultilineCommentOpeningClosingFixerTest 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 static function provideFixCases(): iterable
  31. {
  32. return [
  33. ['<?php /** Opening DocBlock */'],
  34. [
  35. '<?php /* Opening comment */',
  36. '<?php /*** Opening comment */',
  37. ],
  38. [
  39. '<?php /*\ Opening false-DocBlock */',
  40. '<?php /**\ Opening false-DocBlock */',
  41. ],
  42. [
  43. '<?php /** Closing DocBlock */',
  44. '<?php /** Closing DocBlock ***/',
  45. ],
  46. [
  47. '<?php /* Closing comment */',
  48. '<?php /* Closing comment ***/',
  49. ],
  50. [
  51. '<?php /**/',
  52. '<?php /***/',
  53. ],
  54. [
  55. '<?php /**/',
  56. '<?php /********/',
  57. ],
  58. [
  59. <<<'EOT'
  60. <?php
  61. /*
  62. * WUT
  63. */
  64. EOT
  65. ,
  66. <<<'EOT'
  67. <?php
  68. /********
  69. * WUT
  70. ********/
  71. EOT
  72. ,
  73. ],
  74. [
  75. <<<'EOT'
  76. <?php
  77. /*\
  78. * False DocBlock
  79. */
  80. EOT
  81. ,
  82. <<<'EOT'
  83. <?php
  84. /**\
  85. * False DocBlock
  86. */
  87. EOT
  88. ,
  89. ],
  90. [
  91. <<<'EOT'
  92. <?php
  93. # Hash
  94. #*** Hash asterisk
  95. // Slash
  96. //*** Slash asterisk
  97. /*
  98. /**
  99. /***
  100. Weird multiline comment
  101. */
  102. EOT
  103. ,
  104. ],
  105. ];
  106. }
  107. }