@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class Issue0015Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Tests issue 15; Allow enumeration of property values |
|
8 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
9 | - */ |
|
10 | - public function testPropertyEnumeration() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * Tests issue 15; Allow enumeration of property values |
|
8 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
9 | + */ |
|
10 | + public function testPropertyEnumeration() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | api Test |
15 | 15 | definition ClassName |
16 | 16 | title ClassName |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | response 204 |
24 | 24 | ')); |
25 | 25 | |
26 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
27 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"204":{"description":"No Content"}}}}}' |
|
28 | - . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
29 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
30 | - } |
|
26 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
27 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"204":{"description":"No Content"}}}}}' |
|
28 | + . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
29 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -3,515 +3,515 @@ |
||
3 | 3 | class ParserTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Test if the statement matches the expected values |
|
8 | - * @param \SwaggerGen\Statement $statement |
|
9 | - * @param string $command |
|
10 | - * @param string $data |
|
11 | - */ |
|
12 | - private function assertStatement($statement, $command, $data = '') |
|
13 | - { |
|
14 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
15 | - $this->assertSame($command, $statement->getCommand()); |
|
16 | - $this->assertSame($data, $statement->getData()); |
|
17 | - } |
|
18 | - |
|
19 | - /** |
|
20 | - * Test if the statement matches the expected values |
|
21 | - * @param array[] $expected |
|
22 | - * @param SwaggerGen\Parser\Php\Statement[] $statements |
|
23 | - */ |
|
24 | - private function assertStatements(array $expected, array $statements) |
|
25 | - { |
|
26 | - $this->assertCount(count($expected), $statements, join("\n", $statements)); |
|
27 | - foreach ($expected as $index => $command) { |
|
28 | - $statement = $statements[$index]; |
|
29 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
30 | - $this->assertSame($command[0], $statement->getCommand()); |
|
31 | - $this->assertSame($command[1], $statement->getData()); |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
37 | - */ |
|
38 | - public function testConstructor_Empty() |
|
39 | - { |
|
40 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
41 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
46 | - */ |
|
47 | - public function testConstructor_Dirs() |
|
48 | - { |
|
49 | - $this->markTestIncomplete('Not yet implemented.'); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @covers \SwaggerGen\Parser\Php\Parser::addDirs |
|
54 | - */ |
|
55 | - public function testAddDirs() |
|
56 | - { |
|
57 | - $this->markTestIncomplete('Not yet implemented.'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Test all open-curlies are (ac-)counted for in functions |
|
62 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
63 | - */ |
|
64 | - public function testParse_CurlyBraceFunction() |
|
65 | - { |
|
66 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
67 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
68 | - |
|
69 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CurlyBraceFunction.php'); |
|
70 | - $this->assertCount(6, $statements); |
|
71 | - $this->assertStatement($statements[0], 'title', 'CurlyBraceFunction'); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
76 | - */ |
|
77 | - public function testParse_NoMethods() |
|
78 | - { |
|
79 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
80 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
81 | - |
|
82 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_NoMethods.php'); |
|
83 | - |
|
84 | - $this->assertCount(2, $statements); |
|
85 | - |
|
86 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
87 | - $this->assertStatement($statements[1], 'version', '2'); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
92 | - */ |
|
93 | - public function testParse_WithMethod() |
|
94 | - { |
|
95 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
96 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
97 | - |
|
98 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_WithMethod.php'); |
|
99 | - |
|
100 | - $this->assertCount(4, $statements); |
|
101 | - |
|
102 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
103 | - $this->assertStatement($statements[1], 'version', '2'); |
|
104 | - $this->assertStatement($statements[2], 'description', 'some description'); |
|
105 | - $this->assertStatement($statements[3], 'method', 'get something'); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
110 | - */ |
|
111 | - public function testParse_LineContinuation() |
|
112 | - { |
|
113 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
114 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
115 | - |
|
116 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_LineContinuation.php'); |
|
117 | - |
|
118 | - $this->assertCount(2, $statements); |
|
119 | - |
|
120 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
121 | - $this->assertStatement($statements[1], 'description', 'About this strange little class'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
126 | - */ |
|
127 | - public function testParse_InClass() |
|
128 | - { |
|
129 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
130 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
131 | - |
|
132 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InClass.php'); |
|
133 | - |
|
134 | - $this->assertCount(3, $statements); |
|
135 | - |
|
136 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
137 | - $this->assertStatement($statements[1], 'description', 'Some description'); |
|
138 | - $this->assertStatement($statements[2], 'license', 'mit'); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
143 | - */ |
|
144 | - public function testParse_CommentsTypes() |
|
145 | - { |
|
146 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
147 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
148 | - |
|
149 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CommentsTypes.php'); |
|
150 | - |
|
151 | - $this->assertCount(3, $statements); |
|
152 | - |
|
153 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
154 | - $this->assertStatement($statements[1], 'version', '2'); |
|
155 | - $this->assertStatement($statements[2], 'license', 'mit'); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
160 | - */ |
|
161 | - public function testParse_MethodNonDoc() |
|
162 | - { |
|
163 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
164 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
165 | - |
|
166 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_MethodNonDoc.php'); |
|
167 | - |
|
168 | - $this->assertCount(3, $statements); |
|
169 | - |
|
170 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
171 | - $this->assertStatement($statements[1], 'version', '2'); |
|
172 | - $this->assertStatement($statements[2], 'method', 'get something'); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
177 | - */ |
|
178 | - public function testParse_InMethod() |
|
179 | - { |
|
180 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
181 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
182 | - |
|
183 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InMethod.php'); |
|
184 | - |
|
185 | - $this->assertCount(4, $statements); |
|
186 | - |
|
187 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
188 | - $this->assertStatement($statements[1], 'version', '2'); |
|
189 | - $this->assertStatement($statements[2], 'description', 'some description'); |
|
190 | - $this->assertStatement($statements[3], 'method', 'get something'); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
195 | - */ |
|
196 | - public function testParse_AfterClass() |
|
197 | - { |
|
198 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
199 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
200 | - |
|
201 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_AfterClass.php'); |
|
202 | - |
|
203 | - $this->assertCount(2, $statements); |
|
204 | - |
|
205 | - $this->assertStatement($statements[0], 'license', 'mit'); |
|
206 | - $this->assertStatement($statements[1], 'title', 'Some words'); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
211 | - */ |
|
212 | - public function testParse_Prefix() |
|
213 | - { |
|
214 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
215 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
216 | - |
|
217 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Prefix.php'); |
|
218 | - |
|
219 | - $this->assertCount(1, $statements); |
|
220 | - |
|
221 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | - */ |
|
227 | - public function testParse_PropertyReadOnly() |
|
228 | - { |
|
229 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | - |
|
232 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | - |
|
234 | - $this->assertCount(4, $statements); |
|
235 | - |
|
236 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | - $this->assertStatement($statements[1], 'version', '2'); |
|
238 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | - $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | - */ |
|
245 | - public function testParse_PropertyOptional() |
|
246 | - { |
|
247 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | - |
|
250 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | - |
|
252 | - $this->assertCount(4, $statements); |
|
253 | - |
|
254 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | - $this->assertStatement($statements[1], 'version', '2'); |
|
256 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | - $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
262 | - */ |
|
263 | - public function testParse_Minimal() |
|
264 | - { |
|
265 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
266 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
267 | - |
|
268 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Minimal.php'); |
|
269 | - |
|
270 | - $this->assertCount(4, $statements); |
|
271 | - |
|
272 | - $this->assertStatement($statements[0], 'title', 'Minimal'); |
|
273 | - $this->assertStatement($statements[1], 'api', 'MyApi Example'); |
|
274 | - $this->assertStatement($statements[2], 'endpoint', '/endpoint'); |
|
275 | - $this->assertStatement($statements[3], 'method', 'GET Something'); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Tests FunctionName |
|
280 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
281 | - */ |
|
282 | - public function testParse_SeeFunction() |
|
283 | - { |
|
284 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
285 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
286 | - |
|
287 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeFunction.php'); |
|
288 | - |
|
289 | - $this->assertStatements(array( |
|
290 | - array('api', 'MyApi Example'), |
|
291 | - array('endpoint', '/endpoint'), |
|
292 | - array('method', 'GET Something'), |
|
293 | - array('error', '400'), |
|
294 | - ), $statements); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Tests $this->MethodName |
|
299 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
300 | - */ |
|
301 | - public function testParse_SeeThisMethod() |
|
302 | - { |
|
303 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
304 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
305 | - |
|
306 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeThisMethod.php'); |
|
307 | - |
|
308 | - $this->assertStatements(array( |
|
309 | - array('api', 'MyApi Example'), |
|
310 | - array('endpoint', '/endpoint'), |
|
311 | - array('method', 'GET Something'), |
|
312 | - array('error', '400'), |
|
313 | - ), $statements); |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Tests Class->MethodName |
|
318 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
319 | - */ |
|
320 | - public function testParse_SeeObjectMethod() |
|
321 | - { |
|
322 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
323 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
324 | - |
|
325 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeObjectMethod.php'); |
|
326 | - |
|
327 | - $this->assertStatements(array( |
|
328 | - array('api', 'MyApi Example'), |
|
329 | - array('endpoint', '/endpoint'), |
|
330 | - array('method', 'GET Something'), |
|
331 | - array('error', '400'), |
|
332 | - ), $statements); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Tests self::MethodName |
|
337 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
338 | - */ |
|
339 | - public function testParse_SeeSelfMethod() |
|
340 | - { |
|
341 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
342 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
343 | - |
|
344 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeSelfMethod.php'); |
|
345 | - |
|
346 | - $this->assertStatements(array( |
|
347 | - array('api', 'MyApi Example'), |
|
348 | - array('endpoint', '/endpoint'), |
|
349 | - array('method', 'GET Something'), |
|
350 | - array('error', '400'), |
|
351 | - ), $statements); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Tests Class::MethodName |
|
356 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
357 | - */ |
|
358 | - public function testParse_SeeClassMethod() |
|
359 | - { |
|
360 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
361 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
362 | - |
|
363 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeClassMethod.php'); |
|
364 | - |
|
365 | - $this->assertStatements(array( |
|
366 | - array('api', 'MyApi Example'), |
|
367 | - array('endpoint', '/endpoint'), |
|
368 | - array('method', 'GET Something'), |
|
369 | - array('error', '400'), |
|
370 | - ), $statements); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Tests static::MethodName |
|
375 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
376 | - */ |
|
377 | - public function testParse_StaticMethod() |
|
378 | - { |
|
379 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
380 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
381 | - |
|
382 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_StaticMethod.php'); |
|
383 | - |
|
384 | - $this->assertStatements(array( |
|
385 | - array('api', 'MyApi Example'), |
|
386 | - array('endpoint', '/endpoint'), |
|
387 | - array('method', 'GET Something'), |
|
388 | - array('error', '400'), |
|
389 | - ), $statements); |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Tests $this->MethodName with inheritance |
|
394 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
395 | - */ |
|
396 | - public function testParse_SeeInheritedThisMethod() |
|
397 | - { |
|
398 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
399 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
400 | - |
|
401 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedThisMethod.php'); |
|
402 | - |
|
403 | - $this->assertStatements(array( |
|
404 | - array('api', 'MyApi Example'), |
|
405 | - array('endpoint', '/endpoint'), |
|
406 | - array('method', 'GET Something'), |
|
407 | - array('error', '400'), |
|
408 | - ), $statements); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * Tests Class->MethodName with inheritance |
|
413 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
414 | - */ |
|
415 | - public function testParse_SeeInheritedObjectMethod() |
|
416 | - { |
|
417 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
418 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
419 | - |
|
420 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedObjectMethod.php'); |
|
421 | - |
|
422 | - $this->assertStatements(array( |
|
423 | - array('api', 'MyApi Example'), |
|
424 | - array('endpoint', '/endpoint'), |
|
425 | - array('method', 'GET Something'), |
|
426 | - array('error', '400'), |
|
427 | - ), $statements); |
|
428 | - } |
|
429 | - |
|
430 | - /** |
|
431 | - * Tests Autoloading other class when referenced |
|
432 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
433 | - */ |
|
434 | - public function testParse_Autoload_Parse() |
|
435 | - { |
|
436 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
437 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
438 | - |
|
439 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php', array( |
|
440 | - __DIR__ . '/ParserTest', |
|
441 | - )); |
|
442 | - |
|
443 | - $this->assertStatements(array( |
|
444 | - array('api', 'MyApi Example'), |
|
445 | - array('endpoint', '/endpoint'), |
|
446 | - array('method', 'GET Something'), |
|
447 | - array('error', '400'), |
|
448 | - ), $statements); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Tests Autoloading other class when referenced |
|
453 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
454 | - */ |
|
455 | - public function testParse_Autoload_Construct() |
|
456 | - { |
|
457 | - $object = new \SwaggerGen\Parser\Php\Parser(array( |
|
458 | - __DIR__ . '/ParserTest', |
|
459 | - )); |
|
460 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
461 | - |
|
462 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
463 | - |
|
464 | - $this->assertStatements(array( |
|
465 | - array('api', 'MyApi Example'), |
|
466 | - array('endpoint', '/endpoint'), |
|
467 | - array('method', 'GET Something'), |
|
468 | - array('error', '400'), |
|
469 | - ), $statements); |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Tests Autoloading other class when referenced |
|
474 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
475 | - */ |
|
476 | - public function testParse_Autoload_AddDirs() |
|
477 | - { |
|
478 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
479 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
480 | - |
|
481 | - $object->addDirs(array( |
|
482 | - __DIR__ . '/ParserTest', |
|
483 | - )); |
|
484 | - |
|
485 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
486 | - |
|
487 | - $this->assertStatements(array( |
|
488 | - array('api', 'MyApi Example'), |
|
489 | - array('endpoint', '/endpoint'), |
|
490 | - array('method', 'GET Something'), |
|
491 | - array('error', '400'), |
|
492 | - ), $statements); |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
497 | - */ |
|
498 | - public function testParse_XTag() |
|
499 | - { |
|
500 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
501 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
502 | - |
|
503 | - $object->addDirs(array( |
|
504 | - __DIR__ . '/ParserTest', |
|
505 | - )); |
|
506 | - |
|
507 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_XTag.php'); |
|
508 | - |
|
509 | - $this->assertStatements(array( |
|
510 | - array('api', 'MyApi Example'), |
|
511 | - array('endpoint', '/endpoint'), |
|
512 | - array('x-something', 'else'), |
|
513 | - array('method', 'GET Something'), |
|
514 | - ), $statements); |
|
515 | - } |
|
6 | + /** |
|
7 | + * Test if the statement matches the expected values |
|
8 | + * @param \SwaggerGen\Statement $statement |
|
9 | + * @param string $command |
|
10 | + * @param string $data |
|
11 | + */ |
|
12 | + private function assertStatement($statement, $command, $data = '') |
|
13 | + { |
|
14 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
15 | + $this->assertSame($command, $statement->getCommand()); |
|
16 | + $this->assertSame($data, $statement->getData()); |
|
17 | + } |
|
18 | + |
|
19 | + /** |
|
20 | + * Test if the statement matches the expected values |
|
21 | + * @param array[] $expected |
|
22 | + * @param SwaggerGen\Parser\Php\Statement[] $statements |
|
23 | + */ |
|
24 | + private function assertStatements(array $expected, array $statements) |
|
25 | + { |
|
26 | + $this->assertCount(count($expected), $statements, join("\n", $statements)); |
|
27 | + foreach ($expected as $index => $command) { |
|
28 | + $statement = $statements[$index]; |
|
29 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
30 | + $this->assertSame($command[0], $statement->getCommand()); |
|
31 | + $this->assertSame($command[1], $statement->getData()); |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
37 | + */ |
|
38 | + public function testConstructor_Empty() |
|
39 | + { |
|
40 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
41 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
46 | + */ |
|
47 | + public function testConstructor_Dirs() |
|
48 | + { |
|
49 | + $this->markTestIncomplete('Not yet implemented.'); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @covers \SwaggerGen\Parser\Php\Parser::addDirs |
|
54 | + */ |
|
55 | + public function testAddDirs() |
|
56 | + { |
|
57 | + $this->markTestIncomplete('Not yet implemented.'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Test all open-curlies are (ac-)counted for in functions |
|
62 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
63 | + */ |
|
64 | + public function testParse_CurlyBraceFunction() |
|
65 | + { |
|
66 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
67 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
68 | + |
|
69 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CurlyBraceFunction.php'); |
|
70 | + $this->assertCount(6, $statements); |
|
71 | + $this->assertStatement($statements[0], 'title', 'CurlyBraceFunction'); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
76 | + */ |
|
77 | + public function testParse_NoMethods() |
|
78 | + { |
|
79 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
80 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
81 | + |
|
82 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_NoMethods.php'); |
|
83 | + |
|
84 | + $this->assertCount(2, $statements); |
|
85 | + |
|
86 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
87 | + $this->assertStatement($statements[1], 'version', '2'); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
92 | + */ |
|
93 | + public function testParse_WithMethod() |
|
94 | + { |
|
95 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
96 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
97 | + |
|
98 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_WithMethod.php'); |
|
99 | + |
|
100 | + $this->assertCount(4, $statements); |
|
101 | + |
|
102 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
103 | + $this->assertStatement($statements[1], 'version', '2'); |
|
104 | + $this->assertStatement($statements[2], 'description', 'some description'); |
|
105 | + $this->assertStatement($statements[3], 'method', 'get something'); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
110 | + */ |
|
111 | + public function testParse_LineContinuation() |
|
112 | + { |
|
113 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
114 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
115 | + |
|
116 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_LineContinuation.php'); |
|
117 | + |
|
118 | + $this->assertCount(2, $statements); |
|
119 | + |
|
120 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
121 | + $this->assertStatement($statements[1], 'description', 'About this strange little class'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
126 | + */ |
|
127 | + public function testParse_InClass() |
|
128 | + { |
|
129 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
130 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
131 | + |
|
132 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InClass.php'); |
|
133 | + |
|
134 | + $this->assertCount(3, $statements); |
|
135 | + |
|
136 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
137 | + $this->assertStatement($statements[1], 'description', 'Some description'); |
|
138 | + $this->assertStatement($statements[2], 'license', 'mit'); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
143 | + */ |
|
144 | + public function testParse_CommentsTypes() |
|
145 | + { |
|
146 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
147 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
148 | + |
|
149 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CommentsTypes.php'); |
|
150 | + |
|
151 | + $this->assertCount(3, $statements); |
|
152 | + |
|
153 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
154 | + $this->assertStatement($statements[1], 'version', '2'); |
|
155 | + $this->assertStatement($statements[2], 'license', 'mit'); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
160 | + */ |
|
161 | + public function testParse_MethodNonDoc() |
|
162 | + { |
|
163 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
164 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
165 | + |
|
166 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_MethodNonDoc.php'); |
|
167 | + |
|
168 | + $this->assertCount(3, $statements); |
|
169 | + |
|
170 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
171 | + $this->assertStatement($statements[1], 'version', '2'); |
|
172 | + $this->assertStatement($statements[2], 'method', 'get something'); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
177 | + */ |
|
178 | + public function testParse_InMethod() |
|
179 | + { |
|
180 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
181 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
182 | + |
|
183 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InMethod.php'); |
|
184 | + |
|
185 | + $this->assertCount(4, $statements); |
|
186 | + |
|
187 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
188 | + $this->assertStatement($statements[1], 'version', '2'); |
|
189 | + $this->assertStatement($statements[2], 'description', 'some description'); |
|
190 | + $this->assertStatement($statements[3], 'method', 'get something'); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
195 | + */ |
|
196 | + public function testParse_AfterClass() |
|
197 | + { |
|
198 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
199 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
200 | + |
|
201 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_AfterClass.php'); |
|
202 | + |
|
203 | + $this->assertCount(2, $statements); |
|
204 | + |
|
205 | + $this->assertStatement($statements[0], 'license', 'mit'); |
|
206 | + $this->assertStatement($statements[1], 'title', 'Some words'); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
211 | + */ |
|
212 | + public function testParse_Prefix() |
|
213 | + { |
|
214 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
215 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
216 | + |
|
217 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Prefix.php'); |
|
218 | + |
|
219 | + $this->assertCount(1, $statements); |
|
220 | + |
|
221 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | + */ |
|
227 | + public function testParse_PropertyReadOnly() |
|
228 | + { |
|
229 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | + |
|
232 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | + |
|
234 | + $this->assertCount(4, $statements); |
|
235 | + |
|
236 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | + $this->assertStatement($statements[1], 'version', '2'); |
|
238 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | + $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | + */ |
|
245 | + public function testParse_PropertyOptional() |
|
246 | + { |
|
247 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | + |
|
250 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | + |
|
252 | + $this->assertCount(4, $statements); |
|
253 | + |
|
254 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | + $this->assertStatement($statements[1], 'version', '2'); |
|
256 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | + $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
262 | + */ |
|
263 | + public function testParse_Minimal() |
|
264 | + { |
|
265 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
266 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
267 | + |
|
268 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Minimal.php'); |
|
269 | + |
|
270 | + $this->assertCount(4, $statements); |
|
271 | + |
|
272 | + $this->assertStatement($statements[0], 'title', 'Minimal'); |
|
273 | + $this->assertStatement($statements[1], 'api', 'MyApi Example'); |
|
274 | + $this->assertStatement($statements[2], 'endpoint', '/endpoint'); |
|
275 | + $this->assertStatement($statements[3], 'method', 'GET Something'); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Tests FunctionName |
|
280 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
281 | + */ |
|
282 | + public function testParse_SeeFunction() |
|
283 | + { |
|
284 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
285 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
286 | + |
|
287 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeFunction.php'); |
|
288 | + |
|
289 | + $this->assertStatements(array( |
|
290 | + array('api', 'MyApi Example'), |
|
291 | + array('endpoint', '/endpoint'), |
|
292 | + array('method', 'GET Something'), |
|
293 | + array('error', '400'), |
|
294 | + ), $statements); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Tests $this->MethodName |
|
299 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
300 | + */ |
|
301 | + public function testParse_SeeThisMethod() |
|
302 | + { |
|
303 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
304 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
305 | + |
|
306 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeThisMethod.php'); |
|
307 | + |
|
308 | + $this->assertStatements(array( |
|
309 | + array('api', 'MyApi Example'), |
|
310 | + array('endpoint', '/endpoint'), |
|
311 | + array('method', 'GET Something'), |
|
312 | + array('error', '400'), |
|
313 | + ), $statements); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Tests Class->MethodName |
|
318 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
319 | + */ |
|
320 | + public function testParse_SeeObjectMethod() |
|
321 | + { |
|
322 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
323 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
324 | + |
|
325 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeObjectMethod.php'); |
|
326 | + |
|
327 | + $this->assertStatements(array( |
|
328 | + array('api', 'MyApi Example'), |
|
329 | + array('endpoint', '/endpoint'), |
|
330 | + array('method', 'GET Something'), |
|
331 | + array('error', '400'), |
|
332 | + ), $statements); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Tests self::MethodName |
|
337 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
338 | + */ |
|
339 | + public function testParse_SeeSelfMethod() |
|
340 | + { |
|
341 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
342 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
343 | + |
|
344 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeSelfMethod.php'); |
|
345 | + |
|
346 | + $this->assertStatements(array( |
|
347 | + array('api', 'MyApi Example'), |
|
348 | + array('endpoint', '/endpoint'), |
|
349 | + array('method', 'GET Something'), |
|
350 | + array('error', '400'), |
|
351 | + ), $statements); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Tests Class::MethodName |
|
356 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
357 | + */ |
|
358 | + public function testParse_SeeClassMethod() |
|
359 | + { |
|
360 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
361 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
362 | + |
|
363 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeClassMethod.php'); |
|
364 | + |
|
365 | + $this->assertStatements(array( |
|
366 | + array('api', 'MyApi Example'), |
|
367 | + array('endpoint', '/endpoint'), |
|
368 | + array('method', 'GET Something'), |
|
369 | + array('error', '400'), |
|
370 | + ), $statements); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Tests static::MethodName |
|
375 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
376 | + */ |
|
377 | + public function testParse_StaticMethod() |
|
378 | + { |
|
379 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
380 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
381 | + |
|
382 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_StaticMethod.php'); |
|
383 | + |
|
384 | + $this->assertStatements(array( |
|
385 | + array('api', 'MyApi Example'), |
|
386 | + array('endpoint', '/endpoint'), |
|
387 | + array('method', 'GET Something'), |
|
388 | + array('error', '400'), |
|
389 | + ), $statements); |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Tests $this->MethodName with inheritance |
|
394 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
395 | + */ |
|
396 | + public function testParse_SeeInheritedThisMethod() |
|
397 | + { |
|
398 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
399 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
400 | + |
|
401 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedThisMethod.php'); |
|
402 | + |
|
403 | + $this->assertStatements(array( |
|
404 | + array('api', 'MyApi Example'), |
|
405 | + array('endpoint', '/endpoint'), |
|
406 | + array('method', 'GET Something'), |
|
407 | + array('error', '400'), |
|
408 | + ), $statements); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * Tests Class->MethodName with inheritance |
|
413 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
414 | + */ |
|
415 | + public function testParse_SeeInheritedObjectMethod() |
|
416 | + { |
|
417 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
418 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
419 | + |
|
420 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedObjectMethod.php'); |
|
421 | + |
|
422 | + $this->assertStatements(array( |
|
423 | + array('api', 'MyApi Example'), |
|
424 | + array('endpoint', '/endpoint'), |
|
425 | + array('method', 'GET Something'), |
|
426 | + array('error', '400'), |
|
427 | + ), $statements); |
|
428 | + } |
|
429 | + |
|
430 | + /** |
|
431 | + * Tests Autoloading other class when referenced |
|
432 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
433 | + */ |
|
434 | + public function testParse_Autoload_Parse() |
|
435 | + { |
|
436 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
437 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
438 | + |
|
439 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php', array( |
|
440 | + __DIR__ . '/ParserTest', |
|
441 | + )); |
|
442 | + |
|
443 | + $this->assertStatements(array( |
|
444 | + array('api', 'MyApi Example'), |
|
445 | + array('endpoint', '/endpoint'), |
|
446 | + array('method', 'GET Something'), |
|
447 | + array('error', '400'), |
|
448 | + ), $statements); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Tests Autoloading other class when referenced |
|
453 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
454 | + */ |
|
455 | + public function testParse_Autoload_Construct() |
|
456 | + { |
|
457 | + $object = new \SwaggerGen\Parser\Php\Parser(array( |
|
458 | + __DIR__ . '/ParserTest', |
|
459 | + )); |
|
460 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
461 | + |
|
462 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
463 | + |
|
464 | + $this->assertStatements(array( |
|
465 | + array('api', 'MyApi Example'), |
|
466 | + array('endpoint', '/endpoint'), |
|
467 | + array('method', 'GET Something'), |
|
468 | + array('error', '400'), |
|
469 | + ), $statements); |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Tests Autoloading other class when referenced |
|
474 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
475 | + */ |
|
476 | + public function testParse_Autoload_AddDirs() |
|
477 | + { |
|
478 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
479 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
480 | + |
|
481 | + $object->addDirs(array( |
|
482 | + __DIR__ . '/ParserTest', |
|
483 | + )); |
|
484 | + |
|
485 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
486 | + |
|
487 | + $this->assertStatements(array( |
|
488 | + array('api', 'MyApi Example'), |
|
489 | + array('endpoint', '/endpoint'), |
|
490 | + array('method', 'GET Something'), |
|
491 | + array('error', '400'), |
|
492 | + ), $statements); |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
497 | + */ |
|
498 | + public function testParse_XTag() |
|
499 | + { |
|
500 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
501 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
502 | + |
|
503 | + $object->addDirs(array( |
|
504 | + __DIR__ . '/ParserTest', |
|
505 | + )); |
|
506 | + |
|
507 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_XTag.php'); |
|
508 | + |
|
509 | + $this->assertStatements(array( |
|
510 | + array('api', 'MyApi Example'), |
|
511 | + array('endpoint', '/endpoint'), |
|
512 | + array('x-something', 'else'), |
|
513 | + array('method', 'GET Something'), |
|
514 | + ), $statements); |
|
515 | + } |
|
516 | 516 | |
517 | 517 | } |
@@ -3,42 +3,42 @@ discard block |
||
3 | 3 | class PreprocessorTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
8 | - */ |
|
9 | - public function testConstructor_Empty() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
12 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
17 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::getPrefix |
|
18 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::setPrefix |
|
19 | - */ |
|
20 | - public function testConstructor_Prefix() |
|
21 | - { |
|
22 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
23 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
24 | - $this->assertEquals('rest', $object->getPrefix()); |
|
25 | - |
|
26 | - $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
27 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
28 | - $this->assertEquals('foo', $object->getPrefix()); |
|
29 | - |
|
30 | - $object->setPrefix('bar'); |
|
31 | - $this->assertEquals('bar', $object->getPrefix()); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
36 | - */ |
|
37 | - public function testPreprocess_Ifdef_NotDefined() |
|
38 | - { |
|
39 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
40 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
41 | - $out = $object->preprocess('<?php |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
8 | + */ |
|
9 | + public function testConstructor_Empty() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
12 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
17 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::getPrefix |
|
18 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::setPrefix |
|
19 | + */ |
|
20 | + public function testConstructor_Prefix() |
|
21 | + { |
|
22 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
23 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
24 | + $this->assertEquals('rest', $object->getPrefix()); |
|
25 | + |
|
26 | + $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
27 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
28 | + $this->assertEquals('foo', $object->getPrefix()); |
|
29 | + |
|
30 | + $object->setPrefix('bar'); |
|
31 | + $this->assertEquals('bar', $object->getPrefix()); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
36 | + */ |
|
37 | + public function testPreprocess_Ifdef_NotDefined() |
|
38 | + { |
|
39 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
40 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
41 | + $out = $object->preprocess('<?php |
|
42 | 42 | /** |
43 | 43 | * @rest\ifdef test |
44 | 44 | * @rest\whatever |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | */ |
47 | 47 | '); |
48 | 48 | |
49 | - $this->assertEquals('<?php |
|
49 | + $this->assertEquals('<?php |
|
50 | 50 | /** |
51 | 51 | * @!rest\ifdef test |
52 | 52 | * @!rest\whatever |
53 | 53 | * @!rest\endif |
54 | 54 | */ |
55 | 55 | ', $out); |
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
60 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
61 | - */ |
|
62 | - public function testPreprocess_Ifdef_Defined() |
|
63 | - { |
|
64 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
65 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
66 | - $object->define('test'); |
|
67 | - $out = $object->preprocess('<?php |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
60 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
61 | + */ |
|
62 | + public function testPreprocess_Ifdef_Defined() |
|
63 | + { |
|
64 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
65 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
66 | + $object->define('test'); |
|
67 | + $out = $object->preprocess('<?php |
|
68 | 68 | /** |
69 | 69 | * @rest\ifdef test |
70 | 70 | * @rest\whatever |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | */ |
73 | 73 | '); |
74 | 74 | |
75 | - $this->assertEquals('<?php |
|
75 | + $this->assertEquals('<?php |
|
76 | 76 | /** |
77 | 77 | * @!rest\ifdef test |
78 | 78 | * @rest\whatever |
79 | 79 | * @!rest\endif |
80 | 80 | */ |
81 | 81 | ', $out); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
86 | - */ |
|
87 | - public function testPreprocess_Ifndef_NotDefined() |
|
88 | - { |
|
89 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
90 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
91 | - $out = $object->preprocess('<?php |
|
84 | + /** |
|
85 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
86 | + */ |
|
87 | + public function testPreprocess_Ifndef_NotDefined() |
|
88 | + { |
|
89 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
90 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
91 | + $out = $object->preprocess('<?php |
|
92 | 92 | /** |
93 | 93 | * @rest\ifndef test |
94 | 94 | * @rest\whatever |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | '); |
98 | 98 | |
99 | - $this->assertEquals('<?php |
|
99 | + $this->assertEquals('<?php |
|
100 | 100 | /** |
101 | 101 | * @!rest\ifndef test |
102 | 102 | * @rest\whatever |
103 | 103 | * @!rest\endif |
104 | 104 | */ |
105 | 105 | ', $out); |
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
110 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
111 | - */ |
|
112 | - public function testPreprocess_Ifndef_Defined() |
|
113 | - { |
|
114 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
115 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
116 | - $object->define('test'); |
|
117 | - $out = $object->preprocess('<?php |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
110 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
111 | + */ |
|
112 | + public function testPreprocess_Ifndef_Defined() |
|
113 | + { |
|
114 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
115 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
116 | + $object->define('test'); |
|
117 | + $out = $object->preprocess('<?php |
|
118 | 118 | /** |
119 | 119 | * @rest\ifndef test |
120 | 120 | * @rest\whatever |
@@ -122,23 +122,23 @@ discard block |
||
122 | 122 | */ |
123 | 123 | '); |
124 | 124 | |
125 | - $this->assertEquals('<?php |
|
125 | + $this->assertEquals('<?php |
|
126 | 126 | /** |
127 | 127 | * @!rest\ifndef test |
128 | 128 | * @!rest\whatever |
129 | 129 | * @!rest\endif |
130 | 130 | */ |
131 | 131 | ', $out); |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
136 | - */ |
|
137 | - public function testPreprocess_Define() |
|
138 | - { |
|
139 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
140 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
141 | - $out = $object->preprocess('<?php |
|
134 | + /** |
|
135 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
136 | + */ |
|
137 | + public function testPreprocess_Define() |
|
138 | + { |
|
139 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
140 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
141 | + $out = $object->preprocess('<?php |
|
142 | 142 | /** |
143 | 143 | * @rest\define test |
144 | 144 | * @rest\ifndef test |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | '); |
149 | 149 | |
150 | - $this->assertEquals('<?php |
|
150 | + $this->assertEquals('<?php |
|
151 | 151 | /** |
152 | 152 | * @!rest\define test |
153 | 153 | * @!rest\ifndef test |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @!rest\endif |
156 | 156 | */ |
157 | 157 | ', $out); |
158 | - } |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
162 | - */ |
|
163 | - public function testPreprocess_Undef() |
|
164 | - { |
|
165 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
166 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
167 | - $out = $object->preprocess('<?php |
|
160 | + /** |
|
161 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
162 | + */ |
|
163 | + public function testPreprocess_Undef() |
|
164 | + { |
|
165 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
166 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
167 | + $out = $object->preprocess('<?php |
|
168 | 168 | /** |
169 | 169 | * @rest\define test |
170 | 170 | * @rest\undef test |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | '); |
176 | 176 | |
177 | - $this->assertEquals('<?php |
|
177 | + $this->assertEquals('<?php |
|
178 | 178 | /** |
179 | 179 | * @!rest\define test |
180 | 180 | * @!rest\undef test |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * @!rest\endif |
184 | 184 | */ |
185 | 185 | ', $out); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
190 | - */ |
|
191 | - public function testPreprocess_If_NotDefined() |
|
192 | - { |
|
193 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
194 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
195 | - $out = $object->preprocess('<?php |
|
188 | + /** |
|
189 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
190 | + */ |
|
191 | + public function testPreprocess_If_NotDefined() |
|
192 | + { |
|
193 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
194 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
195 | + $out = $object->preprocess('<?php |
|
196 | 196 | /** |
197 | 197 | * @rest\if test red |
198 | 198 | * @rest\whatever |
@@ -200,25 +200,25 @@ discard block |
||
200 | 200 | */ |
201 | 201 | '); |
202 | 202 | |
203 | - $this->assertEquals('<?php |
|
203 | + $this->assertEquals('<?php |
|
204 | 204 | /** |
205 | 205 | * @!rest\if test red |
206 | 206 | * @!rest\whatever |
207 | 207 | * @!rest\endif |
208 | 208 | */ |
209 | 209 | ', $out); |
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
214 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
215 | - */ |
|
216 | - public function testPreprocess_If_AnyValue() |
|
217 | - { |
|
218 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
219 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
220 | - $object->define('test', 'green'); |
|
221 | - $out = $object->preprocess('<?php |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
214 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
215 | + */ |
|
216 | + public function testPreprocess_If_AnyValue() |
|
217 | + { |
|
218 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
219 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
220 | + $object->define('test', 'green'); |
|
221 | + $out = $object->preprocess('<?php |
|
222 | 222 | /** |
223 | 223 | * @rest\if test |
224 | 224 | * @rest\whatever |
@@ -226,25 +226,25 @@ discard block |
||
226 | 226 | */ |
227 | 227 | '); |
228 | 228 | |
229 | - $this->assertEquals('<?php |
|
229 | + $this->assertEquals('<?php |
|
230 | 230 | /** |
231 | 231 | * @!rest\if test |
232 | 232 | * @rest\whatever |
233 | 233 | * @!rest\endif |
234 | 234 | */ |
235 | 235 | ', $out); |
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
240 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
241 | - */ |
|
242 | - public function testPreprocess_If_NoValue() |
|
243 | - { |
|
244 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
245 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
246 | - $object->define('test'); |
|
247 | - $out = $object->preprocess('<?php |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
240 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
241 | + */ |
|
242 | + public function testPreprocess_If_NoValue() |
|
243 | + { |
|
244 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
245 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
246 | + $object->define('test'); |
|
247 | + $out = $object->preprocess('<?php |
|
248 | 248 | /** |
249 | 249 | * @rest\if test red |
250 | 250 | * @rest\whatever |
@@ -252,25 +252,25 @@ discard block |
||
252 | 252 | */ |
253 | 253 | '); |
254 | 254 | |
255 | - $this->assertEquals('<?php |
|
255 | + $this->assertEquals('<?php |
|
256 | 256 | /** |
257 | 257 | * @!rest\if test red |
258 | 258 | * @!rest\whatever |
259 | 259 | * @!rest\endif |
260 | 260 | */ |
261 | 261 | ', $out); |
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
266 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
267 | - */ |
|
268 | - public function testPreprocess_If_Mismatch() |
|
269 | - { |
|
270 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
271 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
272 | - $object->define('test', 'green'); |
|
273 | - $out = $object->preprocess('<?php |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
266 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
267 | + */ |
|
268 | + public function testPreprocess_If_Mismatch() |
|
269 | + { |
|
270 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
271 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
272 | + $object->define('test', 'green'); |
|
273 | + $out = $object->preprocess('<?php |
|
274 | 274 | /** |
275 | 275 | * @rest\if test red |
276 | 276 | * @rest\whatever |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | */ |
279 | 279 | '); |
280 | 280 | |
281 | - $this->assertEquals('<?php |
|
281 | + $this->assertEquals('<?php |
|
282 | 282 | /** |
283 | 283 | * @!rest\if test red |
284 | 284 | * @!rest\whatever |
285 | 285 | * @!rest\endif |
286 | 286 | */ |
287 | 287 | ', $out); |
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
292 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
293 | - */ |
|
294 | - public function testPreprocess_If_Match() |
|
295 | - { |
|
296 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
297 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
298 | - $object->define('test', 'red'); |
|
299 | - $out = $object->preprocess('<?php |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
292 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
293 | + */ |
|
294 | + public function testPreprocess_If_Match() |
|
295 | + { |
|
296 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
297 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
298 | + $object->define('test', 'red'); |
|
299 | + $out = $object->preprocess('<?php |
|
300 | 300 | /** |
301 | 301 | * @rest\if test red |
302 | 302 | * @rest\whatever |
@@ -304,25 +304,25 @@ discard block |
||
304 | 304 | */ |
305 | 305 | '); |
306 | 306 | |
307 | - $this->assertEquals('<?php |
|
307 | + $this->assertEquals('<?php |
|
308 | 308 | /** |
309 | 309 | * @!rest\if test red |
310 | 310 | * @rest\whatever |
311 | 311 | * @!rest\endif |
312 | 312 | */ |
313 | 313 | ', $out); |
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
318 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
319 | - */ |
|
320 | - public function testPreprocess_Else_Match() |
|
321 | - { |
|
322 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
323 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
324 | - $object->define('test', 'blue'); |
|
325 | - $out = $object->preprocess('<?php |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
318 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
319 | + */ |
|
320 | + public function testPreprocess_Else_Match() |
|
321 | + { |
|
322 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
323 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
324 | + $object->define('test', 'blue'); |
|
325 | + $out = $object->preprocess('<?php |
|
326 | 326 | /** |
327 | 327 | * @rest\if test red |
328 | 328 | * @rest\whatever |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | '); |
334 | 334 | |
335 | - $this->assertEquals('<?php |
|
335 | + $this->assertEquals('<?php |
|
336 | 336 | /** |
337 | 337 | * @!rest\if test red |
338 | 338 | * @!rest\whatever |
@@ -341,18 +341,18 @@ discard block |
||
341 | 341 | * @!rest\endif |
342 | 342 | */ |
343 | 343 | ', $out); |
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
348 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
349 | - */ |
|
350 | - public function testPreprocess_Elif_Match() |
|
351 | - { |
|
352 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
353 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
354 | - $object->define('test', 'blue'); |
|
355 | - $out = $object->preprocess('<?php |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
348 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
349 | + */ |
|
350 | + public function testPreprocess_Elif_Match() |
|
351 | + { |
|
352 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
353 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
354 | + $object->define('test', 'blue'); |
|
355 | + $out = $object->preprocess('<?php |
|
356 | 356 | /** |
357 | 357 | * @rest\if test red |
358 | 358 | * @rest\whatever |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | '); |
366 | 366 | |
367 | - $this->assertEquals('<?php |
|
367 | + $this->assertEquals('<?php |
|
368 | 368 | /** |
369 | 369 | * @!rest\if test red |
370 | 370 | * @!rest\whatever |
@@ -375,18 +375,18 @@ discard block |
||
375 | 375 | * @!rest\endif |
376 | 376 | */ |
377 | 377 | ', $out); |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
382 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
383 | - */ |
|
384 | - public function testPreprocess_Elif_NoValue() |
|
385 | - { |
|
386 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
387 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
388 | - $object->define('test', 'blue'); |
|
389 | - $out = $object->preprocess('<?php |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
382 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
383 | + */ |
|
384 | + public function testPreprocess_Elif_NoValue() |
|
385 | + { |
|
386 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
387 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
388 | + $object->define('test', 'blue'); |
|
389 | + $out = $object->preprocess('<?php |
|
390 | 390 | /** |
391 | 391 | * @rest\if test red |
392 | 392 | * @rest\whatever |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | '); |
400 | 400 | |
401 | - $this->assertEquals('<?php |
|
401 | + $this->assertEquals('<?php |
|
402 | 402 | /** |
403 | 403 | * @!rest\if test red |
404 | 404 | * @!rest\whatever |
@@ -409,16 +409,16 @@ discard block |
||
409 | 409 | * @!rest\endif |
410 | 410 | */ |
411 | 411 | ', $out); |
412 | - } |
|
412 | + } |
|
413 | 413 | |
414 | - /** |
|
415 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
416 | - */ |
|
417 | - public function testPreprocess_Ifdef_AffectPrefixedOnly() |
|
418 | - { |
|
419 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
420 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
421 | - $out = $object->preprocess('<?php |
|
414 | + /** |
|
415 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
416 | + */ |
|
417 | + public function testPreprocess_Ifdef_AffectPrefixedOnly() |
|
418 | + { |
|
419 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
420 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
421 | + $out = $object->preprocess('<?php |
|
422 | 422 | /** |
423 | 423 | * @rest\ifdef test |
424 | 424 | * @rest\whatever |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | '); |
431 | 431 | |
432 | - $this->assertEquals('<?php |
|
432 | + $this->assertEquals('<?php |
|
433 | 433 | /** |
434 | 434 | * @!rest\ifdef test |
435 | 435 | * @!rest\whatever |
@@ -439,20 +439,20 @@ discard block |
||
439 | 439 | * @!rest\endif |
440 | 440 | */ |
441 | 441 | ', $out); |
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
446 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::undefine |
|
447 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
448 | - */ |
|
449 | - public function testPreprocess_Undefine() |
|
450 | - { |
|
451 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
452 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
453 | - $object->define('test'); |
|
454 | - $object->undefine('test'); |
|
455 | - $out = $object->preprocess('<?php |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
446 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::undefine |
|
447 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
448 | + */ |
|
449 | + public function testPreprocess_Undefine() |
|
450 | + { |
|
451 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
452 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
453 | + $object->define('test'); |
|
454 | + $object->undefine('test'); |
|
455 | + $out = $object->preprocess('<?php |
|
456 | 456 | /** |
457 | 457 | * @rest\ifdef test |
458 | 458 | * @rest\whatever |
@@ -460,27 +460,27 @@ discard block |
||
460 | 460 | */ |
461 | 461 | '); |
462 | 462 | |
463 | - $this->assertEquals('<?php |
|
463 | + $this->assertEquals('<?php |
|
464 | 464 | /** |
465 | 465 | * @!rest\ifdef test |
466 | 466 | * @!rest\whatever |
467 | 467 | * @!rest\endif |
468 | 468 | */ |
469 | 469 | ', $out); |
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
474 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::resetDefines |
|
475 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
476 | - */ |
|
477 | - public function testPreprocess_ResetDefines() |
|
478 | - { |
|
479 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
480 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
481 | - $object->define('test'); |
|
482 | - $object->resetDefines(); |
|
483 | - $out = $object->preprocess('<?php |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
474 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::resetDefines |
|
475 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
476 | + */ |
|
477 | + public function testPreprocess_ResetDefines() |
|
478 | + { |
|
479 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
480 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
481 | + $object->define('test'); |
|
482 | + $object->resetDefines(); |
|
483 | + $out = $object->preprocess('<?php |
|
484 | 484 | /** |
485 | 485 | * @rest\ifdef test |
486 | 486 | * @rest\whatever |
@@ -488,25 +488,25 @@ discard block |
||
488 | 488 | */ |
489 | 489 | '); |
490 | 490 | |
491 | - $this->assertEquals('<?php |
|
491 | + $this->assertEquals('<?php |
|
492 | 492 | /** |
493 | 493 | * @!rest\ifdef test |
494 | 494 | * @!rest\whatever |
495 | 495 | * @!rest\endif |
496 | 496 | */ |
497 | 497 | ', $out); |
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::addDefines |
|
502 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
503 | - */ |
|
504 | - public function testPreprocess_AddDefines() |
|
505 | - { |
|
506 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
507 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
508 | - $object->addDefines(array('test' => true)); |
|
509 | - $out = $object->preprocess('<?php |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::addDefines |
|
502 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
503 | + */ |
|
504 | + public function testPreprocess_AddDefines() |
|
505 | + { |
|
506 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
507 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
508 | + $object->addDefines(array('test' => true)); |
|
509 | + $out = $object->preprocess('<?php |
|
510 | 510 | /** |
511 | 511 | * @rest\ifdef test |
512 | 512 | * @rest\whatever |
@@ -514,23 +514,23 @@ discard block |
||
514 | 514 | */ |
515 | 515 | '); |
516 | 516 | |
517 | - $this->assertEquals('<?php |
|
517 | + $this->assertEquals('<?php |
|
518 | 518 | /** |
519 | 519 | * @!rest\ifdef test |
520 | 520 | * @rest\whatever |
521 | 521 | * @!rest\endif |
522 | 522 | */ |
523 | 523 | ', $out); |
524 | - } |
|
524 | + } |
|
525 | 525 | |
526 | - /** |
|
527 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
528 | - */ |
|
529 | - public function testPreprocess_AlternativePrefix() |
|
530 | - { |
|
531 | - $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
532 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
533 | - $out = $object->preprocess('<?php |
|
526 | + /** |
|
527 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
528 | + */ |
|
529 | + public function testPreprocess_AlternativePrefix() |
|
530 | + { |
|
531 | + $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
532 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
533 | + $out = $object->preprocess('<?php |
|
534 | 534 | /** |
535 | 535 | * @foo\ifdef test |
536 | 536 | * @foo\whatever |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | '); |
541 | 541 | |
542 | - $this->assertEquals('<?php |
|
542 | + $this->assertEquals('<?php |
|
543 | 543 | /** |
544 | 544 | * @!foo\ifdef test |
545 | 545 | * @!foo\whatever |
@@ -547,31 +547,31 @@ discard block |
||
547 | 547 | * @!foo\endif |
548 | 548 | */ |
549 | 549 | ', $out); |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | - /** |
|
553 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
554 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocessFile |
|
555 | - */ |
|
556 | - public function testPreprocessFile() |
|
557 | - { |
|
558 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
559 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
560 | - $object->define('test'); |
|
552 | + /** |
|
553 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
554 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocessFile |
|
555 | + */ |
|
556 | + public function testPreprocessFile() |
|
557 | + { |
|
558 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
559 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
560 | + $object->define('test'); |
|
561 | 561 | |
562 | - $out = $object->preprocessFile(__DIR__ . '/PreprocessorTest/testPreprocessFile.php'); |
|
562 | + $out = $object->preprocessFile(__DIR__ . '/PreprocessorTest/testPreprocessFile.php'); |
|
563 | 563 | |
564 | - $this->assertEquals('<?php |
|
564 | + $this->assertEquals('<?php |
|
565 | 565 | |
566 | 566 | /** |
567 | 567 | * @!rest\ifdef test |
568 | 568 | * @rest\whatever |
569 | 569 | * @!rest\endif |
570 | 570 | */', $out); |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | - //@todo preprocess($content) -> mingle with other PHP code |
|
574 | - //@todo preprocess($content) -> Condition within comment |
|
575 | - //@todo preprocess($content) -> Condition over comments |
|
576 | - //@todo preprocess($content) -> Condition over code |
|
573 | + //@todo preprocess($content) -> mingle with other PHP code |
|
574 | + //@todo preprocess($content) -> Condition within comment |
|
575 | + //@todo preprocess($content) -> Condition over comments |
|
576 | + //@todo preprocess($content) -> Condition over code |
|
577 | 577 | } |
@@ -5,191 +5,191 @@ |
||
5 | 5 | class ParserTest extends \SwaggerGen_TestCase |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @covers \SwaggerGen\Parser\Text\Parser::__construct |
|
10 | - */ |
|
11 | - public function testConstructor_Empty() |
|
12 | - { |
|
13 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
14 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
15 | - } |
|
16 | - |
|
17 | - /** |
|
18 | - * @covers \SwaggerGen\Parser\Text\Parser::__construct |
|
19 | - */ |
|
20 | - public function testConstructor_Dirs() |
|
21 | - { |
|
22 | - $this->markTestIncomplete('Not yet implemented.'); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @covers \SwaggerGen\Parser\Text\Parser::addDirs |
|
27 | - */ |
|
28 | - public function testAddDirs() |
|
29 | - { |
|
30 | - $this->markTestIncomplete('Not yet implemented.'); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
35 | - */ |
|
36 | - public function testParseText() |
|
37 | - { |
|
38 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
39 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
40 | - |
|
41 | - $statements = $object->parseText('title Some words'); |
|
42 | - |
|
43 | - $this->assertCount(1, $statements); |
|
44 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
45 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
46 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
51 | - */ |
|
52 | - public function testParseText_Whitespace() |
|
53 | - { |
|
54 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
55 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
56 | - |
|
57 | - $statements = $object->parseText(" \t title \t\t Some words \t "); |
|
58 | - |
|
59 | - $this->assertCount(1, $statements); |
|
60 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
61 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
62 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
67 | - */ |
|
68 | - public function testParseText_Multiple_LF() |
|
69 | - { |
|
70 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
71 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
72 | - |
|
73 | - $statements = $object->parseText("title Some words\nSome Random words"); |
|
74 | - |
|
75 | - $this->assertCount(2, $statements); |
|
76 | - |
|
77 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
78 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
79 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
80 | - |
|
81 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
82 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
83 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
88 | - */ |
|
89 | - public function testParseText_Multiple_CR() |
|
90 | - { |
|
91 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
92 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
93 | - |
|
94 | - $statements = $object->parseText("title Some words\rSome Random words"); |
|
95 | - |
|
96 | - $this->assertCount(2, $statements); |
|
97 | - |
|
98 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
99 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
100 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
101 | - |
|
102 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
103 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
104 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
109 | - */ |
|
110 | - public function testParseText_Multiple_CRLF() |
|
111 | - { |
|
112 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
113 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
114 | - |
|
115 | - $statements = $object->parseText("title Some words\r\nSome Random words"); |
|
116 | - |
|
117 | - $this->assertCount(2, $statements); |
|
118 | - |
|
119 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
120 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
121 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
122 | - |
|
123 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
124 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
125 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
130 | - */ |
|
131 | - public function testParseText_Multiple_BlankLines() |
|
132 | - { |
|
133 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
134 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
135 | - |
|
136 | - $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words"); |
|
137 | - |
|
138 | - $this->assertCount(2, $statements); |
|
139 | - |
|
140 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
141 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
142 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
143 | - |
|
144 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
145 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
146 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
151 | - */ |
|
152 | - public function testParseText_Dirs() |
|
153 | - { |
|
154 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
155 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
156 | - |
|
157 | - $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words", array( |
|
158 | - __DIR__ . '/ParserTest/not used by text parser', |
|
159 | - )); |
|
160 | - |
|
161 | - $this->assertCount(2, $statements); |
|
162 | - |
|
163 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
164 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
165 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
166 | - |
|
167 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
168 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
169 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @covers \SwaggerGen\Parser\Text\Parser::parse |
|
174 | - */ |
|
175 | - public function testParse() |
|
176 | - { |
|
177 | - $object = new \SwaggerGen\Parser\Text\Parser(); |
|
178 | - $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
179 | - |
|
180 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse.txt', array( |
|
181 | - __DIR__ . '/ParserTest/not used by text parser', |
|
182 | - )); |
|
183 | - |
|
184 | - $this->assertCount(2, $statements); |
|
185 | - |
|
186 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
187 | - $this->assertSame('title', $statements[0]->getCommand()); |
|
188 | - $this->assertSame('Some words', $statements[0]->getData()); |
|
189 | - |
|
190 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
191 | - $this->assertSame('Some', $statements[1]->getCommand()); |
|
192 | - $this->assertSame('Random words', $statements[1]->getData()); |
|
193 | - } |
|
8 | + /** |
|
9 | + * @covers \SwaggerGen\Parser\Text\Parser::__construct |
|
10 | + */ |
|
11 | + public function testConstructor_Empty() |
|
12 | + { |
|
13 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
14 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
15 | + } |
|
16 | + |
|
17 | + /** |
|
18 | + * @covers \SwaggerGen\Parser\Text\Parser::__construct |
|
19 | + */ |
|
20 | + public function testConstructor_Dirs() |
|
21 | + { |
|
22 | + $this->markTestIncomplete('Not yet implemented.'); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @covers \SwaggerGen\Parser\Text\Parser::addDirs |
|
27 | + */ |
|
28 | + public function testAddDirs() |
|
29 | + { |
|
30 | + $this->markTestIncomplete('Not yet implemented.'); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
35 | + */ |
|
36 | + public function testParseText() |
|
37 | + { |
|
38 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
39 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
40 | + |
|
41 | + $statements = $object->parseText('title Some words'); |
|
42 | + |
|
43 | + $this->assertCount(1, $statements); |
|
44 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
45 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
46 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
51 | + */ |
|
52 | + public function testParseText_Whitespace() |
|
53 | + { |
|
54 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
55 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
56 | + |
|
57 | + $statements = $object->parseText(" \t title \t\t Some words \t "); |
|
58 | + |
|
59 | + $this->assertCount(1, $statements); |
|
60 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
61 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
62 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
67 | + */ |
|
68 | + public function testParseText_Multiple_LF() |
|
69 | + { |
|
70 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
71 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
72 | + |
|
73 | + $statements = $object->parseText("title Some words\nSome Random words"); |
|
74 | + |
|
75 | + $this->assertCount(2, $statements); |
|
76 | + |
|
77 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
78 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
79 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
80 | + |
|
81 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
82 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
83 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
88 | + */ |
|
89 | + public function testParseText_Multiple_CR() |
|
90 | + { |
|
91 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
92 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
93 | + |
|
94 | + $statements = $object->parseText("title Some words\rSome Random words"); |
|
95 | + |
|
96 | + $this->assertCount(2, $statements); |
|
97 | + |
|
98 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
99 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
100 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
101 | + |
|
102 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
103 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
104 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
109 | + */ |
|
110 | + public function testParseText_Multiple_CRLF() |
|
111 | + { |
|
112 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
113 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
114 | + |
|
115 | + $statements = $object->parseText("title Some words\r\nSome Random words"); |
|
116 | + |
|
117 | + $this->assertCount(2, $statements); |
|
118 | + |
|
119 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
120 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
121 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
122 | + |
|
123 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
124 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
125 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
130 | + */ |
|
131 | + public function testParseText_Multiple_BlankLines() |
|
132 | + { |
|
133 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
134 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
135 | + |
|
136 | + $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words"); |
|
137 | + |
|
138 | + $this->assertCount(2, $statements); |
|
139 | + |
|
140 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
141 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
142 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
143 | + |
|
144 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
145 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
146 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @covers \SwaggerGen\Parser\Text\Parser::parseText |
|
151 | + */ |
|
152 | + public function testParseText_Dirs() |
|
153 | + { |
|
154 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
155 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
156 | + |
|
157 | + $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words", array( |
|
158 | + __DIR__ . '/ParserTest/not used by text parser', |
|
159 | + )); |
|
160 | + |
|
161 | + $this->assertCount(2, $statements); |
|
162 | + |
|
163 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
164 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
165 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
166 | + |
|
167 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
168 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
169 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @covers \SwaggerGen\Parser\Text\Parser::parse |
|
174 | + */ |
|
175 | + public function testParse() |
|
176 | + { |
|
177 | + $object = new \SwaggerGen\Parser\Text\Parser(); |
|
178 | + $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object); |
|
179 | + |
|
180 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse.txt', array( |
|
181 | + __DIR__ . '/ParserTest/not used by text parser', |
|
182 | + )); |
|
183 | + |
|
184 | + $this->assertCount(2, $statements); |
|
185 | + |
|
186 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]); |
|
187 | + $this->assertSame('title', $statements[0]->getCommand()); |
|
188 | + $this->assertSame('Some words', $statements[0]->getData()); |
|
189 | + |
|
190 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]); |
|
191 | + $this->assertSame('Some', $statements[1]->getCommand()); |
|
192 | + $this->assertSame('Random words', $statements[1]->getData()); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | } |
@@ -3,34 +3,34 @@ |
||
3 | 3 | class ExceptionTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Exception::__construct |
|
8 | - */ |
|
9 | - public function testConstructor0() |
|
10 | - { |
|
11 | - $this->expectException('\SwaggerGen\Exception'); |
|
12 | - |
|
13 | - throw new \SwaggerGen\Exception('', 0); |
|
14 | - } |
|
15 | - |
|
16 | - /** |
|
17 | - * @covers \SwaggerGen\Exception::__construct |
|
18 | - */ |
|
19 | - public function testConstructor1() |
|
20 | - { |
|
21 | - $this->expectException('\SwaggerGen\Exception', 'This is a message'); |
|
22 | - |
|
23 | - throw new \SwaggerGen\Exception('This is a message', 0); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @covers \SwaggerGen\Exception::__construct |
|
28 | - */ |
|
29 | - public function testConstructor2() |
|
30 | - { |
|
31 | - $this->expectException('\SwaggerGen\Exception', 'This is a message', 1234); |
|
32 | - |
|
33 | - throw new \SwaggerGen\Exception('This is a message', 1234); |
|
34 | - } |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Exception::__construct |
|
8 | + */ |
|
9 | + public function testConstructor0() |
|
10 | + { |
|
11 | + $this->expectException('\SwaggerGen\Exception'); |
|
12 | + |
|
13 | + throw new \SwaggerGen\Exception('', 0); |
|
14 | + } |
|
15 | + |
|
16 | + /** |
|
17 | + * @covers \SwaggerGen\Exception::__construct |
|
18 | + */ |
|
19 | + public function testConstructor1() |
|
20 | + { |
|
21 | + $this->expectException('\SwaggerGen\Exception', 'This is a message'); |
|
22 | + |
|
23 | + throw new \SwaggerGen\Exception('This is a message', 0); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @covers \SwaggerGen\Exception::__construct |
|
28 | + */ |
|
29 | + public function testConstructor2() |
|
30 | + { |
|
31 | + $this->expectException('\SwaggerGen\Exception', 'This is a message', 1234); |
|
32 | + |
|
33 | + throw new \SwaggerGen\Exception('This is a message', 1234); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
@@ -11,15 +11,15 @@ |
||
11 | 11 | class Example |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @rest\endpoint /endpoint/{listid} |
|
16 | - * @rest\method GET Something |
|
17 | - * @rest\param listid |
|
18 | - * @rest\response 200 |
|
19 | - */ |
|
20 | - public function Dummy() |
|
21 | - { |
|
14 | + /** |
|
15 | + * @rest\endpoint /endpoint/{listid} |
|
16 | + * @rest\method GET Something |
|
17 | + * @rest\param listid |
|
18 | + * @rest\response 200 |
|
19 | + */ |
|
20 | + public function Dummy() |
|
21 | + { |
|
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | 25 | } |