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
+ $ parsedDescription = $ parsedContents [1 ]->getParsedDescription ();
108
+ $ this ->assertCount (3 , $ parsedDescription );
109
+ $ this ->assertSame ("inline tag with \n" , $ parsedDescription [0 ]);
110
+ $ this ->assertInstanceOf (
111
+ __NAMESPACE__ . '\Tag\LinkTag ' ,
112
+ $ parsedDescription [1 ]
113
+ );
114
+ $ this ->assertSame (' in it ' , $ parsedDescription [2 ]);
115
+ }
116
+
117
+ public function testLiteralOpeningDelimiter ()
118
+ {
119
+ $ fixture = <<<LONGDESC
120
+ This is text for a description containing { that is literal.
121
+ LONGDESC ;
122
+ $ object = new LongDescription ($ fixture );
123
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
124
+
125
+ $ parsedContents = $ object ->getParsedContents ();
126
+ $ this ->assertCount (1 , $ parsedContents );
127
+ $ this ->assertSame ($ fixture , $ parsedContents [0 ]);
128
+ }
129
+
130
+ public function testNestedLiteralOpeningDelimiter ()
131
+ {
132
+ $ fixture = <<<LONGDESC
133
+ This is text for a description containing {@internal inline tag that has { that
134
+ is literal}.
135
+ LONGDESC ;
136
+ $ object = new LongDescription ($ fixture );
137
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
138
+
139
+ $ parsedContents = $ object ->getParsedContents ();
140
+ $ this ->assertCount (3 , $ parsedContents );
141
+ $ this ->assertSame (
142
+ 'This is text for a description containing ' ,
143
+ $ parsedContents [0 ]
144
+ );
145
+ $ this ->assertInstanceOf (
146
+ __NAMESPACE__ . '\Tag ' ,
147
+ $ parsedContents [1 ]
148
+ );
149
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
150
+
151
+ $ this ->assertSame (
152
+ array ('inline tag that has { that
153
+ is literal ' ),
154
+ $ parsedContents [1 ]->getParsedDescription ()
155
+ );
156
+ }
157
+
158
+ public function testLiteralClosingDelimiter ()
159
+ {
160
+ $ fixture = <<<LONGDESC
161
+ This is text for a description with {} that is not a tag.
162
+ LONGDESC ;
163
+ $ object = new LongDescription ($ fixture );
164
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
165
+
166
+ $ parsedContents = $ object ->getParsedContents ();
167
+ $ this ->assertCount (1 , $ parsedContents );
168
+ $ this ->assertSame (
169
+ 'This is text for a description with } that is not a tag. ' ,
170
+ $ parsedContents [0 ]
171
+ );
172
+ }
173
+
174
+ public function testNestedLiteralClosingDelimiter ()
175
+ {
176
+ $ fixture = <<<LONGDESC
177
+ This is text for a description with {@internal inline tag with {} that is not an
178
+ inline tag}.
179
+ LONGDESC ;
180
+ $ object = new LongDescription ($ fixture );
181
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
182
+
183
+ $ parsedContents = $ object ->getParsedContents ();
184
+ $ this ->assertCount (3 , $ parsedContents );
185
+ $ this ->assertSame (
186
+ 'This is text for a description with ' ,
187
+ $ parsedContents [0 ]
188
+ );
189
+ $ this ->assertInstanceOf (
190
+ __NAMESPACE__ . '\Tag ' ,
191
+ $ parsedContents [1 ]
192
+ );
193
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
194
+
195
+ $ this ->assertSame (
196
+ array ('inline tag with } that is not an
197
+ inline tag ' ),
198
+ $ parsedContents [1 ]->getParsedDescription ()
199
+ );
200
+ }
201
+
202
+ public function testInlineTagEscapingSequence ()
203
+ {
204
+ $ fixture = <<<LONGDESC
205
+ This is text for a description with literal {{@}link}.
206
+ LONGDESC ;
207
+ $ object = new LongDescription ($ fixture );
208
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
209
+
210
+ $ parsedContents = $ object ->getParsedContents ();
211
+ $ this ->assertCount (1 , $ parsedContents );
212
+ $ this ->assertSame (
213
+ 'This is text for a description with literal {@link}. ' ,
214
+ $ parsedContents [0 ]
215
+ );
216
+ }
217
+
218
+ public function testNestedInlineTagEscapingSequence ()
219
+ {
220
+ $ fixture = <<<LONGDESC
221
+ This is text for a description with an {@internal inline tag with literal
222
+ {{@}link{} in it}.
223
+ LONGDESC ;
224
+ $ object = new LongDescription ($ fixture );
225
+ $ this ->assertSame ($ fixture , $ object ->getContents ());
226
+
227
+ $ parsedContents = $ object ->getParsedContents ();
228
+ $ this ->assertCount (3 , $ parsedContents );
229
+ $ this ->assertSame (
230
+ 'This is text for a description with an ' ,
231
+ $ parsedContents [0 ]
232
+ );
233
+ $ this ->assertInstanceOf (
234
+ __NAMESPACE__ . '\Tag ' ,
235
+ $ parsedContents [1 ]
236
+ );
237
+ $ this ->assertSame ('. ' , $ parsedContents [2 ]);
238
+
239
+ $ this ->assertSame (
240
+ array ('inline tag with literal
241
+ {@link} in it ' ),
242
+ $ parsedContents [1 ]->getParsedDescription ()
243
+ );
244
+ }
245
+ }
0 commit comments