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()
45 array('', '', array()),
50 * @throws \Exception with a description
54 'throws' => array(array('type' => '\Exception', 'desc' => 'with a description')),
59 * This is a slightly longer docblock
61 * @param int $foo Is a Foo
62 * @param string $bar With some sort of description
63 * @param \ClassName $baz is cool too
65 * @return int At least it isn\'t a string
67 'This is a slightly longer docblock',
70 array('type' => 'int', 'desc' => 'Is a Foo', 'var' => '$foo'),
71 array('type' => 'string', 'desc' => 'With some sort of description', 'var' => '$bar'),
72 array('type' => '\ClassName', 'desc' => 'is cool too', 'var' => '$baz'),
75 array('type' => 'int', 'desc' => 'At least it isn\'t a string'),
83 * It spans lines, too!
85 * @tagname plus a description
89 "This is a docblock!\n\nIt spans lines, too!",
91 'tagname' => array('plus a description'),