1
+ <?php
2
+ /**
3
+ * phpDocumentor Long Description Test
4
+ *
5
+ * PHP Version 5.3
6
+ *
7
+ * @author Vasil Rangelov <[email protected] >
8
+ * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
9
+ * @license http://www.opensource.org/licenses/mit-license.php MIT
10
+ * @link http://phpdoc.org
11
+ */
12
+
13
+ namespace phpDocumentor \Reflection \DocBlock ;
14
+
15
+ /**
16
+ * Test class for phpDocumentor\Reflection\DocBlock\LongDescription
17
+ *
18
+ * @author Vasil Rangelov <[email protected] >
19
+ * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
20
+ * @license http://www.opensource.org/licenses/mit-license.php MIT
21
+ * @link http://phpdoc.org
22
+ */
23
+ class LongDescriptionTest extends \PHPUnit_Framework_TestCase
24
+ {
25
+ public function testConstruct ()
26
+ {
27
+ $ fixture = <<<LONGDESC
28
+ This is text for a description.
29
+ LONGDESC ;
30
+ $ object = new LongDescription ($ fixture );
31
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
32
+
33
+ $ parsedContents = $ object ->getParsedContents ();
34
+ $ this ->assertCount (1 , $ parsedContents );
35
+ $ this ->assertSame ($ fixture , $ parsedContents [0 ]);
36
+ }
37
+
38
+ public function testInlineTagParsing ()
39
+ {
40
+ $ fixture = <<<LONGDESC
41
+ This is text for a {@link http://phpdoc.org/ description} that uses inline
42
+ tags.
43
+ LONGDESC ;
44
+ $ object = new LongDescription ($ fixture );
45
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
46
+
47
+ $ parsedContents = $ object ->getParsedContents ();
48
+ $ this ->assertCount (3 , $ parsedContents );
49
+ $ this ->assertSame ('This is text for a ' , $ parsedContents [0 ]);
50
+ $ this ->assertInstanceOf (
51
+ __NAMESPACE__ . '\Tag\LinkTag ' ,
52
+ $ parsedContents [1 ]
53
+ );
54
+ $ this ->assertSame (
55
+ ' that uses inline
56
+ tags. ' ,
57
+ $ parsedContents [2 ]
58
+ );
59
+ }
60
+
61
+ public function testInlineTagAtStartParsing ()
62
+ {
63
+ $ fixture = <<<LONGDESC
64
+ {@link http://phpdoc.org/ This} is text for a description that uses inline
65
+ tags.
66
+ LONGDESC ;
67
+ $ object = new LongDescription ($ fixture );
68
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
69
+
70
+ $ parsedContents = $ object ->getParsedContents ();
71
+ $ this ->assertCount (3 , $ parsedContents );
72
+
73
+ $ this ->assertSame ('' , $ parsedContents [0 ]);
74
+ $ this ->assertInstanceOf (
75
+ __NAMESPACE__ . '\Tag\LinkTag ' ,
76
+ $ parsedContents [1 ]
77
+ );
78
+ $ this ->assertSame (
79
+ ' is text for a description that uses inline
80
+ tags. ' ,
81
+ $ parsedContents [2 ]
82
+ );
83
+ }
84
+
85
+ public function testNestedInlineTagParsing ()
86
+ {
87
+ $ fixture = <<<LONGDESC
88
+ This is text for a description with {@internal inline tag with
89
+ {@link http://phpdoc.org another inline tag} in it}.
90
+ LONGDESC ;
91
+ $ object = new LongDescription ($ fixture );
92
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
93
+
94
+ $ parsedContents = $ object ->getParsedContents ();
95
+ $ this ->assertCount (3 , $ parsedContents );
96
+
97
+ $ this ->assertSame (
98
+ 'This is text for a description with ' ,
99
+ $ parsedContents [0 ]
100
+ );
101
+ $ this ->assertInstanceOf (
102
+ __NAMESPACE__ . '\Tag ' ,
103
+ $ parsedContents [1 ]
104
+ );
105
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
106
+ }
107
+
108
+ public function testEmptyInlineTag ()
109
+ {
110
+ $ fixture = <<<LONGDESC
111
+ This is text for a description with an empty inline tag - {@}.
112
+ LONGDESC ;
113
+ $ object = new LongDescription ($ fixture );
114
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
115
+
116
+ $ parsedContents = $ object ->getParsedContents ();
117
+ $ this ->assertCount (1 , $ parsedContents );
118
+ $ this ->assertSame ($ fixture , $ parsedContents [0 ]);
119
+ }
120
+
121
+ public function testNestedEmptyInlineTag ()
122
+ {
123
+ $ fixture = <<<LONGDESC
124
+ This is text for a description with an {@internal inline tag with an empty
125
+ inline tag - {@} in it}.
126
+ LONGDESC ;
127
+ $ object = new LongDescription ($ fixture );
128
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
129
+
130
+ $ parsedContents = $ object ->getParsedContents ();
131
+ $ this ->assertCount (3 , $ parsedContents );
132
+ $ this ->assertSame (
133
+ 'This is text for a description with an ' ,
134
+ $ parsedContents [0 ]
135
+ );
136
+ $ this ->assertInstanceOf (
137
+ __NAMESPACE__ . '\Tag ' ,
138
+ $ parsedContents [1 ]
139
+ );
140
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
141
+ }
142
+
143
+ public function testInlineTagDelimiters ()
144
+ {
145
+ $ fixture = <<<LONGDESC
146
+ This is text for a description with {} that is not a tag.
147
+ LONGDESC ;
148
+ $ object = new LongDescription ($ fixture );
149
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
150
+
151
+ $ parsedContents = $ object ->getParsedContents ();
152
+ $ this ->assertCount (1 , $ parsedContents );
153
+ $ this ->assertSame ($ fixture , $ parsedContents [0 ]);
154
+ }
155
+
156
+ public function testNestedInlineTagDelimiters ()
157
+ {
158
+ $ fixture = <<<LONGDESC
159
+ This is text for a description with {@internal inline tag with {} that is not an
160
+ inline tag}.
161
+ LONGDESC ;
162
+ $ object = new LongDescription ($ fixture );
163
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
164
+
165
+ $ parsedContents = $ object ->getParsedContents ();
166
+ $ this ->assertCount (3 , $ parsedContents );
167
+ $ this ->assertSame (
168
+ 'This is text for a description with ' ,
169
+ $ parsedContents [0 ]
170
+ );
171
+ $ this ->assertInstanceOf (
172
+ __NAMESPACE__ . '\Tag ' ,
173
+ $ parsedContents [1 ]
174
+ );
175
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
176
+ }
177
+ }
0 commit comments