Skip to content

Commit

Permalink
add test for phpDoc helper
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Mar 8, 2019
1 parent ff3c59a commit d1ed40c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions libs/php-utils/test/PhpDocTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Toolkit\PhpUtilTest;

use PHPUnit\Framework\TestCase;
use Toolkit\PhpUtil\PhpDoc;

/**
* Class PhpDocTest
* @package Toolkit\PhpUtilTest
*/
class PhpDocTest extends TestCase
{
public function testGetTags(): void
{
$comment = <<<DOC
/**
* Provide some commands to manage the HTTP Server
*
* @since 2.0
*
* @example
* {fullCmd}:start Start the http server
* {fullCmd}:stop Stop the http server
*/
DOC;
$ret = PhpDoc::getTags($comment);
$this->assertCount(3, $ret);
$this->assertArrayHasKey('since', $ret);
$this->assertArrayHasKey('example', $ret);
$this->assertArrayHasKey('description', $ret);

$ret = PhpDoc::getTags($comment, ['allow' => ['example']]);
$this->assertCount(2, $ret);
$this->assertArrayNotHasKey('since', $ret);
$this->assertArrayHasKey('example', $ret);
$this->assertArrayHasKey('description', $ret);

$ret = PhpDoc::getTags($comment, [
'allow' => ['example'],
'default' => 'desc'
]);
$this->assertCount(2, $ret);
$this->assertArrayNotHasKey('since', $ret);
$this->assertArrayHasKey('example', $ret);
$this->assertArrayHasKey('desc', $ret);
$this->assertArrayNotHasKey('description', $ret);
}
}

0 comments on commit d1ed40c

Please sign in to comment.