@@ -3,495 +3,495 @@ |
||
3 | 3 | class SecuritySchemeTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
20 | - */ |
|
21 | - public function testConstructor_UnknownType() |
|
22 | - { |
|
23 | - $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'"); |
|
24 | - |
|
25 | - new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong'); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
30 | - */ |
|
31 | - public function testConstructor_Basic() |
|
32 | - { |
|
33 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
34 | - |
|
35 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
36 | - |
|
37 | - $this->assertSame(array( |
|
38 | - 'type' => 'basic', |
|
39 | - ), $object->toArray()); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
44 | - */ |
|
45 | - public function testConstructor_BasicDescription() |
|
46 | - { |
|
47 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text'); |
|
48 | - |
|
49 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
50 | - |
|
51 | - $this->assertSame(array( |
|
52 | - 'type' => 'basic', |
|
53 | - 'description' => 'Some text', |
|
54 | - ), $object->toArray()); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
59 | - */ |
|
60 | - public function testConstructor_ApiKeyNoName() |
|
61 | - { |
|
62 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''" |
|
63 | - ); |
|
64 | - |
|
65 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey'); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
70 | - */ |
|
71 | - public function testConstructor_ApiKeyNoIn() |
|
72 | - { |
|
73 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"); |
|
74 | - |
|
75 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name'); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
80 | - */ |
|
81 | - public function testConstructor_ApiKeyWrongIn() |
|
82 | - { |
|
83 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'"); |
|
84 | - |
|
85 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad'); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
90 | - */ |
|
91 | - public function testConstructor_ApiKey() |
|
92 | - { |
|
93 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query'); |
|
94 | - |
|
95 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
96 | - |
|
97 | - $this->assertSame(array( |
|
98 | - 'type' => 'apiKey', |
|
99 | - 'name' => 'Name', |
|
100 | - 'in' => 'query', |
|
101 | - ), $object->toArray()); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
106 | - */ |
|
107 | - public function testConstructor_ApiKeyDescription() |
|
108 | - { |
|
109 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words'); |
|
110 | - |
|
111 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
112 | - |
|
113 | - $this->assertSame(array( |
|
114 | - 'type' => 'apiKey', |
|
115 | - 'description' => 'Some words', |
|
116 | - 'name' => 'Name', |
|
117 | - 'in' => 'query', |
|
118 | - ), $object->toArray()); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
123 | - */ |
|
124 | - public function testConstructor_Oauth2NoFlow() |
|
125 | - { |
|
126 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''"); |
|
127 | - |
|
128 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2'); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
133 | - */ |
|
134 | - public function testConstructor_Oauth2WrongFlow() |
|
135 | - { |
|
136 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'"); |
|
137 | - |
|
138 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow'); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
143 | - */ |
|
144 | - public function testConstructor_Oauth2ImplicitNoUrl() |
|
145 | - { |
|
146 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
147 | - |
|
148 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit'); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
153 | - */ |
|
154 | - public function testConstructor_Oauth2ImplicitBadUrl() |
|
155 | - { |
|
156 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
157 | - |
|
158 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad'); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
163 | - */ |
|
164 | - public function testConstructor_Oauth2ImplicitUrl() |
|
165 | - { |
|
166 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test'); |
|
167 | - |
|
168 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
169 | - |
|
170 | - $this->assertSame(array( |
|
171 | - 'type' => 'oauth2', |
|
172 | - 'flow' => 'implicit', |
|
173 | - 'authorizationUrl' => 'http://www.test', |
|
174 | - ), $object->toArray()); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
179 | - */ |
|
180 | - public function testConstructor_Oauth2ImplicitUrlDescription() |
|
181 | - { |
|
182 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words'); |
|
183 | - |
|
184 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
185 | - |
|
186 | - $this->assertSame(array( |
|
187 | - 'type' => 'oauth2', |
|
188 | - 'description' => 'Some words', |
|
189 | - 'flow' => 'implicit', |
|
190 | - 'authorizationUrl' => 'http://www.test', |
|
191 | - ), $object->toArray()); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
196 | - */ |
|
197 | - public function testConstructor_Oauth2PasswordNoUrl() |
|
198 | - { |
|
199 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
200 | - |
|
201 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password'); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
206 | - */ |
|
207 | - public function testConstructor_Oauth2PasswordBadUrl() |
|
208 | - { |
|
209 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
210 | - |
|
211 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad'); |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
216 | - */ |
|
217 | - public function testConstructor_Oauth2Password() |
|
218 | - { |
|
219 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test'); |
|
220 | - |
|
221 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
222 | - |
|
223 | - $this->assertSame(array( |
|
224 | - 'type' => 'oauth2', |
|
225 | - 'flow' => 'password', |
|
226 | - 'tokenUrl' => 'http://token.test', |
|
227 | - ), $object->toArray()); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
232 | - */ |
|
233 | - public function testConstructor_Oauth2PasswordDescription() |
|
234 | - { |
|
235 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words'); |
|
236 | - |
|
237 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
238 | - |
|
239 | - $this->assertSame(array( |
|
240 | - 'type' => 'oauth2', |
|
241 | - 'description' => 'Some words', |
|
242 | - 'flow' => 'password', |
|
243 | - 'tokenUrl' => 'http://token.test', |
|
244 | - ), $object->toArray()); |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
249 | - */ |
|
250 | - public function testConstructor_Oauth2ApplicationNoUrl() |
|
251 | - { |
|
252 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
253 | - |
|
254 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application'); |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
259 | - */ |
|
260 | - public function testConstructor_Oauth2ApplicationBadUrl() |
|
261 | - { |
|
262 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
263 | - |
|
264 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad'); |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
269 | - */ |
|
270 | - public function testConstructor_Oauth2Application() |
|
271 | - { |
|
272 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test'); |
|
273 | - |
|
274 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
275 | - |
|
276 | - $this->assertSame(array( |
|
277 | - 'type' => 'oauth2', |
|
278 | - 'flow' => 'application', |
|
279 | - 'tokenUrl' => 'http://token.test', |
|
280 | - ), $object->toArray()); |
|
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
285 | - */ |
|
286 | - public function testConstructor_Oauth2ApplicationDescription() |
|
287 | - { |
|
288 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words'); |
|
289 | - |
|
290 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
291 | - |
|
292 | - $this->assertSame(array( |
|
293 | - 'type' => 'oauth2', |
|
294 | - 'description' => 'Some words', |
|
295 | - 'flow' => 'application', |
|
296 | - 'tokenUrl' => 'http://token.test', |
|
297 | - ), $object->toArray()); |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
303 | - */ |
|
304 | - public function testConstructor_Oauth2AccesscodeNoUrl1() |
|
305 | - { |
|
306 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
307 | - |
|
308 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode'); |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
313 | - */ |
|
314 | - public function testConstructor_Oauth2AccesscodeBadUrl1() |
|
315 | - { |
|
316 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
317 | - |
|
318 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad'); |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
323 | - */ |
|
324 | - public function testConstructor_Oauth2AccesscodeNoUrl2() |
|
325 | - { |
|
326 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
327 | - |
|
328 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test'); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
333 | - */ |
|
334 | - public function testConstructor_Oauth2AccesscodeBadUrl2() |
|
335 | - { |
|
336 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
337 | - |
|
338 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad'); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
343 | - */ |
|
344 | - public function testConstructor_Oauth2Accesscode() |
|
345 | - { |
|
346 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
347 | - |
|
348 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
349 | - |
|
350 | - $this->assertSame(array( |
|
351 | - 'type' => 'oauth2', |
|
352 | - 'flow' => 'accessCode', |
|
353 | - 'authorizationUrl' => 'http://auth.test', |
|
354 | - 'tokenUrl' => 'http://token.test', |
|
355 | - ), $object->toArray()); |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
360 | - */ |
|
361 | - public function testConstructor_Oauth2AccesscodeDescription() |
|
362 | - { |
|
363 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
364 | - |
|
365 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
366 | - |
|
367 | - $this->assertSame(array( |
|
368 | - 'type' => 'oauth2', |
|
369 | - 'description' => 'Some words', |
|
370 | - 'flow' => 'accessCode', |
|
371 | - 'authorizationUrl' => 'http://auth.test', |
|
372 | - 'tokenUrl' => 'http://token.test', |
|
373 | - ), $object->toArray()); |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
378 | - */ |
|
379 | - public function testCommandDescription() |
|
380 | - { |
|
381 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
382 | - |
|
383 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
384 | - |
|
385 | - $object->handleCommand('description', 'Some words'); |
|
386 | - |
|
387 | - $this->assertSame(array( |
|
388 | - 'type' => 'oauth2', |
|
389 | - 'description' => 'Some words', |
|
390 | - 'flow' => 'accessCode', |
|
391 | - 'authorizationUrl' => 'http://auth.test', |
|
392 | - 'tokenUrl' => 'http://token.test', |
|
393 | - ), $object->toArray()); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
398 | - */ |
|
399 | - public function testCommandDescriptionEmpty() |
|
400 | - { |
|
401 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
402 | - |
|
403 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
404 | - |
|
405 | - $object->handleCommand('description', ''); |
|
406 | - |
|
407 | - $this->assertSame(array( |
|
408 | - 'type' => 'oauth2', |
|
409 | - 'flow' => 'accessCode', |
|
410 | - 'authorizationUrl' => 'http://auth.test', |
|
411 | - 'tokenUrl' => 'http://token.test', |
|
412 | - ), $object->toArray()); |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
417 | - */ |
|
418 | - public function testCommandScopeNotOauth() |
|
419 | - { |
|
420 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
421 | - |
|
422 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
423 | - |
|
424 | - $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'"); |
|
425 | - |
|
426 | - $object->handleCommand('scope', 'scope1'); |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
431 | - */ |
|
432 | - public function testCommandScope() |
|
433 | - { |
|
434 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
435 | - |
|
436 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
437 | - |
|
438 | - $object->handleCommand('scope', 'scope1'); |
|
439 | - |
|
440 | - $this->assertSame(array( |
|
441 | - 'type' => 'oauth2', |
|
442 | - 'flow' => 'accessCode', |
|
443 | - 'authorizationUrl' => 'http://auth.test', |
|
444 | - 'tokenUrl' => 'http://token.test', |
|
445 | - 'scopes' => array( |
|
446 | - 'scope1' => '', |
|
447 | - ) |
|
448 | - ), $object->toArray()); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
453 | - */ |
|
454 | - public function testCommandScopeDescription() |
|
455 | - { |
|
456 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
457 | - |
|
458 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
459 | - |
|
460 | - $object->handleCommand('scope', 'scope1 Some text'); |
|
461 | - |
|
462 | - $this->assertSame(array( |
|
463 | - 'type' => 'oauth2', |
|
464 | - 'flow' => 'accessCode', |
|
465 | - 'authorizationUrl' => 'http://auth.test', |
|
466 | - 'tokenUrl' => 'http://token.test', |
|
467 | - 'scopes' => array( |
|
468 | - 'scope1' => 'Some text', |
|
469 | - ) |
|
470 | - ), $object->toArray()); |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
475 | - */ |
|
476 | - public function testCommandScopes() |
|
477 | - { |
|
478 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
479 | - |
|
480 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
481 | - |
|
482 | - $object->handleCommand('scope', 'scope2 Some text'); |
|
483 | - $object->handleCommand('scope', 'scope1 Some text'); |
|
484 | - |
|
485 | - $this->assertSame(array( |
|
486 | - 'type' => 'oauth2', |
|
487 | - 'flow' => 'accessCode', |
|
488 | - 'authorizationUrl' => 'http://auth.test', |
|
489 | - 'tokenUrl' => 'http://token.test', |
|
490 | - 'scopes' => array( |
|
491 | - 'scope2' => 'Some text', |
|
492 | - 'scope1' => 'Some text', |
|
493 | - ) |
|
494 | - ), $object->toArray()); |
|
495 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
20 | + */ |
|
21 | + public function testConstructor_UnknownType() |
|
22 | + { |
|
23 | + $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'"); |
|
24 | + |
|
25 | + new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong'); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
30 | + */ |
|
31 | + public function testConstructor_Basic() |
|
32 | + { |
|
33 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
34 | + |
|
35 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
36 | + |
|
37 | + $this->assertSame(array( |
|
38 | + 'type' => 'basic', |
|
39 | + ), $object->toArray()); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
44 | + */ |
|
45 | + public function testConstructor_BasicDescription() |
|
46 | + { |
|
47 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text'); |
|
48 | + |
|
49 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
50 | + |
|
51 | + $this->assertSame(array( |
|
52 | + 'type' => 'basic', |
|
53 | + 'description' => 'Some text', |
|
54 | + ), $object->toArray()); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
59 | + */ |
|
60 | + public function testConstructor_ApiKeyNoName() |
|
61 | + { |
|
62 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''" |
|
63 | + ); |
|
64 | + |
|
65 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey'); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
70 | + */ |
|
71 | + public function testConstructor_ApiKeyNoIn() |
|
72 | + { |
|
73 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"); |
|
74 | + |
|
75 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name'); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
80 | + */ |
|
81 | + public function testConstructor_ApiKeyWrongIn() |
|
82 | + { |
|
83 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'"); |
|
84 | + |
|
85 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad'); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
90 | + */ |
|
91 | + public function testConstructor_ApiKey() |
|
92 | + { |
|
93 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query'); |
|
94 | + |
|
95 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
96 | + |
|
97 | + $this->assertSame(array( |
|
98 | + 'type' => 'apiKey', |
|
99 | + 'name' => 'Name', |
|
100 | + 'in' => 'query', |
|
101 | + ), $object->toArray()); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
106 | + */ |
|
107 | + public function testConstructor_ApiKeyDescription() |
|
108 | + { |
|
109 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words'); |
|
110 | + |
|
111 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
112 | + |
|
113 | + $this->assertSame(array( |
|
114 | + 'type' => 'apiKey', |
|
115 | + 'description' => 'Some words', |
|
116 | + 'name' => 'Name', |
|
117 | + 'in' => 'query', |
|
118 | + ), $object->toArray()); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
123 | + */ |
|
124 | + public function testConstructor_Oauth2NoFlow() |
|
125 | + { |
|
126 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''"); |
|
127 | + |
|
128 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2'); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
133 | + */ |
|
134 | + public function testConstructor_Oauth2WrongFlow() |
|
135 | + { |
|
136 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'"); |
|
137 | + |
|
138 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow'); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
143 | + */ |
|
144 | + public function testConstructor_Oauth2ImplicitNoUrl() |
|
145 | + { |
|
146 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
147 | + |
|
148 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit'); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
153 | + */ |
|
154 | + public function testConstructor_Oauth2ImplicitBadUrl() |
|
155 | + { |
|
156 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
157 | + |
|
158 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad'); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
163 | + */ |
|
164 | + public function testConstructor_Oauth2ImplicitUrl() |
|
165 | + { |
|
166 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test'); |
|
167 | + |
|
168 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
169 | + |
|
170 | + $this->assertSame(array( |
|
171 | + 'type' => 'oauth2', |
|
172 | + 'flow' => 'implicit', |
|
173 | + 'authorizationUrl' => 'http://www.test', |
|
174 | + ), $object->toArray()); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
179 | + */ |
|
180 | + public function testConstructor_Oauth2ImplicitUrlDescription() |
|
181 | + { |
|
182 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words'); |
|
183 | + |
|
184 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
185 | + |
|
186 | + $this->assertSame(array( |
|
187 | + 'type' => 'oauth2', |
|
188 | + 'description' => 'Some words', |
|
189 | + 'flow' => 'implicit', |
|
190 | + 'authorizationUrl' => 'http://www.test', |
|
191 | + ), $object->toArray()); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
196 | + */ |
|
197 | + public function testConstructor_Oauth2PasswordNoUrl() |
|
198 | + { |
|
199 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
200 | + |
|
201 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password'); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
206 | + */ |
|
207 | + public function testConstructor_Oauth2PasswordBadUrl() |
|
208 | + { |
|
209 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
210 | + |
|
211 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad'); |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
216 | + */ |
|
217 | + public function testConstructor_Oauth2Password() |
|
218 | + { |
|
219 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test'); |
|
220 | + |
|
221 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
222 | + |
|
223 | + $this->assertSame(array( |
|
224 | + 'type' => 'oauth2', |
|
225 | + 'flow' => 'password', |
|
226 | + 'tokenUrl' => 'http://token.test', |
|
227 | + ), $object->toArray()); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
232 | + */ |
|
233 | + public function testConstructor_Oauth2PasswordDescription() |
|
234 | + { |
|
235 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words'); |
|
236 | + |
|
237 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
238 | + |
|
239 | + $this->assertSame(array( |
|
240 | + 'type' => 'oauth2', |
|
241 | + 'description' => 'Some words', |
|
242 | + 'flow' => 'password', |
|
243 | + 'tokenUrl' => 'http://token.test', |
|
244 | + ), $object->toArray()); |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
249 | + */ |
|
250 | + public function testConstructor_Oauth2ApplicationNoUrl() |
|
251 | + { |
|
252 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
253 | + |
|
254 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application'); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
259 | + */ |
|
260 | + public function testConstructor_Oauth2ApplicationBadUrl() |
|
261 | + { |
|
262 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
263 | + |
|
264 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad'); |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
269 | + */ |
|
270 | + public function testConstructor_Oauth2Application() |
|
271 | + { |
|
272 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test'); |
|
273 | + |
|
274 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
275 | + |
|
276 | + $this->assertSame(array( |
|
277 | + 'type' => 'oauth2', |
|
278 | + 'flow' => 'application', |
|
279 | + 'tokenUrl' => 'http://token.test', |
|
280 | + ), $object->toArray()); |
|
281 | + } |
|
282 | + |
|
283 | + /** |
|
284 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
285 | + */ |
|
286 | + public function testConstructor_Oauth2ApplicationDescription() |
|
287 | + { |
|
288 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words'); |
|
289 | + |
|
290 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
291 | + |
|
292 | + $this->assertSame(array( |
|
293 | + 'type' => 'oauth2', |
|
294 | + 'description' => 'Some words', |
|
295 | + 'flow' => 'application', |
|
296 | + 'tokenUrl' => 'http://token.test', |
|
297 | + ), $object->toArray()); |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
303 | + */ |
|
304 | + public function testConstructor_Oauth2AccesscodeNoUrl1() |
|
305 | + { |
|
306 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
307 | + |
|
308 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode'); |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
313 | + */ |
|
314 | + public function testConstructor_Oauth2AccesscodeBadUrl1() |
|
315 | + { |
|
316 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
317 | + |
|
318 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad'); |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
323 | + */ |
|
324 | + public function testConstructor_Oauth2AccesscodeNoUrl2() |
|
325 | + { |
|
326 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
327 | + |
|
328 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test'); |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
333 | + */ |
|
334 | + public function testConstructor_Oauth2AccesscodeBadUrl2() |
|
335 | + { |
|
336 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
337 | + |
|
338 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad'); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
343 | + */ |
|
344 | + public function testConstructor_Oauth2Accesscode() |
|
345 | + { |
|
346 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
347 | + |
|
348 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
349 | + |
|
350 | + $this->assertSame(array( |
|
351 | + 'type' => 'oauth2', |
|
352 | + 'flow' => 'accessCode', |
|
353 | + 'authorizationUrl' => 'http://auth.test', |
|
354 | + 'tokenUrl' => 'http://token.test', |
|
355 | + ), $object->toArray()); |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
360 | + */ |
|
361 | + public function testConstructor_Oauth2AccesscodeDescription() |
|
362 | + { |
|
363 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
364 | + |
|
365 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
366 | + |
|
367 | + $this->assertSame(array( |
|
368 | + 'type' => 'oauth2', |
|
369 | + 'description' => 'Some words', |
|
370 | + 'flow' => 'accessCode', |
|
371 | + 'authorizationUrl' => 'http://auth.test', |
|
372 | + 'tokenUrl' => 'http://token.test', |
|
373 | + ), $object->toArray()); |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
378 | + */ |
|
379 | + public function testCommandDescription() |
|
380 | + { |
|
381 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
382 | + |
|
383 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
384 | + |
|
385 | + $object->handleCommand('description', 'Some words'); |
|
386 | + |
|
387 | + $this->assertSame(array( |
|
388 | + 'type' => 'oauth2', |
|
389 | + 'description' => 'Some words', |
|
390 | + 'flow' => 'accessCode', |
|
391 | + 'authorizationUrl' => 'http://auth.test', |
|
392 | + 'tokenUrl' => 'http://token.test', |
|
393 | + ), $object->toArray()); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
398 | + */ |
|
399 | + public function testCommandDescriptionEmpty() |
|
400 | + { |
|
401 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
402 | + |
|
403 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
404 | + |
|
405 | + $object->handleCommand('description', ''); |
|
406 | + |
|
407 | + $this->assertSame(array( |
|
408 | + 'type' => 'oauth2', |
|
409 | + 'flow' => 'accessCode', |
|
410 | + 'authorizationUrl' => 'http://auth.test', |
|
411 | + 'tokenUrl' => 'http://token.test', |
|
412 | + ), $object->toArray()); |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
417 | + */ |
|
418 | + public function testCommandScopeNotOauth() |
|
419 | + { |
|
420 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
421 | + |
|
422 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
423 | + |
|
424 | + $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'"); |
|
425 | + |
|
426 | + $object->handleCommand('scope', 'scope1'); |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
431 | + */ |
|
432 | + public function testCommandScope() |
|
433 | + { |
|
434 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
435 | + |
|
436 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
437 | + |
|
438 | + $object->handleCommand('scope', 'scope1'); |
|
439 | + |
|
440 | + $this->assertSame(array( |
|
441 | + 'type' => 'oauth2', |
|
442 | + 'flow' => 'accessCode', |
|
443 | + 'authorizationUrl' => 'http://auth.test', |
|
444 | + 'tokenUrl' => 'http://token.test', |
|
445 | + 'scopes' => array( |
|
446 | + 'scope1' => '', |
|
447 | + ) |
|
448 | + ), $object->toArray()); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
453 | + */ |
|
454 | + public function testCommandScopeDescription() |
|
455 | + { |
|
456 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
457 | + |
|
458 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
459 | + |
|
460 | + $object->handleCommand('scope', 'scope1 Some text'); |
|
461 | + |
|
462 | + $this->assertSame(array( |
|
463 | + 'type' => 'oauth2', |
|
464 | + 'flow' => 'accessCode', |
|
465 | + 'authorizationUrl' => 'http://auth.test', |
|
466 | + 'tokenUrl' => 'http://token.test', |
|
467 | + 'scopes' => array( |
|
468 | + 'scope1' => 'Some text', |
|
469 | + ) |
|
470 | + ), $object->toArray()); |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
475 | + */ |
|
476 | + public function testCommandScopes() |
|
477 | + { |
|
478 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
479 | + |
|
480 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
481 | + |
|
482 | + $object->handleCommand('scope', 'scope2 Some text'); |
|
483 | + $object->handleCommand('scope', 'scope1 Some text'); |
|
484 | + |
|
485 | + $this->assertSame(array( |
|
486 | + 'type' => 'oauth2', |
|
487 | + 'flow' => 'accessCode', |
|
488 | + 'authorizationUrl' => 'http://auth.test', |
|
489 | + 'tokenUrl' => 'http://token.test', |
|
490 | + 'scopes' => array( |
|
491 | + 'scope2' => 'Some text', |
|
492 | + 'scope1' => 'Some text', |
|
493 | + ) |
|
494 | + ), $object->toArray()); |
|
495 | + } |
|
496 | 496 | |
497 | 497 | } |
@@ -3,193 +3,193 @@ |
||
3 | 3 | class ParameterTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
20 | - */ |
|
21 | - public function testConstructor_InEmpty(): void |
|
22 | - { |
|
23 | - $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''"); |
|
24 | - |
|
25 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, '', ''); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
30 | - */ |
|
31 | - public function testConstructor_InNotValid(): void |
|
32 | - { |
|
33 | - $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'"); |
|
34 | - |
|
35 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', ''); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
40 | - */ |
|
41 | - public function testConstructor_DefinitionEmpty(): void |
|
42 | - { |
|
43 | - $this->expectException('\SwaggerGen\Exception', "No type definition for parameter"); |
|
44 | - |
|
45 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', ''); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
50 | - */ |
|
51 | - public function testConstructor_NameEmpty(): void |
|
52 | - { |
|
53 | - $this->expectException('\SwaggerGen\Exception', "No name for parameter"); |
|
54 | - |
|
55 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int'); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
60 | - */ |
|
61 | - public function testConstructor_DefinitionUnknownType() |
|
62 | - { |
|
63 | - $this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'"); |
|
64 | - |
|
65 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar'); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
70 | - */ |
|
71 | - public function testConstructor() |
|
72 | - { |
|
73 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo'); |
|
74 | - |
|
75 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
76 | - |
|
77 | - $this->assertSame(array( |
|
78 | - 'name' => 'foo', |
|
79 | - 'in' => 'path', |
|
80 | - 'required' => true, |
|
81 | - 'type' => 'integer', |
|
82 | - 'format' => 'int32', |
|
83 | - ), $object->toArray()); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
88 | - */ |
|
89 | - public function testConstructor_PathAlwaysRequired() |
|
90 | - { |
|
91 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
92 | - |
|
93 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
94 | - |
|
95 | - $this->assertSame(array( |
|
96 | - 'name' => 'foo', |
|
97 | - 'in' => 'path', |
|
98 | - 'required' => true, |
|
99 | - 'type' => 'integer', |
|
100 | - 'format' => 'int32', |
|
101 | - ), $object->toArray()); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
106 | - */ |
|
107 | - public function testConstructor_Optional() |
|
108 | - { |
|
109 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false); |
|
110 | - |
|
111 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
112 | - |
|
113 | - $this->assertSame(array( |
|
114 | - 'name' => 'foo', |
|
115 | - 'in' => 'query', |
|
116 | - 'type' => 'integer', |
|
117 | - 'format' => 'int32', |
|
118 | - ), $object->toArray()); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
123 | - */ |
|
124 | - public function testConstructor_Description() |
|
125 | - { |
|
126 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words'); |
|
127 | - |
|
128 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
129 | - |
|
130 | - $this->assertSame(array( |
|
131 | - 'name' => 'foo', |
|
132 | - 'in' => 'path', |
|
133 | - 'description' => 'Some words', |
|
134 | - 'required' => true, |
|
135 | - 'type' => 'integer', |
|
136 | - 'format' => 'int32', |
|
137 | - ), $object->toArray()); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
142 | - */ |
|
143 | - public function testConstructor_Form() |
|
144 | - { |
|
145 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false); |
|
146 | - |
|
147 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
148 | - |
|
149 | - $this->assertSame(array( |
|
150 | - 'name' => 'foo', |
|
151 | - 'in' => 'formData', |
|
152 | - 'type' => 'integer', |
|
153 | - 'format' => 'int32', |
|
154 | - ), $object->toArray()); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
159 | - */ |
|
160 | - public function testConstructor_Header() |
|
161 | - { |
|
162 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false); |
|
163 | - |
|
164 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
165 | - |
|
166 | - $this->assertSame(array( |
|
167 | - 'name' => 'foo', |
|
168 | - 'in' => 'header', |
|
169 | - 'type' => 'integer', |
|
170 | - 'format' => 'int32', |
|
171 | - ), $object->toArray()); |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand |
|
176 | - */ |
|
177 | - public function testHandleCommand_Passing() |
|
178 | - { |
|
179 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
180 | - |
|
181 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
182 | - |
|
183 | - $object->handleCommand('default', '123'); |
|
184 | - |
|
185 | - $this->assertSame(array( |
|
186 | - 'name' => 'foo', |
|
187 | - 'in' => 'path', |
|
188 | - 'required' => true, |
|
189 | - 'type' => 'integer', |
|
190 | - 'format' => 'int32', |
|
191 | - 'default' => 123, |
|
192 | - ), $object->toArray()); |
|
193 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
20 | + */ |
|
21 | + public function testConstructor_InEmpty(): void |
|
22 | + { |
|
23 | + $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''"); |
|
24 | + |
|
25 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, '', ''); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
30 | + */ |
|
31 | + public function testConstructor_InNotValid(): void |
|
32 | + { |
|
33 | + $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'"); |
|
34 | + |
|
35 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', ''); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
40 | + */ |
|
41 | + public function testConstructor_DefinitionEmpty(): void |
|
42 | + { |
|
43 | + $this->expectException('\SwaggerGen\Exception', "No type definition for parameter"); |
|
44 | + |
|
45 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', ''); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
50 | + */ |
|
51 | + public function testConstructor_NameEmpty(): void |
|
52 | + { |
|
53 | + $this->expectException('\SwaggerGen\Exception', "No name for parameter"); |
|
54 | + |
|
55 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int'); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
60 | + */ |
|
61 | + public function testConstructor_DefinitionUnknownType() |
|
62 | + { |
|
63 | + $this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'"); |
|
64 | + |
|
65 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar'); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
70 | + */ |
|
71 | + public function testConstructor() |
|
72 | + { |
|
73 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo'); |
|
74 | + |
|
75 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
76 | + |
|
77 | + $this->assertSame(array( |
|
78 | + 'name' => 'foo', |
|
79 | + 'in' => 'path', |
|
80 | + 'required' => true, |
|
81 | + 'type' => 'integer', |
|
82 | + 'format' => 'int32', |
|
83 | + ), $object->toArray()); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
88 | + */ |
|
89 | + public function testConstructor_PathAlwaysRequired() |
|
90 | + { |
|
91 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
92 | + |
|
93 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
94 | + |
|
95 | + $this->assertSame(array( |
|
96 | + 'name' => 'foo', |
|
97 | + 'in' => 'path', |
|
98 | + 'required' => true, |
|
99 | + 'type' => 'integer', |
|
100 | + 'format' => 'int32', |
|
101 | + ), $object->toArray()); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
106 | + */ |
|
107 | + public function testConstructor_Optional() |
|
108 | + { |
|
109 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false); |
|
110 | + |
|
111 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
112 | + |
|
113 | + $this->assertSame(array( |
|
114 | + 'name' => 'foo', |
|
115 | + 'in' => 'query', |
|
116 | + 'type' => 'integer', |
|
117 | + 'format' => 'int32', |
|
118 | + ), $object->toArray()); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
123 | + */ |
|
124 | + public function testConstructor_Description() |
|
125 | + { |
|
126 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words'); |
|
127 | + |
|
128 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
129 | + |
|
130 | + $this->assertSame(array( |
|
131 | + 'name' => 'foo', |
|
132 | + 'in' => 'path', |
|
133 | + 'description' => 'Some words', |
|
134 | + 'required' => true, |
|
135 | + 'type' => 'integer', |
|
136 | + 'format' => 'int32', |
|
137 | + ), $object->toArray()); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
142 | + */ |
|
143 | + public function testConstructor_Form() |
|
144 | + { |
|
145 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false); |
|
146 | + |
|
147 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
148 | + |
|
149 | + $this->assertSame(array( |
|
150 | + 'name' => 'foo', |
|
151 | + 'in' => 'formData', |
|
152 | + 'type' => 'integer', |
|
153 | + 'format' => 'int32', |
|
154 | + ), $object->toArray()); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
159 | + */ |
|
160 | + public function testConstructor_Header() |
|
161 | + { |
|
162 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false); |
|
163 | + |
|
164 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
165 | + |
|
166 | + $this->assertSame(array( |
|
167 | + 'name' => 'foo', |
|
168 | + 'in' => 'header', |
|
169 | + 'type' => 'integer', |
|
170 | + 'format' => 'int32', |
|
171 | + ), $object->toArray()); |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand |
|
176 | + */ |
|
177 | + public function testHandleCommand_Passing() |
|
178 | + { |
|
179 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
180 | + |
|
181 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
182 | + |
|
183 | + $object->handleCommand('default', '123'); |
|
184 | + |
|
185 | + $this->assertSame(array( |
|
186 | + 'name' => 'foo', |
|
187 | + 'in' => 'path', |
|
188 | + 'required' => true, |
|
189 | + 'type' => 'integer', |
|
190 | + 'format' => 'int32', |
|
191 | + 'default' => 123, |
|
192 | + ), $object->toArray()); |
|
193 | + } |
|
194 | 194 | |
195 | 195 | } |
@@ -3,247 +3,247 @@ |
||
3 | 3 | class InfoTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\Info |
|
20 | - */ |
|
21 | - public function testNoConstructor(): void |
|
22 | - { |
|
23 | - $object = new \SwaggerGen\Swagger\Info; |
|
24 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
25 | - |
|
26 | - $this->assertSame(array( |
|
27 | - 'title' => 'undefined', |
|
28 | - 'version' => '0', |
|
29 | - ), $object->toArray()); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
34 | - */ |
|
35 | - public function testCommandTitle() |
|
36 | - { |
|
37 | - $object = new \SwaggerGen\Swagger\Info; |
|
38 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
39 | - |
|
40 | - $object->handleCommand('title', 'This is the title'); |
|
41 | - |
|
42 | - $this->assertSame(array( |
|
43 | - 'title' => 'This is the title', |
|
44 | - 'version' => '0', |
|
45 | - ), $object->toArray()); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
50 | - */ |
|
51 | - public function testCommandDescription() |
|
52 | - { |
|
53 | - $object = new \SwaggerGen\Swagger\Info; |
|
54 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
55 | - |
|
56 | - $object->handleCommand('description', 'This is the description'); |
|
57 | - |
|
58 | - $this->assertSame(array( |
|
59 | - 'title' => 'undefined', |
|
60 | - 'description' => 'This is the description', |
|
61 | - 'version' => '0', |
|
62 | - ), $object->toArray()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
67 | - */ |
|
68 | - public function testCommandVersion() |
|
69 | - { |
|
70 | - $object = new \SwaggerGen\Swagger\Info; |
|
71 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
72 | - |
|
73 | - $object->handleCommand('version', '1.2.3a'); |
|
74 | - |
|
75 | - $this->assertSame(array( |
|
76 | - 'title' => 'undefined', |
|
77 | - 'version' => '1.2.3a', |
|
78 | - ), $object->toArray()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
83 | - */ |
|
84 | - public function testCommandTermsofservice() |
|
85 | - { |
|
86 | - $object = new \SwaggerGen\Swagger\Info; |
|
87 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
88 | - |
|
89 | - $object->handleCommand('termsofservice', 'These are the terms'); |
|
90 | - |
|
91 | - $this->assertSame(array( |
|
92 | - 'title' => 'undefined', |
|
93 | - 'termsOfService' => 'These are the terms', |
|
94 | - 'version' => '0', |
|
95 | - ), $object->toArray()); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
100 | - */ |
|
101 | - public function testCommandTerms() |
|
102 | - { |
|
103 | - $object = new \SwaggerGen\Swagger\Info; |
|
104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
105 | - |
|
106 | - $object->handleCommand('terms', 'These are the terms'); |
|
107 | - |
|
108 | - $this->assertSame(array( |
|
109 | - 'title' => 'undefined', |
|
110 | - 'termsOfService' => 'These are the terms', |
|
111 | - 'version' => '0', |
|
112 | - ), $object->toArray()); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
117 | - */ |
|
118 | - public function testCommandContactNameUrlEmail() |
|
119 | - { |
|
120 | - $object = new \SwaggerGen\Swagger\Info; |
|
121 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
122 | - |
|
123 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
124 | - |
|
125 | - $this->assertSame(array( |
|
126 | - 'title' => 'undefined', |
|
127 | - 'contact' => array( |
|
128 | - 'name' => 'Arthur D. Author', |
|
129 | - 'url' => 'http://example.test', |
|
130 | - 'email' => '[email protected]', |
|
131 | - ), |
|
132 | - 'version' => '0', |
|
133 | - ), $object->toArray()); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
138 | - */ |
|
139 | - public function testCommandContactNameEmailNameUrlName() |
|
140 | - { |
|
141 | - $object = new \SwaggerGen\Swagger\Info; |
|
142 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
143 | - |
|
144 | - $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
145 | - |
|
146 | - $this->assertSame(array( |
|
147 | - 'title' => 'undefined', |
|
148 | - 'contact' => array( |
|
149 | - 'name' => 'Arthur D. Author', |
|
150 | - 'url' => 'http://example.test', |
|
151 | - 'email' => '[email protected]', |
|
152 | - ), |
|
153 | - 'version' => '0', |
|
154 | - ), $object->toArray()); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
159 | - */ |
|
160 | - public function testCommandLicenseNameUrl() |
|
161 | - { |
|
162 | - $object = new \SwaggerGen\Swagger\Info; |
|
163 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
164 | - |
|
165 | - $object->handleCommand('license', 'NAME http://example.test'); |
|
166 | - |
|
167 | - $this->assertSame(array( |
|
168 | - 'title' => 'undefined', |
|
169 | - 'license' => array( |
|
170 | - 'name' => 'NAME', |
|
171 | - 'url' => 'http://example.test', |
|
172 | - ), |
|
173 | - 'version' => '0', |
|
174 | - ), $object->toArray()); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
179 | - */ |
|
180 | - public function testCommandLicenseUrlName() |
|
181 | - { |
|
182 | - $object = new \SwaggerGen\Swagger\Info; |
|
183 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
184 | - |
|
185 | - $object->handleCommand('license', 'http://example.test NAME'); |
|
186 | - |
|
187 | - $this->assertSame(array( |
|
188 | - 'title' => 'undefined', |
|
189 | - 'license' => array( |
|
190 | - 'name' => 'NAME', |
|
191 | - 'url' => 'http://example.test', |
|
192 | - ), |
|
193 | - 'version' => '0', |
|
194 | - ), $object->toArray()); |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
199 | - */ |
|
200 | - public function testCommandLicenseShorthand() |
|
201 | - { |
|
202 | - $object = new \SwaggerGen\Swagger\Info; |
|
203 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
204 | - |
|
205 | - $object->handleCommand('license', 'BSD'); |
|
206 | - |
|
207 | - $this->assertSame(array( |
|
208 | - 'title' => 'undefined', |
|
209 | - 'license' => array( |
|
210 | - 'name' => 'BSD', |
|
211 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
212 | - ), |
|
213 | - 'version' => '0', |
|
214 | - ), $object->toArray()); |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
219 | - */ |
|
220 | - public function testCommandAll() |
|
221 | - { |
|
222 | - $object = new \SwaggerGen\Swagger\Info; |
|
223 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
224 | - |
|
225 | - $object->handleCommand('description', 'This is the description'); |
|
226 | - $object->handleCommand('license', 'BSD'); |
|
227 | - $object->handleCommand('terms', 'These are the terms'); |
|
228 | - $object->handleCommand('version', '1.2.3a'); |
|
229 | - $object->handleCommand('title', 'This is the title'); |
|
230 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
231 | - |
|
232 | - $this->assertSame(array( |
|
233 | - 'title' => 'This is the title', |
|
234 | - 'description' => 'This is the description', |
|
235 | - 'termsOfService' => 'These are the terms', |
|
236 | - 'contact' => array( |
|
237 | - 'name' => 'Arthur D. Author', |
|
238 | - 'url' => 'http://example.test', |
|
239 | - 'email' => '[email protected]', |
|
240 | - ), |
|
241 | - 'license' => array( |
|
242 | - 'name' => 'BSD', |
|
243 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
244 | - ), |
|
245 | - 'version' => '1.2.3a', |
|
246 | - ), $object->toArray()); |
|
247 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\Info |
|
20 | + */ |
|
21 | + public function testNoConstructor(): void |
|
22 | + { |
|
23 | + $object = new \SwaggerGen\Swagger\Info; |
|
24 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
25 | + |
|
26 | + $this->assertSame(array( |
|
27 | + 'title' => 'undefined', |
|
28 | + 'version' => '0', |
|
29 | + ), $object->toArray()); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
34 | + */ |
|
35 | + public function testCommandTitle() |
|
36 | + { |
|
37 | + $object = new \SwaggerGen\Swagger\Info; |
|
38 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
39 | + |
|
40 | + $object->handleCommand('title', 'This is the title'); |
|
41 | + |
|
42 | + $this->assertSame(array( |
|
43 | + 'title' => 'This is the title', |
|
44 | + 'version' => '0', |
|
45 | + ), $object->toArray()); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
50 | + */ |
|
51 | + public function testCommandDescription() |
|
52 | + { |
|
53 | + $object = new \SwaggerGen\Swagger\Info; |
|
54 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
55 | + |
|
56 | + $object->handleCommand('description', 'This is the description'); |
|
57 | + |
|
58 | + $this->assertSame(array( |
|
59 | + 'title' => 'undefined', |
|
60 | + 'description' => 'This is the description', |
|
61 | + 'version' => '0', |
|
62 | + ), $object->toArray()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
67 | + */ |
|
68 | + public function testCommandVersion() |
|
69 | + { |
|
70 | + $object = new \SwaggerGen\Swagger\Info; |
|
71 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
72 | + |
|
73 | + $object->handleCommand('version', '1.2.3a'); |
|
74 | + |
|
75 | + $this->assertSame(array( |
|
76 | + 'title' => 'undefined', |
|
77 | + 'version' => '1.2.3a', |
|
78 | + ), $object->toArray()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
83 | + */ |
|
84 | + public function testCommandTermsofservice() |
|
85 | + { |
|
86 | + $object = new \SwaggerGen\Swagger\Info; |
|
87 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
88 | + |
|
89 | + $object->handleCommand('termsofservice', 'These are the terms'); |
|
90 | + |
|
91 | + $this->assertSame(array( |
|
92 | + 'title' => 'undefined', |
|
93 | + 'termsOfService' => 'These are the terms', |
|
94 | + 'version' => '0', |
|
95 | + ), $object->toArray()); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
100 | + */ |
|
101 | + public function testCommandTerms() |
|
102 | + { |
|
103 | + $object = new \SwaggerGen\Swagger\Info; |
|
104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
105 | + |
|
106 | + $object->handleCommand('terms', 'These are the terms'); |
|
107 | + |
|
108 | + $this->assertSame(array( |
|
109 | + 'title' => 'undefined', |
|
110 | + 'termsOfService' => 'These are the terms', |
|
111 | + 'version' => '0', |
|
112 | + ), $object->toArray()); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
117 | + */ |
|
118 | + public function testCommandContactNameUrlEmail() |
|
119 | + { |
|
120 | + $object = new \SwaggerGen\Swagger\Info; |
|
121 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
122 | + |
|
123 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
124 | + |
|
125 | + $this->assertSame(array( |
|
126 | + 'title' => 'undefined', |
|
127 | + 'contact' => array( |
|
128 | + 'name' => 'Arthur D. Author', |
|
129 | + 'url' => 'http://example.test', |
|
130 | + 'email' => '[email protected]', |
|
131 | + ), |
|
132 | + 'version' => '0', |
|
133 | + ), $object->toArray()); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
138 | + */ |
|
139 | + public function testCommandContactNameEmailNameUrlName() |
|
140 | + { |
|
141 | + $object = new \SwaggerGen\Swagger\Info; |
|
142 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
143 | + |
|
144 | + $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
145 | + |
|
146 | + $this->assertSame(array( |
|
147 | + 'title' => 'undefined', |
|
148 | + 'contact' => array( |
|
149 | + 'name' => 'Arthur D. Author', |
|
150 | + 'url' => 'http://example.test', |
|
151 | + 'email' => '[email protected]', |
|
152 | + ), |
|
153 | + 'version' => '0', |
|
154 | + ), $object->toArray()); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
159 | + */ |
|
160 | + public function testCommandLicenseNameUrl() |
|
161 | + { |
|
162 | + $object = new \SwaggerGen\Swagger\Info; |
|
163 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
164 | + |
|
165 | + $object->handleCommand('license', 'NAME http://example.test'); |
|
166 | + |
|
167 | + $this->assertSame(array( |
|
168 | + 'title' => 'undefined', |
|
169 | + 'license' => array( |
|
170 | + 'name' => 'NAME', |
|
171 | + 'url' => 'http://example.test', |
|
172 | + ), |
|
173 | + 'version' => '0', |
|
174 | + ), $object->toArray()); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
179 | + */ |
|
180 | + public function testCommandLicenseUrlName() |
|
181 | + { |
|
182 | + $object = new \SwaggerGen\Swagger\Info; |
|
183 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
184 | + |
|
185 | + $object->handleCommand('license', 'http://example.test NAME'); |
|
186 | + |
|
187 | + $this->assertSame(array( |
|
188 | + 'title' => 'undefined', |
|
189 | + 'license' => array( |
|
190 | + 'name' => 'NAME', |
|
191 | + 'url' => 'http://example.test', |
|
192 | + ), |
|
193 | + 'version' => '0', |
|
194 | + ), $object->toArray()); |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
199 | + */ |
|
200 | + public function testCommandLicenseShorthand() |
|
201 | + { |
|
202 | + $object = new \SwaggerGen\Swagger\Info; |
|
203 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
204 | + |
|
205 | + $object->handleCommand('license', 'BSD'); |
|
206 | + |
|
207 | + $this->assertSame(array( |
|
208 | + 'title' => 'undefined', |
|
209 | + 'license' => array( |
|
210 | + 'name' => 'BSD', |
|
211 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
212 | + ), |
|
213 | + 'version' => '0', |
|
214 | + ), $object->toArray()); |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
219 | + */ |
|
220 | + public function testCommandAll() |
|
221 | + { |
|
222 | + $object = new \SwaggerGen\Swagger\Info; |
|
223 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
224 | + |
|
225 | + $object->handleCommand('description', 'This is the description'); |
|
226 | + $object->handleCommand('license', 'BSD'); |
|
227 | + $object->handleCommand('terms', 'These are the terms'); |
|
228 | + $object->handleCommand('version', '1.2.3a'); |
|
229 | + $object->handleCommand('title', 'This is the title'); |
|
230 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
231 | + |
|
232 | + $this->assertSame(array( |
|
233 | + 'title' => 'This is the title', |
|
234 | + 'description' => 'This is the description', |
|
235 | + 'termsOfService' => 'These are the terms', |
|
236 | + 'contact' => array( |
|
237 | + 'name' => 'Arthur D. Author', |
|
238 | + 'url' => 'http://example.test', |
|
239 | + 'email' => '[email protected]', |
|
240 | + ), |
|
241 | + 'license' => array( |
|
242 | + 'name' => 'BSD', |
|
243 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
244 | + ), |
|
245 | + 'version' => '1.2.3a', |
|
246 | + ), $object->toArray()); |
|
247 | + } |
|
248 | 248 | |
249 | 249 | } |
@@ -3,113 +3,113 @@ |
||
3 | 3 | class LicenseTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
20 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
21 | - */ |
|
22 | - public function testConstructor2Unknown(): void |
|
23 | - { |
|
24 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
25 | - |
|
26 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
27 | - |
|
28 | - $this->assertSame(array( |
|
29 | - 'name' => 'Name', |
|
30 | - ), $object->toArray()); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
35 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
36 | - */ |
|
37 | - public function testConstructor2Known() |
|
38 | - { |
|
39 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
40 | - |
|
41 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
42 | - |
|
43 | - $this->assertSame(array( |
|
44 | - 'name' => 'MIT', |
|
45 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
46 | - ), $object->toArray()); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
51 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
52 | - */ |
|
53 | - public function testConstructor3Unknown() |
|
54 | - { |
|
55 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
56 | - |
|
57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
58 | - |
|
59 | - $this->assertSame(array( |
|
60 | - 'name' => 'Name', |
|
61 | - 'url' => 'http://example', |
|
62 | - ), $object->toArray()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
67 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
68 | - */ |
|
69 | - public function testConstructor3Known() |
|
70 | - { |
|
71 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
72 | - |
|
73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
74 | - |
|
75 | - $this->assertSame(array( |
|
76 | - 'name' => 'MIT', |
|
77 | - 'url' => 'http://example', |
|
78 | - ), $object->toArray()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
83 | - */ |
|
84 | - public function testCommandName() |
|
85 | - { |
|
86 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
87 | - |
|
88 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
89 | - |
|
90 | - $object->handleCommand('name', 'GPL-3'); |
|
91 | - |
|
92 | - $this->assertSame(array( |
|
93 | - 'name' => 'GPL-3', |
|
94 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
95 | - ), $object->toArray()); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
100 | - */ |
|
101 | - public function testCommandUrl() |
|
102 | - { |
|
103 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
104 | - |
|
105 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
106 | - |
|
107 | - $object->handleCommand('url', 'http://example'); |
|
108 | - |
|
109 | - $this->assertSame(array( |
|
110 | - 'name' => 'MIT', |
|
111 | - 'url' => 'http://example', |
|
112 | - ), $object->toArray()); |
|
113 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
20 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
21 | + */ |
|
22 | + public function testConstructor2Unknown(): void |
|
23 | + { |
|
24 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
25 | + |
|
26 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
27 | + |
|
28 | + $this->assertSame(array( |
|
29 | + 'name' => 'Name', |
|
30 | + ), $object->toArray()); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
35 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
36 | + */ |
|
37 | + public function testConstructor2Known() |
|
38 | + { |
|
39 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
40 | + |
|
41 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
42 | + |
|
43 | + $this->assertSame(array( |
|
44 | + 'name' => 'MIT', |
|
45 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
46 | + ), $object->toArray()); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
51 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
52 | + */ |
|
53 | + public function testConstructor3Unknown() |
|
54 | + { |
|
55 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
56 | + |
|
57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
58 | + |
|
59 | + $this->assertSame(array( |
|
60 | + 'name' => 'Name', |
|
61 | + 'url' => 'http://example', |
|
62 | + ), $object->toArray()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
67 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
68 | + */ |
|
69 | + public function testConstructor3Known() |
|
70 | + { |
|
71 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
72 | + |
|
73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
74 | + |
|
75 | + $this->assertSame(array( |
|
76 | + 'name' => 'MIT', |
|
77 | + 'url' => 'http://example', |
|
78 | + ), $object->toArray()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
83 | + */ |
|
84 | + public function testCommandName() |
|
85 | + { |
|
86 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
87 | + |
|
88 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
89 | + |
|
90 | + $object->handleCommand('name', 'GPL-3'); |
|
91 | + |
|
92 | + $this->assertSame(array( |
|
93 | + 'name' => 'GPL-3', |
|
94 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
95 | + ), $object->toArray()); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
100 | + */ |
|
101 | + public function testCommandUrl() |
|
102 | + { |
|
103 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
104 | + |
|
105 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
106 | + |
|
107 | + $object->handleCommand('url', 'http://example'); |
|
108 | + |
|
109 | + $this->assertSame(array( |
|
110 | + 'name' => 'MIT', |
|
111 | + 'url' => 'http://example', |
|
112 | + ), $object->toArray()); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
@@ -3,94 +3,94 @@ discard block |
||
3 | 3 | class SwaggerGenTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\SwaggerGen::__construct |
|
8 | - */ |
|
9 | - public function testConstructor_Empty() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\SwaggerGen(); |
|
12 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
13 | - |
|
14 | - $this->expectException('\SwaggerGen\Exception', 'No path defined'); |
|
15 | - $object->getSwagger(array()); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
20 | - */ |
|
21 | - public function testGetSwagger_ShortestPossible() |
|
22 | - { |
|
23 | - $object = new \SwaggerGen\SwaggerGen(); |
|
24 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
25 | - |
|
26 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\SwaggerGen::__construct |
|
8 | + */ |
|
9 | + public function testConstructor_Empty() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\SwaggerGen(); |
|
12 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
13 | + |
|
14 | + $this->expectException('\SwaggerGen\Exception', 'No path defined'); |
|
15 | + $object->getSwagger(array()); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
20 | + */ |
|
21 | + public function testGetSwagger_ShortestPossible() |
|
22 | + { |
|
23 | + $object = new \SwaggerGen\SwaggerGen(); |
|
24 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
25 | + |
|
26 | + $array = $object->getSwagger(array(' |
|
27 | 27 | endpoint |
28 | 28 | method GET |
29 | 29 | response 202 |
30 | 30 | ')); |
31 | 31 | |
32 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | - } |
|
32 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @covers \SwaggerGen\SwaggerGen::__construct |
|
37 | + */ |
|
38 | + public function testConstructor_BadContext() |
|
39 | + { |
|
40 | + $object = new \SwaggerGen\SwaggerGen(); |
|
41 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
34 | 42 | |
35 | - /** |
|
36 | - * @covers \SwaggerGen\SwaggerGen::__construct |
|
37 | - */ |
|
38 | - public function testConstructor_BadContext() |
|
39 | - { |
|
40 | - $object = new \SwaggerGen\SwaggerGen(); |
|
41 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
42 | - |
|
43 | - $this->expectException('\SwaggerGen\StatementException', 'Invalid error code: \'\''); |
|
44 | - try { |
|
45 | - $object->getSwagger(array(' |
|
43 | + $this->expectException('\SwaggerGen\StatementException', 'Invalid error code: \'\''); |
|
44 | + try { |
|
45 | + $object->getSwagger(array(' |
|
46 | 46 | endpoint |
47 | 47 | method GET |
48 | 48 | error |
49 | 49 | ')); |
50 | - } catch (\SwaggerGen\StatementException $e) { |
|
51 | - $this->assertSame("Invalid error code: ''", $e->getMessage()); |
|
52 | - $this->assertSame(3, $e->getStatement()->getLine()); |
|
53 | - |
|
54 | - throw $e; // rethrow to satisfy expected exception check |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
60 | - */ |
|
61 | - public function testGetSwagger_JSON() |
|
62 | - { |
|
63 | - $object = new \SwaggerGen\SwaggerGen(); |
|
64 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
65 | - |
|
66 | - $output = $object->getSwagger(array(' |
|
50 | + } catch (\SwaggerGen\StatementException $e) { |
|
51 | + $this->assertSame("Invalid error code: ''", $e->getMessage()); |
|
52 | + $this->assertSame(3, $e->getStatement()->getLine()); |
|
53 | + |
|
54 | + throw $e; // rethrow to satisfy expected exception check |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
60 | + */ |
|
61 | + public function testGetSwagger_JSON() |
|
62 | + { |
|
63 | + $object = new \SwaggerGen\SwaggerGen(); |
|
64 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
65 | + |
|
66 | + $output = $object->getSwagger(array(' |
|
67 | 67 | endpoint |
68 | 68 | method GET |
69 | 69 | response 202 |
70 | 70 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_JSON); |
71 | 71 | |
72 | - $this->assertSame('{"swagger":"2.0","info":{"title":"undefined","version":"0"},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', $output); |
|
73 | - } |
|
72 | + $this->assertSame('{"swagger":"2.0","info":{"title":"undefined","version":"0"},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', $output); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
77 | - */ |
|
78 | - public function testGetSwagger_JSON_Pretty() |
|
79 | - { |
|
80 | - if (!defined('JSON_PRETTY_PRINT')) { |
|
81 | - $this->markTestSkipped('JSON_PRETTY_PRINT available since PHP 5.4.0'); |
|
82 | - } |
|
75 | + /** |
|
76 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
77 | + */ |
|
78 | + public function testGetSwagger_JSON_Pretty() |
|
79 | + { |
|
80 | + if (!defined('JSON_PRETTY_PRINT')) { |
|
81 | + $this->markTestSkipped('JSON_PRETTY_PRINT available since PHP 5.4.0'); |
|
82 | + } |
|
83 | 83 | |
84 | - $object = new \SwaggerGen\SwaggerGen(); |
|
85 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
84 | + $object = new \SwaggerGen\SwaggerGen(); |
|
85 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
86 | 86 | |
87 | - $output = $object->getSwagger(array(' |
|
87 | + $output = $object->getSwagger(array(' |
|
88 | 88 | endpoint |
89 | 89 | method GET |
90 | 90 | response 202 |
91 | 91 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_JSON_PRETTY); |
92 | 92 | |
93 | - $this->assertSame('{ |
|
93 | + $this->assertSame('{ |
|
94 | 94 | "swagger": "2.0", |
95 | 95 | "info": { |
96 | 96 | "title": "undefined", |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | }', $output); |
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
115 | - */ |
|
116 | - public function testGetSwagger_YAML() |
|
117 | - { |
|
118 | - if (!extension_loaded('yaml')) { |
|
119 | - $this->markTestSkipped('The YAML extension is not available.'); |
|
120 | - } else { |
|
121 | - $object = new \SwaggerGen\SwaggerGen(); |
|
122 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
123 | - |
|
124 | - $output = $object->getSwagger(array(' |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
115 | + */ |
|
116 | + public function testGetSwagger_YAML() |
|
117 | + { |
|
118 | + if (!extension_loaded('yaml')) { |
|
119 | + $this->markTestSkipped('The YAML extension is not available.'); |
|
120 | + } else { |
|
121 | + $object = new \SwaggerGen\SwaggerGen(); |
|
122 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
123 | + |
|
124 | + $output = $object->getSwagger(array(' |
|
125 | 125 | endpoint |
126 | 126 | method GET |
127 | 127 | response 202 |
128 | 128 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_YAML); |
129 | 129 | |
130 | - $this->assertSame('--- |
|
130 | + $this->assertSame('--- |
|
131 | 131 | swagger: "2.0" |
132 | 132 | info: |
133 | 133 | title: undefined |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | description: Accepted |
141 | 141 | ... |
142 | 142 | ', $output); |
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @covers \SwaggerGen\SwaggerGen::define |
|
148 | - */ |
|
149 | - public function testDefine_NotDefined() |
|
150 | - { |
|
151 | - $object = new \SwaggerGen\SwaggerGen(); |
|
152 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
153 | - |
|
154 | - $array = $object->getSwagger(array(' |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @covers \SwaggerGen\SwaggerGen::define |
|
148 | + */ |
|
149 | + public function testDefine_NotDefined() |
|
150 | + { |
|
151 | + $object = new \SwaggerGen\SwaggerGen(); |
|
152 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
153 | + |
|
154 | + $array = $object->getSwagger(array(' |
|
155 | 155 | endpoint |
156 | 156 | method GET |
157 | 157 | if d |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | response 204 |
161 | 161 | endif |
162 | 162 | ')); |
163 | - $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
164 | - $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @covers \SwaggerGen\SwaggerGen::define |
|
169 | - */ |
|
170 | - public function testDefine_Defined() |
|
171 | - { |
|
172 | - $object = new \SwaggerGen\SwaggerGen(); |
|
173 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
174 | - |
|
175 | - $object->define('d'); |
|
176 | - $array = $object->getSwagger(array(' |
|
163 | + $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
164 | + $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @covers \SwaggerGen\SwaggerGen::define |
|
169 | + */ |
|
170 | + public function testDefine_Defined() |
|
171 | + { |
|
172 | + $object = new \SwaggerGen\SwaggerGen(); |
|
173 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
174 | + |
|
175 | + $object->define('d'); |
|
176 | + $array = $object->getSwagger(array(' |
|
177 | 177 | endpoint |
178 | 178 | method GET |
179 | 179 | if d |
@@ -182,21 +182,21 @@ discard block |
||
182 | 182 | response 204 |
183 | 183 | endif |
184 | 184 | ')); |
185 | - $this->assertArrayHasKey(202, $array['paths']['/']['get']['responses']); |
|
186 | - $this->assertArrayNotHasKey(204, $array['paths']['/']['get']['responses']); |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @covers \SwaggerGen\SwaggerGen::define |
|
191 | - */ |
|
192 | - public function testUndefine() |
|
193 | - { |
|
194 | - $object = new \SwaggerGen\SwaggerGen(); |
|
195 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
196 | - |
|
197 | - $object->define('d'); |
|
198 | - $object->undefine('d'); |
|
199 | - $array = $object->getSwagger(array(' |
|
185 | + $this->assertArrayHasKey(202, $array['paths']['/']['get']['responses']); |
|
186 | + $this->assertArrayNotHasKey(204, $array['paths']['/']['get']['responses']); |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @covers \SwaggerGen\SwaggerGen::define |
|
191 | + */ |
|
192 | + public function testUndefine() |
|
193 | + { |
|
194 | + $object = new \SwaggerGen\SwaggerGen(); |
|
195 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
196 | + |
|
197 | + $object->define('d'); |
|
198 | + $object->undefine('d'); |
|
199 | + $array = $object->getSwagger(array(' |
|
200 | 200 | endpoint |
201 | 201 | method GET |
202 | 202 | if d |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | response 204 |
206 | 206 | endif |
207 | 207 | ')); |
208 | - $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
209 | - $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
210 | - } |
|
208 | + $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
209 | + $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
210 | + } |
|
211 | 211 | } |
@@ -3,128 +3,128 @@ |
||
3 | 3 | class Issue0005Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
8 | - */ |
|
9 | - public function testHandleCommand_Model_Property() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
12 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
13 | - |
|
14 | - $schema = $object->handleCommand('model', 'foo'); |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
16 | - |
|
17 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
18 | - |
|
19 | - $path = $object->handleCommand('endpoint'); |
|
20 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
21 | - |
|
22 | - $this->assertSame(array( |
|
23 | - 'swagger' => '2.0', |
|
24 | - 'info' => array( |
|
25 | - 'title' => 'undefined', |
|
26 | - 'version' => '0', |
|
27 | - ), |
|
28 | - 'paths' => array( |
|
29 | - '/' => array(), |
|
30 | - ), |
|
31 | - 'definitions' => array( |
|
32 | - 'foo' => array( |
|
33 | - 'type' => 'object', |
|
34 | - 'required' => array( |
|
35 | - 'bar', |
|
36 | - ), |
|
37 | - 'properties' => array( |
|
38 | - 'bar' => array( |
|
39 | - 'type' => 'string', |
|
40 | - 'description' => 'Some words here', |
|
41 | - ), |
|
42 | - ), |
|
43 | - ), |
|
44 | - ), |
|
45 | - ), $object->toArray()); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
50 | - */ |
|
51 | - public function testHandleCommand_Model_DuplicateProperties() |
|
52 | - { |
|
53 | - $object = new \SwaggerGen\Swagger\Swagger(); |
|
54 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
55 | - |
|
56 | - $schema = $object->handleCommand('model', 'foo'); |
|
57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
58 | - |
|
59 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
60 | - $schema->handleCommand('property', 'integer bar Some other words'); |
|
61 | - |
|
62 | - $path = $object->handleCommand('endpoint'); |
|
63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
64 | - |
|
65 | - $this->assertSame(array( |
|
66 | - 'swagger' => '2.0', |
|
67 | - 'info' => array( |
|
68 | - 'title' => 'undefined', |
|
69 | - 'version' => '0', |
|
70 | - ), |
|
71 | - 'paths' => array( |
|
72 | - '/' => array(), |
|
73 | - ), |
|
74 | - 'definitions' => array( |
|
75 | - 'foo' => array( |
|
76 | - 'type' => 'object', |
|
77 | - 'required' => array( |
|
78 | - 'bar', |
|
79 | - ), |
|
80 | - 'properties' => array( |
|
81 | - 'bar' => array( |
|
82 | - 'type' => 'integer', |
|
83 | - 'format' => 'int32', |
|
84 | - 'description' => 'Some other words', |
|
85 | - ), |
|
86 | - ), |
|
87 | - ), |
|
88 | - ), |
|
89 | - ), $object->toArray()); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
94 | - */ |
|
95 | - public function testHandleCommand_Query_Duplicate() |
|
96 | - { |
|
97 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
98 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
99 | - |
|
100 | - $operation = new \SwaggerGen\Swagger\Operation($object); |
|
101 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
102 | - |
|
103 | - $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
105 | - |
|
106 | - $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
107 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | - |
|
109 | - $response = $operation->handleCommand('response', '200'); |
|
110 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
111 | - |
|
112 | - $this->assertSame(array( |
|
113 | - 'parameters' => array( |
|
114 | - array( |
|
115 | - 'name' => 'foo', |
|
116 | - 'in' => 'query', |
|
117 | - 'description' => 'Other text', |
|
118 | - 'required' => true, |
|
119 | - 'type' => 'string', |
|
120 | - ), |
|
121 | - ), |
|
122 | - 'responses' => array( |
|
123 | - 200 => array( |
|
124 | - 'description' => 'OK', |
|
125 | - ), |
|
126 | - ), |
|
127 | - ), $operation->toArray()); |
|
128 | - } |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
8 | + */ |
|
9 | + public function testHandleCommand_Model_Property() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
12 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
13 | + |
|
14 | + $schema = $object->handleCommand('model', 'foo'); |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
16 | + |
|
17 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
18 | + |
|
19 | + $path = $object->handleCommand('endpoint'); |
|
20 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
21 | + |
|
22 | + $this->assertSame(array( |
|
23 | + 'swagger' => '2.0', |
|
24 | + 'info' => array( |
|
25 | + 'title' => 'undefined', |
|
26 | + 'version' => '0', |
|
27 | + ), |
|
28 | + 'paths' => array( |
|
29 | + '/' => array(), |
|
30 | + ), |
|
31 | + 'definitions' => array( |
|
32 | + 'foo' => array( |
|
33 | + 'type' => 'object', |
|
34 | + 'required' => array( |
|
35 | + 'bar', |
|
36 | + ), |
|
37 | + 'properties' => array( |
|
38 | + 'bar' => array( |
|
39 | + 'type' => 'string', |
|
40 | + 'description' => 'Some words here', |
|
41 | + ), |
|
42 | + ), |
|
43 | + ), |
|
44 | + ), |
|
45 | + ), $object->toArray()); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
50 | + */ |
|
51 | + public function testHandleCommand_Model_DuplicateProperties() |
|
52 | + { |
|
53 | + $object = new \SwaggerGen\Swagger\Swagger(); |
|
54 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
55 | + |
|
56 | + $schema = $object->handleCommand('model', 'foo'); |
|
57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
58 | + |
|
59 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
60 | + $schema->handleCommand('property', 'integer bar Some other words'); |
|
61 | + |
|
62 | + $path = $object->handleCommand('endpoint'); |
|
63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
64 | + |
|
65 | + $this->assertSame(array( |
|
66 | + 'swagger' => '2.0', |
|
67 | + 'info' => array( |
|
68 | + 'title' => 'undefined', |
|
69 | + 'version' => '0', |
|
70 | + ), |
|
71 | + 'paths' => array( |
|
72 | + '/' => array(), |
|
73 | + ), |
|
74 | + 'definitions' => array( |
|
75 | + 'foo' => array( |
|
76 | + 'type' => 'object', |
|
77 | + 'required' => array( |
|
78 | + 'bar', |
|
79 | + ), |
|
80 | + 'properties' => array( |
|
81 | + 'bar' => array( |
|
82 | + 'type' => 'integer', |
|
83 | + 'format' => 'int32', |
|
84 | + 'description' => 'Some other words', |
|
85 | + ), |
|
86 | + ), |
|
87 | + ), |
|
88 | + ), |
|
89 | + ), $object->toArray()); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
94 | + */ |
|
95 | + public function testHandleCommand_Query_Duplicate() |
|
96 | + { |
|
97 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
98 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
99 | + |
|
100 | + $operation = new \SwaggerGen\Swagger\Operation($object); |
|
101 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
102 | + |
|
103 | + $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
105 | + |
|
106 | + $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
107 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | + |
|
109 | + $response = $operation->handleCommand('response', '200'); |
|
110 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
111 | + |
|
112 | + $this->assertSame(array( |
|
113 | + 'parameters' => array( |
|
114 | + array( |
|
115 | + 'name' => 'foo', |
|
116 | + 'in' => 'query', |
|
117 | + 'description' => 'Other text', |
|
118 | + 'required' => true, |
|
119 | + 'type' => 'string', |
|
120 | + ), |
|
121 | + ), |
|
122 | + 'responses' => array( |
|
123 | + 200 => array( |
|
124 | + 'description' => 'OK', |
|
125 | + ), |
|
126 | + ), |
|
127 | + ), $operation->toArray()); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | class Issue0012Test extends SwaggerGen_TestCase |
8 | 8 | { |
9 | 9 | |
10 | - public function testIssue() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
10 | + public function testIssue() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | api Test |
15 | 15 | endpoint /test |
16 | 16 | method GET something |
17 | 17 | response 200 object(modifications:array(ModificationHistory),users:array(User)) |
18 | 18 | ')); |
19 | 19 | |
20 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
21 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
22 | - . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
23 | - . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
24 | - . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
25 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
26 | - } |
|
20 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
21 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
22 | + . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
23 | + . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
24 | + . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
25 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class Issue0002Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Tests issue 2; @rest/require should create object on each item |
|
8 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
9 | - */ |
|
10 | - public function testRequireMustBeObject() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * Tests issue 2; @rest/require should create object on each item |
|
8 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
9 | + */ |
|
10 | + public function testRequireMustBeObject() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | security api_key apikey X-Api-Authentication header |
15 | 15 | require api_key |
16 | 16 | api Test |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | response 202 |
21 | 21 | ')); |
22 | 22 | |
23 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
25 | - . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
26 | - . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
27 | - } |
|
23 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
25 | + . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
26 | + . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
27 | + } |
|
28 | 28 | |
29 | - public function testRequireAsObjectWithScopes() |
|
30 | - { |
|
31 | - $object = new \SwaggerGen\SwaggerGen(); |
|
32 | - $array = $object->getSwagger(array(' |
|
29 | + public function testRequireAsObjectWithScopes() |
|
30 | + { |
|
31 | + $object = new \SwaggerGen\SwaggerGen(); |
|
32 | + $array = $object->getSwagger(array(' |
|
33 | 33 | security oauth oauth2 implicit http://www.test |
34 | 34 | require oauth user:name |
35 | 35 | api Test |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | response 202 |
40 | 40 | ')); |
41 | 41 | |
42 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
43 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
44 | - . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
45 | - . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
46 | - } |
|
42 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
43 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
44 | + . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
45 | + . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -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 | } |