-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKodocTest.php
More file actions
executable file
·368 lines (361 loc) · 6.35 KB
/
Copy pathKodocTest.php
File metadata and controls
executable file
·368 lines (361 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php
/**
* @group kohana
* @group kohana.userguide
*
* @package Kohana/Userguide
* @author Kohana Team
* @copyright (c) 2008-2013 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_KodocTest extends PHPUnit_Framework_TestCase
{
public function provider_parse_basic()
{
return array(
array(
<<<'COMMENT'
/**
* Description
*/
COMMENT
,
array("<p>Description</p>\n", array()),
),
array(
<<<'COMMENT'
/**
* Description spanning
* multiple lines
*/
COMMENT
,
array("<p>Description spanning\nmultiple lines</p>\n", array()),
),
array(
<<<'COMMENT'
/**
* Description including
*
* a code block
*/
COMMENT
,
array("<p>Description including</p>\n\n<pre><code>a code block\n</code></pre>\n", array()),
),
array(
<<<'COMMENT'
/**
* Indented
*/
COMMENT
,
array("<p>Indented</p>\n", array()),
),
array(
<<<'COMMENT'
/**
* @tag Content
*/
COMMENT
,
array('', array('tag' => array('Content'))),
),
array(
<<<'COMMENT'
/**
* @tag Multiple
* @tag Tags
*/
COMMENT
,
array('', array('tag' => array('Multiple', 'Tags'))),
),
array(
<<<'COMMENT'
/**
* Description with tag
* @tag Content
*/
COMMENT
,
array(
"<p>Description with tag</p>\n",
array('tag' => array('Content')),
),
),
array(
<<<'COMMENT'
/**
* @trailingspace
*/
COMMENT
,
array('', array('trailingspace' => array(''))),
),
array(
<<<'COMMENT'
/**
* @tag Content that spans
* multiple lines
*/
COMMENT
,
array(
'',
array('tag' => array("Content that spans\nmultiple lines")),
),
),
array(
<<<'COMMENT'
/**
* @tag Content that spans
* multiple lines indented
*/
COMMENT
,
array(
'',
array('tag' => array("Content that spans\n multiple lines indented")),
),
),
);
}
/**
* @covers Kohana_Kodoc::parse
*
* @dataProvider provider_parse_basic
*
* @param string $comment Argument to the method
* @param array $expected Expected result
*/
public function test_parse_basic($comment, $expected)
{
$this->assertSame($expected, Kodoc::parse($comment));
}
public function provider_parse_tags()
{
$route_api = Route::get('docs/api');
return array(
array(
<<<'COMMENT'
/**
* @access public
*/
COMMENT
,
array('', array()),
),
array(
<<<'COMMENT'
/**
* @copyright Some plain text
*/
COMMENT
,
array('', array('copyright' => array('Some plain text'))),
),
array(
<<<'COMMENT'
/**
* @copyright (c) 2008-2013 Kohana Team
*/
COMMENT
,
array('', array('copyright' => array('© 2008-2013 Kohana Team'))),
),
array(
<<<'COMMENT'
/**
* @license Kohana
*/
COMMENT
,
array('', array('license' => array('Kohana'))),
),
array(
<<<'COMMENT'
/**
* @license http://kohanaframework.org/license
*/
COMMENT
,
array('', array('license' => array('<a href="http://kohanaframework.org/license">http://kohanaframework.org/license</a>'))),
),
array(
<<<'COMMENT'
/**
* @link http://kohanaframework.org
*/
COMMENT
,
array('', array('link' => array('<a href="http://kohanaframework.org">http://kohanaframework.org</a>'))),
),
array(
<<<'COMMENT'
/**
* @link http://kohanaframework.org Description
*/
COMMENT
,
array('', array('link' => array('<a href="http://kohanaframework.org">Description</a>'))),
),
array(
<<<'COMMENT'
/**
* @see MyClass
*/
COMMENT
,
array(
'',
array(
'see' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'MyClass'))
).'">MyClass</a>',
),
),
),
),
array(
<<<'COMMENT'
/**
* @see MyClass::method()
*/
COMMENT
,
array(
'',
array(
'see' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'MyClass')).'#method'
).'">MyClass::method()</a>',
),
),
),
),
array(
<<<'COMMENT'
/**
* @throws Exception
*/
COMMENT
,
array(
'',
array(
'throws' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'Exception'))
).'">Exception</a>',
),
),
),
),
array(
<<<'COMMENT'
/**
* @throws Exception During failure
*/
COMMENT
,
array(
'',
array(
'throws' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'Exception'))
).'">Exception</a> During failure',
),
),
),
),
array(
<<<'COMMENT'
/**
* @uses MyClass
*/
COMMENT
,
array(
'',
array(
'uses' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'MyClass'))
).'">MyClass</a>',
),
),
),
),
array(
<<<'COMMENT'
/**
* @uses MyClass::method()
*/
COMMENT
,
array(
'',
array(
'uses' => array(
'<a href="'.URL::site(
$route_api->uri(array('class' => 'MyClass')).'#method'
).'">MyClass::method()</a>',
),
),
),
),
);
}
/**
* @covers Kohana_Kodoc::format_tag
* @covers Kohana_Kodoc::parse
*
* @dataProvider provider_parse_tags
*
* @param string $comment Argument to the method
* @param array $expected Expected result
*/
public function test_parse_tags($comment, $expected)
{
$this->assertSame($expected, Kodoc::parse($comment));
}
/**
* Provides test data for test_transparent_classes
* @return array
*/
public function provider_transparent_classes()
{
return array(
// Kohana_Core is a special case
array('Kohana','Kohana_Core',NULL),
array('Controller_Template','Kohana_Controller_Template',NULL),
array('Controller_Template','Kohana_Controller_Template',
array('Kohana_Controller_Template'=>'Kohana_Controller_Template',
'Controller_Template'=>'Controller_Template')
),
array(FALSE,'Kohana_Controller_Template',
array('Kohana_Controller_Template'=>'Kohana_Controller_Template')),
array(FALSE,'Controller_Template',NULL),
);
}
/**
* Tests Kodoc::is_transparent
*
* Checks that a selection of transparent and non-transparent classes give expected results
*
* @group kohana.userguide.3529-configurable-transparent-classes
* @dataProvider provider_transparent_classes
* @param mixed $expected
* @param string $class
* @param array $classes
*/
public function test_transparent_classes($expected, $class, $classes)
{
$result = Kodoc::is_transparent($class, $classes);
$this->assertSame($expected,$result);
}
}