Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d1ed40c

Browse files
committed
add test for phpDoc helper
1 parent ff3c59a commit d1ed40c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

‎libs/php-utils/test/PhpDocTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Toolkit\PhpUtilTest;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Toolkit\PhpUtil\PhpDoc;
7+
8+
/**
9+
* Class PhpDocTest
10+
* @package Toolkit\PhpUtilTest
11+
*/
12+
class PhpDocTest extends TestCase
13+
{
14+
public function testGetTags(): void
15+
{
16+
$comment = <<<DOC
17+
/**
18+
* Provide some commands to manage the HTTP Server
19+
*
20+
* @since 2.0
21+
*
22+
* @example
23+
* {fullCmd}:start Start the http server
24+
* {fullCmd}:stop Stop the http server
25+
*/
26+
DOC;
27+
$ret = PhpDoc::getTags($comment);
28+
$this->assertCount(3, $ret);
29+
$this->assertArrayHasKey('since', $ret);
30+
$this->assertArrayHasKey('example', $ret);
31+
$this->assertArrayHasKey('description', $ret);
32+
33+
$ret = PhpDoc::getTags($comment, ['allow' => ['example']]);
34+
$this->assertCount(2, $ret);
35+
$this->assertArrayNotHasKey('since', $ret);
36+
$this->assertArrayHasKey('example', $ret);
37+
$this->assertArrayHasKey('description', $ret);
38+
39+
$ret = PhpDoc::getTags($comment, [
40+
'allow' => ['example'],
41+
'default' => 'desc'
42+
]);
43+
$this->assertCount(2, $ret);
44+
$this->assertArrayNotHasKey('since', $ret);
45+
$this->assertArrayHasKey('example', $ret);
46+
$this->assertArrayHasKey('desc', $ret);
47+
$this->assertArrayNotHasKey('description', $ret);
48+
}
49+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /