4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\Util;
14 use Psy\Util\Docblock;
16 class DocblockTest extends \PHPUnit\Framework\TestCase
19 * @dataProvider comments
21 public function testDocblockParsing($comment, $body, $tags)
24 ->getMockBuilder('ReflectionClass')
25 ->disableOriginalConstructor()
28 $reflector->expects($this->once())
29 ->method('getDocComment')
30 ->will($this->returnValue($comment));
32 $docblock = new Docblock($reflector);
34 $this->assertEquals($body, $docblock->desc);
36 foreach ($tags as $tag => $value) {
37 $this->assertTrue($docblock->hasTag($tag));
38 $this->assertEquals($value, $docblock->tag($tag));
42 public function comments()
44 if (defined('HHVM_VERSION')) {
45 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.');
49 array('', '', array()),
54 * @throws \Exception with a description
58 'throws' => array(array('type' => '\Exception', 'desc' => 'with a description')),
63 * This is a slightly longer docblock
65 * @param int $foo Is a Foo
66 * @param string $bar With some sort of description
67 * @param \ClassName $baz is cool too
69 * @return int At least it isn\'t a string
71 'This is a slightly longer docblock',
74 array('type' => 'int', 'desc' => 'Is a Foo', 'var' => '$foo'),
75 array('type' => 'string', 'desc' => 'With some sort of description', 'var' => '$bar'),
76 array('type' => '\ClassName', 'desc' => 'is cool too', 'var' => '$baz'),
79 array('type' => 'int', 'desc' => 'At least it isn\'t a string'),
87 * It spans lines, too!
89 * @tagname plus a description
93 "This is a docblock!\n\nIt spans lines, too!",
95 'tagname' => array('plus a description'),