Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/Util/DocblockTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2018 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->assertSame($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 [ | |
49 ['', '', []], | |
50 [ | |
51 '/** | |
52 * This is a docblock | |
53 * | |
54 * @throws \Exception with a description | |
55 */', | |
56 'This is a docblock', | |
57 [ | |
58 'throws' => [['type' => '\Exception', 'desc' => 'with a description']], | |
59 ], | |
60 ], | |
61 [ | |
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 [ | |
73 'param' => [ | |
74 ['type' => 'int', 'desc' => 'Is a Foo', 'var' => '$foo'], | |
75 ['type' => 'string', 'desc' => 'With some sort of description', 'var' => '$bar'], | |
76 ['type' => '\ClassName', 'desc' => 'is cool too', 'var' => '$baz'], | |
77 ], | |
78 'return' => [ | |
79 ['type' => 'int', 'desc' => 'At least it isn\'t a string'], | |
80 ], | |
81 ], | |
82 ], | |
83 [ | |
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 [ | |
95 'tagname' => ['plus a description'], | |
96 ], | |
97 ], | |
98 ]; | |
99 } | |
100 } |