ShortDescriptionTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. public static function provideGetEndCases(): iterable
  33. {
  34. yield [1, '/**
  35. * Test docblock.
  36. *
  37. * @param string $hello
  38. * @param bool $test Description
  39. * extends over many lines
  40. *
  41. * @param adkjbadjasbdand $asdnjkasd
  42. *
  43. * @throws \Exception asdnjkasd
  44. * asdasdasdasdasdasdasdasd
  45. * kasdkasdkbasdasdasdjhbasdhbasjdbjasbdjhb
  46. *
  47. * @return void
  48. */'];
  49. yield [2, '/**
  50. * This is a multi-line
  51. * short description.
  52. */'];
  53. yield [3, '/**
  54. *
  55. *
  56. * There might be extra blank lines.
  57. *
  58. *
  59. * And here is description...
  60. */'];
  61. yield [null, '/** */'];
  62. yield [null, "/**\n * @test\n*/"];
  63. }
  64. }