Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/Psy/Test/Util/DocblockTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2017 Justin Hileman | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Psy\Test\Util; | |
13 | |
14 use Psy\Util\Docblock; | |
15 | |
16 class DocblockTest extends \PHPUnit\Framework\TestCase | |
17 { | |
18 /** | |
19 * @dataProvider comments | |
20 */ | |
21 public function testDocblockParsing($comment, $body, $tags) | |
22 { | |
23 $reflector = $this | |
24 ->getMockBuilder('ReflectionClass') | |
25 ->disableOriginalConstructor() | |
26 ->getMock(); | |
27 | |
28 $reflector->expects($this->once()) | |
29 ->method('getDocComment') | |
30 ->will($this->returnValue($comment)); | |
31 | |
32 $docblock = new Docblock($reflector); | |
33 | |
34 $this->assertEquals($body, $docblock->desc); | |
35 | |
36 foreach ($tags as $tag => $value) { | |
37 $this->assertTrue($docblock->hasTag($tag)); | |
38 $this->assertEquals($value, $docblock->tag($tag)); | |
39 } | |
40 } | |
41 | |
42 public function comments() | |
43 { | |
44 if (defined('HHVM_VERSION')) { | |
45 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.'); | |
46 } | |
47 | |
48 return array( | |
49 array('', '', array()), | |
50 array( | |
51 '/** | |
52 * This is a docblock | |
53 * | |
54 * @throws \Exception with a description | |
55 */', | |
56 'This is a docblock', | |
57 array( | |
58 'throws' => array(array('type' => '\Exception', 'desc' => 'with a description')), | |
59 ), | |
60 ), | |
61 array( | |
62 '/** | |
63 * This is a slightly longer docblock | |
64 * | |
65 * @param int $foo Is a Foo | |
66 * @param string $bar With some sort of description | |
67 * @param \ClassName $baz is cool too | |
68 * | |
69 * @return int At least it isn\'t a string | |
70 */', | |
71 'This is a slightly longer docblock', | |
72 array( | |
73 'param' => array( | |
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'), | |
77 ), | |
78 'return' => array( | |
79 array('type' => 'int', 'desc' => 'At least it isn\'t a string'), | |
80 ), | |
81 ), | |
82 ), | |
83 array( | |
84 '/** | |
85 * This is a docblock! | |
86 * | |
87 * It spans lines, too! | |
88 * | |
89 * @tagname plus a description | |
90 * | |
91 * @return | |
92 */', | |
93 "This is a docblock!\n\nIt spans lines, too!", | |
94 array( | |
95 'tagname' => array('plus a description'), | |
96 ), | |
97 ), | |
98 ); | |
99 } | |
100 } |