MultilineCommentOpeningClosingFixerTest.php 2.6 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. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Comment\MultilineCommentOpeningClosingFixer>
  22. */
  23. final class MultilineCommentOpeningClosingFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix(string $expected, ?string $input = null): void
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. /**
  33. * @return iterable<array{0: string, 1?: string}>
  34. */
  35. public static function provideFixCases(): iterable
  36. {
  37. yield ['<?php /** Opening DocBlock */'];
  38. yield [
  39. '<?php /* Opening comment */',
  40. '<?php /*** Opening comment */',
  41. ];
  42. yield [
  43. '<?php /*\ Opening false-DocBlock */',
  44. '<?php /**\ Opening false-DocBlock */',
  45. ];
  46. yield [
  47. '<?php /** Closing DocBlock */',
  48. '<?php /** Closing DocBlock ***/',
  49. ];
  50. yield [
  51. '<?php /* Closing comment */',
  52. '<?php /* Closing comment ***/',
  53. ];
  54. yield [
  55. '<?php /**/',
  56. '<?php /***/',
  57. ];
  58. yield [
  59. '<?php /**/',
  60. '<?php /********/',
  61. ];
  62. yield [
  63. <<<'EOT'
  64. <?php
  65. /*
  66. * WUT
  67. */
  68. EOT,
  69. <<<'EOT'
  70. <?php
  71. /********
  72. * WUT
  73. ********/
  74. EOT,
  75. ];
  76. yield [
  77. <<<'EOT'
  78. <?php
  79. /*\
  80. * False DocBlock
  81. */
  82. EOT,
  83. <<<'EOT'
  84. <?php
  85. /**\
  86. * False DocBlock
  87. */
  88. EOT,
  89. ];
  90. yield [
  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. }