ShortDescriptionTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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\DocBlock;
  13. use PhpCsFixer\DocBlock\DocBlock;
  14. use PhpCsFixer\DocBlock\ShortDescription;
  15. use PhpCsFixer\Tests\TestCase;
  16. /**
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\DocBlock\ShortDescription
  20. */
  21. final class ShortDescriptionTest extends TestCase
  22. {
  23. /**
  24. * @dataProvider provideGetEndCases
  25. */
  26. public function testGetEnd(?int $expected, string $input): void
  27. {
  28. $doc = new DocBlock($input);
  29. $shortDescription = new ShortDescription($doc);
  30. self::assertSame($expected, $shortDescription->getEnd());
  31. }
  32. /**
  33. * @return iterable<array{null|int, string}>
  34. */
  35. public static function provideGetEndCases(): iterable
  36. {
  37. yield [1, '/**
  38. * Test docblock.
  39. *
  40. * @param string $hello
  41. * @param bool $test Description
  42. * extends over many lines
  43. *
  44. * @param adkjbadjasbdand $asdnjkasd
  45. *
  46. * @throws \Exception asdnjkasd
  47. * asdasdasdasdasdasdasdasd
  48. * kasdkasdkbasdasdasdjhbasdhbasjdbjasbdjhb
  49. *
  50. * @return void
  51. */'];
  52. yield [2, '/**
  53. * This is a multi-line
  54. * short description.
  55. */'];
  56. yield [3, '/**
  57. *
  58. *
  59. * There might be extra blank lines.
  60. *
  61. *
  62. * And here is description...
  63. */'];
  64. yield [null, '/** */'];
  65. yield [null, "/**\n * @test\n*/"];
  66. }
  67. }