MultilineCommentOpeningClosingFixerTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. yield ['<?php /** Opening DocBlock */'];
  33. yield [
  34. '<?php /* Opening comment */',
  35. '<?php /*** Opening comment */',
  36. ];
  37. yield [
  38. '<?php /*\ Opening false-DocBlock */',
  39. '<?php /**\ Opening false-DocBlock */',
  40. ];
  41. yield [
  42. '<?php /** Closing DocBlock */',
  43. '<?php /** Closing DocBlock ***/',
  44. ];
  45. yield [
  46. '<?php /* Closing comment */',
  47. '<?php /* Closing comment ***/',
  48. ];
  49. yield [
  50. '<?php /**/',
  51. '<?php /***/',
  52. ];
  53. yield [
  54. '<?php /**/',
  55. '<?php /********/',
  56. ];
  57. yield [
  58. <<<'EOT'
  59. <?php
  60. /*
  61. * WUT
  62. */
  63. EOT
  64. ,
  65. <<<'EOT'
  66. <?php
  67. /********
  68. * WUT
  69. ********/
  70. EOT
  71. ,
  72. ];
  73. yield [
  74. <<<'EOT'
  75. <?php
  76. /*\
  77. * False DocBlock
  78. */
  79. EOT
  80. ,
  81. <<<'EOT'
  82. <?php
  83. /**\
  84. * False DocBlock
  85. */
  86. EOT
  87. ,
  88. ];
  89. yield [
  90. <<<'EOT'
  91. <?php
  92. # Hash
  93. #*** Hash asterisk
  94. // Slash
  95. //*** Slash asterisk
  96. /*
  97. /**
  98. /***
  99. Weird multiline comment
  100. */
  101. EOT
  102. ,
  103. ];
  104. }
  105. }