PhpDocTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php declare(strict_types=1);
  2. /**
  3. * This file is part of toolkit/stdlib.
  4. *
  5. * @author https://github.com/inhere
  6. * @link https://github.com/php-toolkit/stdlib
  7. * @license MIT
  8. */
  9. namespace Toolkit\StdlibTest\Util;
  10. use PHPUnit\Framework\TestCase;
  11. use ReflectionMethod;
  12. use Toolkit\Stdlib\Util\PhpDoc;
  13. /**
  14. * class PhpDocTest
  15. */
  16. class PhpDocTest extends TestCase
  17. {
  18. /**
  19. * Open an github repository by browser
  20. *
  21. * @options
  22. * -r, --remote The git remote name. default is `origin`
  23. * --main Use the config `mainRemote` name
  24. *
  25. * @arguments
  26. * repoPath The remote git repo URL or repository group/name.
  27. * If not input, will auto parse from current work directory
  28. *
  29. * @param string $input
  30. * @param int $output
  31. *
  32. * @example
  33. * {fullCmd} php-toolkit/cli-utils
  34. * {fullCmd} https://github.com/php-toolkit/cli-utils
  35. */
  36. public function testDoc_basic(): void
  37. {
  38. $rftMth = new ReflectionMethod($this, 'testDoc_basic');
  39. $tags = PhpDoc::getTags($rftMth->getDocComment(), [
  40. 'default' => 'desc',
  41. ]);
  42. $this->assertArrayHasKey('desc', $tags);
  43. $this->assertArrayHasKey('example', $tags);
  44. $this->assertArrayHasKey('options', $tags);
  45. $this->assertArrayHasKey('arguments', $tags);
  46. $this->assertEquals('Open an github repository by browser', $tags['desc']);
  47. }
  48. }