From d1ed40c9f77c02c6ab4fd4308188d2ffb5d8af15 Mon Sep 17 00:00:00 2001 From: inhere Date: Fri, 8 Mar 2019 23:24:58 +0800 Subject: [PATCH] add test for phpDoc helper --- libs/php-utils/test/PhpDocTest.php | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libs/php-utils/test/PhpDocTest.php diff --git a/libs/php-utils/test/PhpDocTest.php b/libs/php-utils/test/PhpDocTest.php new file mode 100644 index 0000000..5316e1f --- /dev/null +++ b/libs/php-utils/test/PhpDocTest.php @@ -0,0 +1,49 @@ +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); + } +}