Completed
Push — master ( fcb010...ba73f2 )
by Martijn
19s
created
tests/Swagger/SecuritySchemeTest.php 1 patch
Indentation   +489 added lines, -489 removed lines patch added patch discarded remove patch
@@ -6,494 +6,494 @@
 block discarded – undo
6 6
 class SecuritySchemeTest extends TestCase
7 7
 {
8 8
 
9
-    protected $parent;
10
-
11
-    /**
12
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
13
-     */
14
-    public function testConstructor_UnknownType()
15
-    {
16
-        $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'");
17
-
18
-        new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong');
19
-    }
20
-
21
-    /**
22
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
23
-     */
24
-    public function testConstructor_Basic()
25
-    {
26
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
27
-
28
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
29
-
30
-        $this->assertSame(array(
31
-            'type' => 'basic',
32
-        ), $object->toArray());
33
-    }
34
-
35
-    /**
36
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
37
-     */
38
-    public function testConstructor_BasicDescription()
39
-    {
40
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text');
41
-
42
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
43
-
44
-        $this->assertSame(array(
45
-            'type' => 'basic',
46
-            'description' => 'Some text',
47
-        ), $object->toArray());
48
-    }
49
-
50
-    /**
51
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
52
-     */
53
-    public function testConstructor_ApiKeyNoName()
54
-    {
55
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"
56
-        );
57
-
58
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey');
59
-    }
60
-
61
-    /**
62
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
63
-     */
64
-    public function testConstructor_ApiKeyNoIn()
65
-    {
66
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''");
67
-
68
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name');
69
-    }
70
-
71
-    /**
72
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
73
-     */
74
-    public function testConstructor_ApiKeyWrongIn()
75
-    {
76
-        $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'");
77
-
78
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad');
79
-    }
80
-
81
-    /**
82
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
83
-     */
84
-    public function testConstructor_ApiKey()
85
-    {
86
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query');
87
-
88
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
89
-
90
-        $this->assertSame(array(
91
-            'type' => 'apiKey',
92
-            'name' => 'Name',
93
-            'in' => 'query',
94
-        ), $object->toArray());
95
-    }
96
-
97
-    /**
98
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
99
-     */
100
-    public function testConstructor_ApiKeyDescription()
101
-    {
102
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words');
103
-
104
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
105
-
106
-        $this->assertSame(array(
107
-            'type' => 'apiKey',
108
-            'description' => 'Some words',
109
-            'name' => 'Name',
110
-            'in' => 'query',
111
-        ), $object->toArray());
112
-    }
113
-
114
-    /**
115
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
116
-     */
117
-    public function testConstructor_Oauth2NoFlow()
118
-    {
119
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''");
120
-
121
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2');
122
-    }
123
-
124
-    /**
125
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
126
-     */
127
-    public function testConstructor_Oauth2WrongFlow()
128
-    {
129
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'");
130
-
131
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow');
132
-    }
133
-
134
-    /**
135
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
136
-     */
137
-    public function testConstructor_Oauth2ImplicitNoUrl()
138
-    {
139
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
140
-
141
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit');
142
-    }
143
-
144
-    /**
145
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
146
-     */
147
-    public function testConstructor_Oauth2ImplicitBadUrl()
148
-    {
149
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
150
-
151
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad');
152
-    }
153
-
154
-    /**
155
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
156
-     */
157
-    public function testConstructor_Oauth2ImplicitUrl()
158
-    {
159
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test');
160
-
161
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
162
-
163
-        $this->assertSame(array(
164
-            'type' => 'oauth2',
165
-            'flow' => 'implicit',
166
-            'authorizationUrl' => 'http://www.test',
167
-        ), $object->toArray());
168
-    }
169
-
170
-    /**
171
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
172
-     */
173
-    public function testConstructor_Oauth2ImplicitUrlDescription()
174
-    {
175
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words');
176
-
177
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
178
-
179
-        $this->assertSame(array(
180
-            'type' => 'oauth2',
181
-            'description' => 'Some words',
182
-            'flow' => 'implicit',
183
-            'authorizationUrl' => 'http://www.test',
184
-        ), $object->toArray());
185
-    }
186
-
187
-    /**
188
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
189
-     */
190
-    public function testConstructor_Oauth2PasswordNoUrl()
191
-    {
192
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
193
-
194
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password');
195
-    }
196
-
197
-    /**
198
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
199
-     */
200
-    public function testConstructor_Oauth2PasswordBadUrl()
201
-    {
202
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
203
-
204
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad');
205
-    }
206
-
207
-    /**
208
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
209
-     */
210
-    public function testConstructor_Oauth2Password()
211
-    {
212
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test');
213
-
214
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
215
-
216
-        $this->assertSame(array(
217
-            'type' => 'oauth2',
218
-            'flow' => 'password',
219
-            'tokenUrl' => 'http://token.test',
220
-        ), $object->toArray());
221
-    }
222
-
223
-    /**
224
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
225
-     */
226
-    public function testConstructor_Oauth2PasswordDescription()
227
-    {
228
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words');
229
-
230
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
231
-
232
-        $this->assertSame(array(
233
-            'type' => 'oauth2',
234
-            'description' => 'Some words',
235
-            'flow' => 'password',
236
-            'tokenUrl' => 'http://token.test',
237
-        ), $object->toArray());
238
-    }
239
-
240
-    /**
241
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
242
-     */
243
-    public function testConstructor_Oauth2ApplicationNoUrl()
244
-    {
245
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
246
-
247
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application');
248
-    }
249
-
250
-    /**
251
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
252
-     */
253
-    public function testConstructor_Oauth2ApplicationBadUrl()
254
-    {
255
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
256
-
257
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad');
258
-    }
259
-
260
-    /**
261
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
262
-     */
263
-    public function testConstructor_Oauth2Application()
264
-    {
265
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test');
266
-
267
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
268
-
269
-        $this->assertSame(array(
270
-            'type' => 'oauth2',
271
-            'flow' => 'application',
272
-            'tokenUrl' => 'http://token.test',
273
-        ), $object->toArray());
274
-    }
275
-
276
-    /**
277
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
278
-     */
279
-    public function testConstructor_Oauth2ApplicationDescription()
280
-    {
281
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words');
282
-
283
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
284
-
285
-        $this->assertSame(array(
286
-            'type' => 'oauth2',
287
-            'description' => 'Some words',
288
-            'flow' => 'application',
289
-            'tokenUrl' => 'http://token.test',
290
-        ), $object->toArray());
291
-    }
292
-
293
-    /**
294
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
295
-     */
296
-    public function testConstructor_Oauth2AccesscodeNoUrl1()
297
-    {
298
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
299
-
300
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode');
301
-    }
302
-
303
-    /**
304
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
305
-     */
306
-    public function testConstructor_Oauth2AccesscodeBadUrl1()
307
-    {
308
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
309
-
310
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad');
311
-    }
312
-
313
-    /**
314
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
315
-     */
316
-    public function testConstructor_Oauth2AccesscodeNoUrl2()
317
-    {
318
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
319
-
320
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test');
321
-    }
322
-
323
-    /**
324
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
325
-     */
326
-    public function testConstructor_Oauth2AccesscodeBadUrl2()
327
-    {
328
-        $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
329
-
330
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad');
331
-    }
332
-
333
-    /**
334
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
335
-     */
336
-    public function testConstructor_Oauth2Accesscode()
337
-    {
338
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
339
-
340
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
341
-
342
-        $this->assertSame(array(
343
-            'type' => 'oauth2',
344
-            'flow' => 'accessCode',
345
-            'authorizationUrl' => 'http://auth.test',
346
-            'tokenUrl' => 'http://token.test',
347
-        ), $object->toArray());
348
-    }
349
-
350
-    /**
351
-     * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
352
-     */
353
-    public function testConstructor_Oauth2AccesscodeDescription()
354
-    {
355
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode  http://auth.test http://token.test Some words');
356
-
357
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
358
-
359
-        $this->assertSame(array(
360
-            'type' => 'oauth2',
361
-            'description' => 'Some words',
362
-            'flow' => 'accessCode',
363
-            'authorizationUrl' => 'http://auth.test',
364
-            'tokenUrl' => 'http://token.test',
365
-        ), $object->toArray());
366
-    }
367
-
368
-    /**
369
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
370
-     */
371
-    public function testCommandDescription()
372
-    {
373
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
374
-
375
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
376
-
377
-        $object->handleCommand('description', 'Some words');
378
-
379
-        $this->assertSame(array(
380
-            'type' => 'oauth2',
381
-            'description' => 'Some words',
382
-            'flow' => 'accessCode',
383
-            'authorizationUrl' => 'http://auth.test',
384
-            'tokenUrl' => 'http://token.test',
385
-        ), $object->toArray());
386
-    }
387
-
388
-    /**
389
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
390
-     */
391
-    public function testCommandDescriptionEmpty()
392
-    {
393
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words');
394
-
395
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
396
-
397
-        $object->handleCommand('description', '');
398
-
399
-        $this->assertSame(array(
400
-            'type' => 'oauth2',
401
-            'flow' => 'accessCode',
402
-            'authorizationUrl' => 'http://auth.test',
403
-            'tokenUrl' => 'http://token.test',
404
-        ), $object->toArray());
405
-    }
406
-
407
-    /**
408
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
409
-     */
410
-    public function testCommandScopeNotOauth()
411
-    {
412
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
413
-
414
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
415
-
416
-        $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'");
417
-
418
-        $object->handleCommand('scope', 'scope1');
419
-    }
420
-
421
-    /**
422
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
423
-     */
424
-    public function testCommandScope()
425
-    {
426
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
427
-
428
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
429
-
430
-        $object->handleCommand('scope', 'scope1');
431
-
432
-        $this->assertSame(array(
433
-            'type' => 'oauth2',
434
-            'flow' => 'accessCode',
435
-            'authorizationUrl' => 'http://auth.test',
436
-            'tokenUrl' => 'http://token.test',
437
-            'scopes' => array(
438
-                'scope1' => '',
439
-            )
440
-        ), $object->toArray());
441
-    }
442
-
443
-    /**
444
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
445
-     */
446
-    public function testCommandScopeDescription()
447
-    {
448
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
449
-
450
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
451
-
452
-        $object->handleCommand('scope', 'scope1 Some text');
453
-
454
-        $this->assertSame(array(
455
-            'type' => 'oauth2',
456
-            'flow' => 'accessCode',
457
-            'authorizationUrl' => 'http://auth.test',
458
-            'tokenUrl' => 'http://token.test',
459
-            'scopes' => array(
460
-                'scope1' => 'Some text',
461
-            )
462
-        ), $object->toArray());
463
-    }
464
-
465
-    /**
466
-     * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
467
-     */
468
-    public function testCommandScopes()
469
-    {
470
-        $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
471
-
472
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
473
-
474
-        $object->handleCommand('scope', 'scope2 Some text');
475
-        $object->handleCommand('scope', 'scope1 Some text');
476
-
477
-        $this->assertSame(array(
478
-            'type' => 'oauth2',
479
-            'flow' => 'accessCode',
480
-            'authorizationUrl' => 'http://auth.test',
481
-            'tokenUrl' => 'http://token.test',
482
-            'scopes' => array(
483
-                'scope2' => 'Some text',
484
-                'scope1' => 'Some text',
485
-            )
486
-        ), $object->toArray());
487
-    }
488
-
489
-    protected function setUp(): void
490
-    {
491
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
492
-    }
493
-
494
-    protected function assertPreConditions(): void
495
-    {
496
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
497
-    }
9
+	protected $parent;
10
+
11
+	/**
12
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
13
+	 */
14
+	public function testConstructor_UnknownType()
15
+	{
16
+		$this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'");
17
+
18
+		new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong');
19
+	}
20
+
21
+	/**
22
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
23
+	 */
24
+	public function testConstructor_Basic()
25
+	{
26
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
27
+
28
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
29
+
30
+		$this->assertSame(array(
31
+			'type' => 'basic',
32
+		), $object->toArray());
33
+	}
34
+
35
+	/**
36
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
37
+	 */
38
+	public function testConstructor_BasicDescription()
39
+	{
40
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text');
41
+
42
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
43
+
44
+		$this->assertSame(array(
45
+			'type' => 'basic',
46
+			'description' => 'Some text',
47
+		), $object->toArray());
48
+	}
49
+
50
+	/**
51
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
52
+	 */
53
+	public function testConstructor_ApiKeyNoName()
54
+	{
55
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"
56
+		);
57
+
58
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey');
59
+	}
60
+
61
+	/**
62
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
63
+	 */
64
+	public function testConstructor_ApiKeyNoIn()
65
+	{
66
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''");
67
+
68
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name');
69
+	}
70
+
71
+	/**
72
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
73
+	 */
74
+	public function testConstructor_ApiKeyWrongIn()
75
+	{
76
+		$this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'");
77
+
78
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad');
79
+	}
80
+
81
+	/**
82
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
83
+	 */
84
+	public function testConstructor_ApiKey()
85
+	{
86
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query');
87
+
88
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
89
+
90
+		$this->assertSame(array(
91
+			'type' => 'apiKey',
92
+			'name' => 'Name',
93
+			'in' => 'query',
94
+		), $object->toArray());
95
+	}
96
+
97
+	/**
98
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
99
+	 */
100
+	public function testConstructor_ApiKeyDescription()
101
+	{
102
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words');
103
+
104
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
105
+
106
+		$this->assertSame(array(
107
+			'type' => 'apiKey',
108
+			'description' => 'Some words',
109
+			'name' => 'Name',
110
+			'in' => 'query',
111
+		), $object->toArray());
112
+	}
113
+
114
+	/**
115
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
116
+	 */
117
+	public function testConstructor_Oauth2NoFlow()
118
+	{
119
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''");
120
+
121
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2');
122
+	}
123
+
124
+	/**
125
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
126
+	 */
127
+	public function testConstructor_Oauth2WrongFlow()
128
+	{
129
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'");
130
+
131
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow');
132
+	}
133
+
134
+	/**
135
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
136
+	 */
137
+	public function testConstructor_Oauth2ImplicitNoUrl()
138
+	{
139
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
140
+
141
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit');
142
+	}
143
+
144
+	/**
145
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
146
+	 */
147
+	public function testConstructor_Oauth2ImplicitBadUrl()
148
+	{
149
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
150
+
151
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad');
152
+	}
153
+
154
+	/**
155
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
156
+	 */
157
+	public function testConstructor_Oauth2ImplicitUrl()
158
+	{
159
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test');
160
+
161
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
162
+
163
+		$this->assertSame(array(
164
+			'type' => 'oauth2',
165
+			'flow' => 'implicit',
166
+			'authorizationUrl' => 'http://www.test',
167
+		), $object->toArray());
168
+	}
169
+
170
+	/**
171
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
172
+	 */
173
+	public function testConstructor_Oauth2ImplicitUrlDescription()
174
+	{
175
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words');
176
+
177
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
178
+
179
+		$this->assertSame(array(
180
+			'type' => 'oauth2',
181
+			'description' => 'Some words',
182
+			'flow' => 'implicit',
183
+			'authorizationUrl' => 'http://www.test',
184
+		), $object->toArray());
185
+	}
186
+
187
+	/**
188
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
189
+	 */
190
+	public function testConstructor_Oauth2PasswordNoUrl()
191
+	{
192
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
193
+
194
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password');
195
+	}
196
+
197
+	/**
198
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
199
+	 */
200
+	public function testConstructor_Oauth2PasswordBadUrl()
201
+	{
202
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
203
+
204
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad');
205
+	}
206
+
207
+	/**
208
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
209
+	 */
210
+	public function testConstructor_Oauth2Password()
211
+	{
212
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test');
213
+
214
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
215
+
216
+		$this->assertSame(array(
217
+			'type' => 'oauth2',
218
+			'flow' => 'password',
219
+			'tokenUrl' => 'http://token.test',
220
+		), $object->toArray());
221
+	}
222
+
223
+	/**
224
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
225
+	 */
226
+	public function testConstructor_Oauth2PasswordDescription()
227
+	{
228
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words');
229
+
230
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
231
+
232
+		$this->assertSame(array(
233
+			'type' => 'oauth2',
234
+			'description' => 'Some words',
235
+			'flow' => 'password',
236
+			'tokenUrl' => 'http://token.test',
237
+		), $object->toArray());
238
+	}
239
+
240
+	/**
241
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
242
+	 */
243
+	public function testConstructor_Oauth2ApplicationNoUrl()
244
+	{
245
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
246
+
247
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application');
248
+	}
249
+
250
+	/**
251
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
252
+	 */
253
+	public function testConstructor_Oauth2ApplicationBadUrl()
254
+	{
255
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
256
+
257
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad');
258
+	}
259
+
260
+	/**
261
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
262
+	 */
263
+	public function testConstructor_Oauth2Application()
264
+	{
265
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test');
266
+
267
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
268
+
269
+		$this->assertSame(array(
270
+			'type' => 'oauth2',
271
+			'flow' => 'application',
272
+			'tokenUrl' => 'http://token.test',
273
+		), $object->toArray());
274
+	}
275
+
276
+	/**
277
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
278
+	 */
279
+	public function testConstructor_Oauth2ApplicationDescription()
280
+	{
281
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words');
282
+
283
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
284
+
285
+		$this->assertSame(array(
286
+			'type' => 'oauth2',
287
+			'description' => 'Some words',
288
+			'flow' => 'application',
289
+			'tokenUrl' => 'http://token.test',
290
+		), $object->toArray());
291
+	}
292
+
293
+	/**
294
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
295
+	 */
296
+	public function testConstructor_Oauth2AccesscodeNoUrl1()
297
+	{
298
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''");
299
+
300
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode');
301
+	}
302
+
303
+	/**
304
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
305
+	 */
306
+	public function testConstructor_Oauth2AccesscodeBadUrl1()
307
+	{
308
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'");
309
+
310
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad');
311
+	}
312
+
313
+	/**
314
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
315
+	 */
316
+	public function testConstructor_Oauth2AccesscodeNoUrl2()
317
+	{
318
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''");
319
+
320
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test');
321
+	}
322
+
323
+	/**
324
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
325
+	 */
326
+	public function testConstructor_Oauth2AccesscodeBadUrl2()
327
+	{
328
+		$this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'");
329
+
330
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad');
331
+	}
332
+
333
+	/**
334
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
335
+	 */
336
+	public function testConstructor_Oauth2Accesscode()
337
+	{
338
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
339
+
340
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
341
+
342
+		$this->assertSame(array(
343
+			'type' => 'oauth2',
344
+			'flow' => 'accessCode',
345
+			'authorizationUrl' => 'http://auth.test',
346
+			'tokenUrl' => 'http://token.test',
347
+		), $object->toArray());
348
+	}
349
+
350
+	/**
351
+	 * @covers \SwaggerGen\Swagger\SecurityScheme::__construct
352
+	 */
353
+	public function testConstructor_Oauth2AccesscodeDescription()
354
+	{
355
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode  http://auth.test http://token.test Some words');
356
+
357
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
358
+
359
+		$this->assertSame(array(
360
+			'type' => 'oauth2',
361
+			'description' => 'Some words',
362
+			'flow' => 'accessCode',
363
+			'authorizationUrl' => 'http://auth.test',
364
+			'tokenUrl' => 'http://token.test',
365
+		), $object->toArray());
366
+	}
367
+
368
+	/**
369
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
370
+	 */
371
+	public function testCommandDescription()
372
+	{
373
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
374
+
375
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
376
+
377
+		$object->handleCommand('description', 'Some words');
378
+
379
+		$this->assertSame(array(
380
+			'type' => 'oauth2',
381
+			'description' => 'Some words',
382
+			'flow' => 'accessCode',
383
+			'authorizationUrl' => 'http://auth.test',
384
+			'tokenUrl' => 'http://token.test',
385
+		), $object->toArray());
386
+	}
387
+
388
+	/**
389
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
390
+	 */
391
+	public function testCommandDescriptionEmpty()
392
+	{
393
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words');
394
+
395
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
396
+
397
+		$object->handleCommand('description', '');
398
+
399
+		$this->assertSame(array(
400
+			'type' => 'oauth2',
401
+			'flow' => 'accessCode',
402
+			'authorizationUrl' => 'http://auth.test',
403
+			'tokenUrl' => 'http://token.test',
404
+		), $object->toArray());
405
+	}
406
+
407
+	/**
408
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
409
+	 */
410
+	public function testCommandScopeNotOauth()
411
+	{
412
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic');
413
+
414
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
415
+
416
+		$this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'");
417
+
418
+		$object->handleCommand('scope', 'scope1');
419
+	}
420
+
421
+	/**
422
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
423
+	 */
424
+	public function testCommandScope()
425
+	{
426
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
427
+
428
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
429
+
430
+		$object->handleCommand('scope', 'scope1');
431
+
432
+		$this->assertSame(array(
433
+			'type' => 'oauth2',
434
+			'flow' => 'accessCode',
435
+			'authorizationUrl' => 'http://auth.test',
436
+			'tokenUrl' => 'http://token.test',
437
+			'scopes' => array(
438
+				'scope1' => '',
439
+			)
440
+		), $object->toArray());
441
+	}
442
+
443
+	/**
444
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
445
+	 */
446
+	public function testCommandScopeDescription()
447
+	{
448
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
449
+
450
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
451
+
452
+		$object->handleCommand('scope', 'scope1 Some text');
453
+
454
+		$this->assertSame(array(
455
+			'type' => 'oauth2',
456
+			'flow' => 'accessCode',
457
+			'authorizationUrl' => 'http://auth.test',
458
+			'tokenUrl' => 'http://token.test',
459
+			'scopes' => array(
460
+				'scope1' => 'Some text',
461
+			)
462
+		), $object->toArray());
463
+	}
464
+
465
+	/**
466
+	 * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand
467
+	 */
468
+	public function testCommandScopes()
469
+	{
470
+		$object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test');
471
+
472
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object);
473
+
474
+		$object->handleCommand('scope', 'scope2 Some text');
475
+		$object->handleCommand('scope', 'scope1 Some text');
476
+
477
+		$this->assertSame(array(
478
+			'type' => 'oauth2',
479
+			'flow' => 'accessCode',
480
+			'authorizationUrl' => 'http://auth.test',
481
+			'tokenUrl' => 'http://token.test',
482
+			'scopes' => array(
483
+				'scope2' => 'Some text',
484
+				'scope1' => 'Some text',
485
+			)
486
+		), $object->toArray());
487
+	}
488
+
489
+	protected function setUp(): void
490
+	{
491
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
492
+	}
493
+
494
+	protected function assertPreConditions(): void
495
+	{
496
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
497
+	}
498 498
 
499 499
 }
Please login to merge, or discard this patch.
tests/Swagger/AbstractDocumentableObjectTest.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@
 block discarded – undo
6 6
 class AbstractDocumentableObjectTest extends TestCase
7 7
 {
8 8
 
9
-    protected $parent;
10
-
11
-    /**
12
-     * @covers \SwaggerGen\Swagger\Tag::__construct
13
-     * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand
14
-     */
15
-    public function testCommandDocWithoutDescription()
16
-    {
17
-        $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name');
18
-
19
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object);
20
-
21
-        $this->assertSame(array(
22
-            'name' => 'Name',
23
-        ), $object->toArray());
24
-
25
-        $object->handleCommand('doc', 'http://example.test');
26
-
27
-        $this->assertSame(array(
28
-            'name' => 'Name',
29
-            'externalDocs' => array(
30
-                'url' => 'http://example.test',
31
-            ),
32
-        ), $object->toArray());
33
-    }
34
-
35
-    /**
36
-     * @covers \SwaggerGen\Swagger\Tag::__construct
37
-     * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand
38
-     */
39
-    public function testCommandDocWithDescription()
40
-    {
41
-        $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name');
42
-
43
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object);
44
-
45
-        $this->assertSame(array(
46
-            'name' => 'Name',
47
-        ), $object->toArray());
48
-
49
-        $object->handleCommand('doc', 'http://example.test Some words here');
50
-
51
-        $this->assertSame(array(
52
-            'name' => 'Name',
53
-            'externalDocs' => array(
54
-                'url' => 'http://example.test',
55
-                'description' => 'Some words here',
56
-            ),
57
-        ), $object->toArray());
58
-    }
59
-
60
-    protected function setUp(): void
61
-    {
62
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
63
-    }
64
-
65
-    protected function assertPreConditions(): void
66
-    {
67
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
68
-    }
9
+	protected $parent;
10
+
11
+	/**
12
+	 * @covers \SwaggerGen\Swagger\Tag::__construct
13
+	 * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand
14
+	 */
15
+	public function testCommandDocWithoutDescription()
16
+	{
17
+		$object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name');
18
+
19
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object);
20
+
21
+		$this->assertSame(array(
22
+			'name' => 'Name',
23
+		), $object->toArray());
24
+
25
+		$object->handleCommand('doc', 'http://example.test');
26
+
27
+		$this->assertSame(array(
28
+			'name' => 'Name',
29
+			'externalDocs' => array(
30
+				'url' => 'http://example.test',
31
+			),
32
+		), $object->toArray());
33
+	}
34
+
35
+	/**
36
+	 * @covers \SwaggerGen\Swagger\Tag::__construct
37
+	 * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand
38
+	 */
39
+	public function testCommandDocWithDescription()
40
+	{
41
+		$object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name');
42
+
43
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object);
44
+
45
+		$this->assertSame(array(
46
+			'name' => 'Name',
47
+		), $object->toArray());
48
+
49
+		$object->handleCommand('doc', 'http://example.test Some words here');
50
+
51
+		$this->assertSame(array(
52
+			'name' => 'Name',
53
+			'externalDocs' => array(
54
+				'url' => 'http://example.test',
55
+				'description' => 'Some words here',
56
+			),
57
+		), $object->toArray());
58
+	}
59
+
60
+	protected function setUp(): void
61
+	{
62
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
63
+	}
64
+
65
+	protected function assertPreConditions(): void
66
+	{
67
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
68
+	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
tests/Swagger/PathTest.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -6,232 +6,232 @@
 block discarded – undo
6 6
 class PathTest extends TestCase
7 7
 {
8 8
 
9
-    protected $parent;
10
-
11
-    /**
12
-     * @covers \SwaggerGen\Swagger\Path::__construct
13
-     */
14
-    public function testConstructor_Empty()
15
-    {
16
-        $object = new \SwaggerGen\Swagger\Path($this->parent);
17
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
18
-
19
-        $this->assertSame(array(), $object->toArray());
20
-    }
21
-
22
-    /**
23
-     * @covers \SwaggerGen\Swagger\Path::__construct
24
-     */
25
-    public function testConstructor_Tag()
26
-    {
27
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
28
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
29
-
30
-        $this->assertSame(array(), $object->toArray());
31
-    }
32
-
33
-    /**
34
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
35
-     */
36
-    public function testHandleCommand_Method_Empty()
37
-    {
38
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
39
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
40
-
41
-        $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''");
42
-        $return = $object->handleCommand('method');
43
-    }
44
-
45
-    /**
46
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
47
-     */
48
-    public function testHandleCommand_Method_Unknown()
49
-    {
50
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
51
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
52
-
53
-        $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'");
54
-        $return = $object->handleCommand('method', 'foo');
55
-    }
56
-
57
-    /**
58
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
59
-     */
60
-    public function testHandleCommand_Method_Get()
61
-    {
62
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
63
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
64
-
65
-        $operation = $object->handleCommand('method', 'get');
66
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
67
-        $operation->handleCommand('response', 200);
68
-
69
-        $this->assertSame(array(
70
-            'get' => array(
71
-                'tags' => array(
72
-                    'Tag',
73
-                ),
74
-                'responses' => array(
75
-                    200 => array(
76
-                        'description' => 'OK',
77
-                    ),
78
-                ),
79
-            ),
80
-        ), $object->toArray());
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
85
-     */
86
-    public function testHandleCommand_Method_Description()
87
-    {
88
-        $this->markTestIncomplete('This test has not been implemented yet.');
89
-    }
90
-
91
-    /**
92
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
93
-     */
94
-    public function testHandleCommand_Operation_Get()
95
-    {
96
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
97
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
98
-
99
-        $operation = $object->handleCommand('operation', 'get');
100
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
101
-        $operation->handleCommand('response', 200);
102
-
103
-        $this->assertSame(array(
104
-            'get' => array(
105
-                'tags' => array(
106
-                    'Tag',
107
-                ),
108
-                'responses' => array(
109
-                    200 => array(
110
-                        'description' => 'OK',
111
-                    ),
112
-                ),
113
-            ),
114
-        ), $object->toArray());
115
-    }
116
-
117
-    /**
118
-     * @covers \SwaggerGen\Swagger\Path::handleCommand
119
-     */
120
-    public function testHandleCommand_MethodOrdering()
121
-    {
122
-        $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
123
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
124
-
125
-        $operation = $object->handleCommand('method', 'post');
126
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
127
-        $operation->handleCommand('response', 200);
128
-
129
-        $operation = $object->handleCommand('method', 'delete');
130
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
131
-        $operation->handleCommand('response', 200);
132
-
133
-        $operation = $object->handleCommand('method', 'patch');
134
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
135
-        $operation->handleCommand('response', 200);
136
-
137
-        $operation = $object->handleCommand('method', 'put');
138
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
139
-        $operation->handleCommand('response', 200);
140
-
141
-        $operation = $object->handleCommand('method', 'head');
142
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
143
-        $operation->handleCommand('response', 200);
144
-
145
-        $operation = $object->handleCommand('method', 'get');
146
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
147
-        $operation->handleCommand('response', 200);
148
-
149
-        $operation = $object->handleCommand('method', 'options');
150
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
151
-        $operation->handleCommand('response', 200);
152
-
153
-        $this->assertSame(array(
154
-            'get' => array(
155
-                'tags' => array(
156
-                    'Tag',
157
-                ),
158
-                'responses' => array(
159
-                    200 => array(
160
-                        'description' => 'OK',
161
-                    ),
162
-                ),
163
-            ),
164
-            'put' => array(
165
-                'tags' => array(
166
-                    'Tag',
167
-                ),
168
-                'responses' => array(
169
-                    200 => array(
170
-                        'description' => 'OK',
171
-                    ),
172
-                ),
173
-            ),
174
-            'post' => array(
175
-                'tags' => array(
176
-                    'Tag',
177
-                ),
178
-                'responses' => array(
179
-                    200 => array(
180
-                        'description' => 'OK',
181
-                    ),
182
-                ),
183
-            ),
184
-            'delete' => array(
185
-                'tags' => array(
186
-                    'Tag',
187
-                ),
188
-                'responses' => array(
189
-                    200 => array(
190
-                        'description' => 'OK',
191
-                    ),
192
-                ),
193
-            ),
194
-            'options' => array(
195
-                'tags' => array(
196
-                    'Tag',
197
-                ),
198
-                'responses' => array(
199
-                    200 => array(
200
-                        'description' => 'OK',
201
-                    ),
202
-                ),
203
-            ),
204
-            'head' => array(
205
-                'tags' => array(
206
-                    'Tag',
207
-                ),
208
-                'responses' => array(
209
-                    200 => array(
210
-                        'description' => 'OK',
211
-                    ),
212
-                ),
213
-            ),
214
-            'patch' => array(
215
-                'tags' => array(
216
-                    'Tag',
217
-                ),
218
-                'responses' => array(
219
-                    200 => array(
220
-                        'description' => 'OK',
221
-                    ),
222
-                ),
223
-            ),
224
-        ), $object->toArray());
225
-    }
226
-
227
-    protected function setUp(): void
228
-    {
229
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
230
-    }
231
-
232
-    protected function assertPreConditions(): void
233
-    {
234
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
235
-    }
9
+	protected $parent;
10
+
11
+	/**
12
+	 * @covers \SwaggerGen\Swagger\Path::__construct
13
+	 */
14
+	public function testConstructor_Empty()
15
+	{
16
+		$object = new \SwaggerGen\Swagger\Path($this->parent);
17
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
18
+
19
+		$this->assertSame(array(), $object->toArray());
20
+	}
21
+
22
+	/**
23
+	 * @covers \SwaggerGen\Swagger\Path::__construct
24
+	 */
25
+	public function testConstructor_Tag()
26
+	{
27
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
28
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
29
+
30
+		$this->assertSame(array(), $object->toArray());
31
+	}
32
+
33
+	/**
34
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
35
+	 */
36
+	public function testHandleCommand_Method_Empty()
37
+	{
38
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
39
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
40
+
41
+		$this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''");
42
+		$return = $object->handleCommand('method');
43
+	}
44
+
45
+	/**
46
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
47
+	 */
48
+	public function testHandleCommand_Method_Unknown()
49
+	{
50
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
51
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
52
+
53
+		$this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'");
54
+		$return = $object->handleCommand('method', 'foo');
55
+	}
56
+
57
+	/**
58
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
59
+	 */
60
+	public function testHandleCommand_Method_Get()
61
+	{
62
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
63
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
64
+
65
+		$operation = $object->handleCommand('method', 'get');
66
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
67
+		$operation->handleCommand('response', 200);
68
+
69
+		$this->assertSame(array(
70
+			'get' => array(
71
+				'tags' => array(
72
+					'Tag',
73
+				),
74
+				'responses' => array(
75
+					200 => array(
76
+						'description' => 'OK',
77
+					),
78
+				),
79
+			),
80
+		), $object->toArray());
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
85
+	 */
86
+	public function testHandleCommand_Method_Description()
87
+	{
88
+		$this->markTestIncomplete('This test has not been implemented yet.');
89
+	}
90
+
91
+	/**
92
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
93
+	 */
94
+	public function testHandleCommand_Operation_Get()
95
+	{
96
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
97
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
98
+
99
+		$operation = $object->handleCommand('operation', 'get');
100
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
101
+		$operation->handleCommand('response', 200);
102
+
103
+		$this->assertSame(array(
104
+			'get' => array(
105
+				'tags' => array(
106
+					'Tag',
107
+				),
108
+				'responses' => array(
109
+					200 => array(
110
+						'description' => 'OK',
111
+					),
112
+				),
113
+			),
114
+		), $object->toArray());
115
+	}
116
+
117
+	/**
118
+	 * @covers \SwaggerGen\Swagger\Path::handleCommand
119
+	 */
120
+	public function testHandleCommand_MethodOrdering()
121
+	{
122
+		$object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag'));
123
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object);
124
+
125
+		$operation = $object->handleCommand('method', 'post');
126
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
127
+		$operation->handleCommand('response', 200);
128
+
129
+		$operation = $object->handleCommand('method', 'delete');
130
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
131
+		$operation->handleCommand('response', 200);
132
+
133
+		$operation = $object->handleCommand('method', 'patch');
134
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
135
+		$operation->handleCommand('response', 200);
136
+
137
+		$operation = $object->handleCommand('method', 'put');
138
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
139
+		$operation->handleCommand('response', 200);
140
+
141
+		$operation = $object->handleCommand('method', 'head');
142
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
143
+		$operation->handleCommand('response', 200);
144
+
145
+		$operation = $object->handleCommand('method', 'get');
146
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
147
+		$operation->handleCommand('response', 200);
148
+
149
+		$operation = $object->handleCommand('method', 'options');
150
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
151
+		$operation->handleCommand('response', 200);
152
+
153
+		$this->assertSame(array(
154
+			'get' => array(
155
+				'tags' => array(
156
+					'Tag',
157
+				),
158
+				'responses' => array(
159
+					200 => array(
160
+						'description' => 'OK',
161
+					),
162
+				),
163
+			),
164
+			'put' => array(
165
+				'tags' => array(
166
+					'Tag',
167
+				),
168
+				'responses' => array(
169
+					200 => array(
170
+						'description' => 'OK',
171
+					),
172
+				),
173
+			),
174
+			'post' => array(
175
+				'tags' => array(
176
+					'Tag',
177
+				),
178
+				'responses' => array(
179
+					200 => array(
180
+						'description' => 'OK',
181
+					),
182
+				),
183
+			),
184
+			'delete' => array(
185
+				'tags' => array(
186
+					'Tag',
187
+				),
188
+				'responses' => array(
189
+					200 => array(
190
+						'description' => 'OK',
191
+					),
192
+				),
193
+			),
194
+			'options' => array(
195
+				'tags' => array(
196
+					'Tag',
197
+				),
198
+				'responses' => array(
199
+					200 => array(
200
+						'description' => 'OK',
201
+					),
202
+				),
203
+			),
204
+			'head' => array(
205
+				'tags' => array(
206
+					'Tag',
207
+				),
208
+				'responses' => array(
209
+					200 => array(
210
+						'description' => 'OK',
211
+					),
212
+				),
213
+			),
214
+			'patch' => array(
215
+				'tags' => array(
216
+					'Tag',
217
+				),
218
+				'responses' => array(
219
+					200 => array(
220
+						'description' => 'OK',
221
+					),
222
+				),
223
+			),
224
+		), $object->toArray());
225
+	}
226
+
227
+	protected function setUp(): void
228
+	{
229
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
230
+	}
231
+
232
+	protected function assertPreConditions(): void
233
+	{
234
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
235
+	}
236 236
 
237 237
 }
Please login to merge, or discard this patch.
tests/Swagger/ParameterTest.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -6,193 +6,193 @@
 block discarded – undo
6 6
 class ParameterTest extends TestCase
7 7
 {
8 8
 
9
-    protected $parent;
10
-
11
-    /**
12
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
13
-     */
14
-    public function testConstructor_InEmpty(): void
15
-    {
16
-        $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''");
17
-
18
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, '', '');
19
-    }
20
-
21
-    /**
22
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
23
-     */
24
-    public function testConstructor_InNotValid(): void
25
-    {
26
-        $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'");
27
-
28
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', '');
29
-    }
30
-
31
-    /**
32
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
33
-     */
34
-    public function testConstructor_DefinitionEmpty(): void
35
-    {
36
-        $this->expectException('\SwaggerGen\Exception', "No type definition for parameter");
37
-
38
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', '');
39
-    }
40
-
41
-    /**
42
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
43
-     */
44
-    public function testConstructor_NameEmpty(): void
45
-    {
46
-        $this->expectException('\SwaggerGen\Exception', "No name for parameter");
47
-
48
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int');
49
-    }
50
-
51
-    /**
52
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
53
-     */
54
-    public function testConstructor_DefinitionUnknownType()
55
-    {
56
-        $this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'");
57
-
58
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar');
59
-    }
60
-
61
-    /**
62
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
63
-     */
64
-    public function testConstructor()
65
-    {
66
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo');
67
-
68
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
69
-
70
-        $this->assertSame(array(
71
-            'name' => 'foo',
72
-            'in' => 'path',
73
-            'required' => true,
74
-            'type' => 'integer',
75
-            'format' => 'int32',
76
-        ), $object->toArray());
77
-    }
78
-
79
-    /**
80
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
81
-     */
82
-    public function testConstructor_PathAlwaysRequired()
83
-    {
84
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false);
85
-
86
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
87
-
88
-        $this->assertSame(array(
89
-            'name' => 'foo',
90
-            'in' => 'path',
91
-            'required' => true,
92
-            'type' => 'integer',
93
-            'format' => 'int32',
94
-        ), $object->toArray());
95
-    }
96
-
97
-    /**
98
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
99
-     */
100
-    public function testConstructor_Optional()
101
-    {
102
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false);
103
-
104
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
105
-
106
-        $this->assertSame(array(
107
-            'name' => 'foo',
108
-            'in' => 'query',
109
-            'type' => 'integer',
110
-            'format' => 'int32',
111
-        ), $object->toArray());
112
-    }
113
-
114
-    /**
115
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
116
-     */
117
-    public function testConstructor_Description()
118
-    {
119
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words');
120
-
121
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
122
-
123
-        $this->assertSame(array(
124
-            'name' => 'foo',
125
-            'in' => 'path',
126
-            'description' => 'Some words',
127
-            'required' => true,
128
-            'type' => 'integer',
129
-            'format' => 'int32',
130
-        ), $object->toArray());
131
-    }
132
-
133
-    /**
134
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
135
-     */
136
-    public function testConstructor_Form()
137
-    {
138
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false);
139
-
140
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
141
-
142
-        $this->assertSame(array(
143
-            'name' => 'foo',
144
-            'in' => 'formData',
145
-            'type' => 'integer',
146
-            'format' => 'int32',
147
-        ), $object->toArray());
148
-    }
149
-
150
-    /**
151
-     * @covers \SwaggerGen\Swagger\Parameter::__construct
152
-     */
153
-    public function testConstructor_Header()
154
-    {
155
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false);
156
-
157
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
158
-
159
-        $this->assertSame(array(
160
-            'name' => 'foo',
161
-            'in' => 'header',
162
-            'type' => 'integer',
163
-            'format' => 'int32',
164
-        ), $object->toArray());
165
-    }
166
-
167
-    /**
168
-     * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand
169
-     */
170
-    public function testHandleCommand_Passing()
171
-    {
172
-        $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false);
173
-
174
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
175
-
176
-        $object->handleCommand('default', '123');
177
-
178
-        $this->assertSame(array(
179
-            'name' => 'foo',
180
-            'in' => 'path',
181
-            'required' => true,
182
-            'type' => 'integer',
183
-            'format' => 'int32',
184
-            'default' => 123,
185
-        ), $object->toArray());
186
-    }
187
-
188
-    protected function setUp(): void
189
-    {
190
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
191
-    }
192
-
193
-    protected function assertPreConditions(): void
194
-    {
195
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
196
-    }
9
+	protected $parent;
10
+
11
+	/**
12
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
13
+	 */
14
+	public function testConstructor_InEmpty(): void
15
+	{
16
+		$this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''");
17
+
18
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, '', '');
19
+	}
20
+
21
+	/**
22
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
23
+	 */
24
+	public function testConstructor_InNotValid(): void
25
+	{
26
+		$this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'");
27
+
28
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', '');
29
+	}
30
+
31
+	/**
32
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
33
+	 */
34
+	public function testConstructor_DefinitionEmpty(): void
35
+	{
36
+		$this->expectException('\SwaggerGen\Exception', "No type definition for parameter");
37
+
38
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', '');
39
+	}
40
+
41
+	/**
42
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
43
+	 */
44
+	public function testConstructor_NameEmpty(): void
45
+	{
46
+		$this->expectException('\SwaggerGen\Exception', "No name for parameter");
47
+
48
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int');
49
+	}
50
+
51
+	/**
52
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
53
+	 */
54
+	public function testConstructor_DefinitionUnknownType()
55
+	{
56
+		$this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'");
57
+
58
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar');
59
+	}
60
+
61
+	/**
62
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
63
+	 */
64
+	public function testConstructor()
65
+	{
66
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo');
67
+
68
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
69
+
70
+		$this->assertSame(array(
71
+			'name' => 'foo',
72
+			'in' => 'path',
73
+			'required' => true,
74
+			'type' => 'integer',
75
+			'format' => 'int32',
76
+		), $object->toArray());
77
+	}
78
+
79
+	/**
80
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
81
+	 */
82
+	public function testConstructor_PathAlwaysRequired()
83
+	{
84
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false);
85
+
86
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
87
+
88
+		$this->assertSame(array(
89
+			'name' => 'foo',
90
+			'in' => 'path',
91
+			'required' => true,
92
+			'type' => 'integer',
93
+			'format' => 'int32',
94
+		), $object->toArray());
95
+	}
96
+
97
+	/**
98
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
99
+	 */
100
+	public function testConstructor_Optional()
101
+	{
102
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false);
103
+
104
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
105
+
106
+		$this->assertSame(array(
107
+			'name' => 'foo',
108
+			'in' => 'query',
109
+			'type' => 'integer',
110
+			'format' => 'int32',
111
+		), $object->toArray());
112
+	}
113
+
114
+	/**
115
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
116
+	 */
117
+	public function testConstructor_Description()
118
+	{
119
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words');
120
+
121
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
122
+
123
+		$this->assertSame(array(
124
+			'name' => 'foo',
125
+			'in' => 'path',
126
+			'description' => 'Some words',
127
+			'required' => true,
128
+			'type' => 'integer',
129
+			'format' => 'int32',
130
+		), $object->toArray());
131
+	}
132
+
133
+	/**
134
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
135
+	 */
136
+	public function testConstructor_Form()
137
+	{
138
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false);
139
+
140
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
141
+
142
+		$this->assertSame(array(
143
+			'name' => 'foo',
144
+			'in' => 'formData',
145
+			'type' => 'integer',
146
+			'format' => 'int32',
147
+		), $object->toArray());
148
+	}
149
+
150
+	/**
151
+	 * @covers \SwaggerGen\Swagger\Parameter::__construct
152
+	 */
153
+	public function testConstructor_Header()
154
+	{
155
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false);
156
+
157
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
158
+
159
+		$this->assertSame(array(
160
+			'name' => 'foo',
161
+			'in' => 'header',
162
+			'type' => 'integer',
163
+			'format' => 'int32',
164
+		), $object->toArray());
165
+	}
166
+
167
+	/**
168
+	 * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand
169
+	 */
170
+	public function testHandleCommand_Passing()
171
+	{
172
+		$object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false);
173
+
174
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object);
175
+
176
+		$object->handleCommand('default', '123');
177
+
178
+		$this->assertSame(array(
179
+			'name' => 'foo',
180
+			'in' => 'path',
181
+			'required' => true,
182
+			'type' => 'integer',
183
+			'format' => 'int32',
184
+			'default' => 123,
185
+		), $object->toArray());
186
+	}
187
+
188
+	protected function setUp(): void
189
+	{
190
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
191
+	}
192
+
193
+	protected function assertPreConditions(): void
194
+	{
195
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
196
+	}
197 197
 
198 198
 }
Please login to merge, or discard this patch.
tests/Swagger/SwaggerTest.php 1 patch
Indentation   +1043 added lines, -1043 removed lines patch added patch discarded remove patch
@@ -6,1048 +6,1048 @@
 block discarded – undo
6 6
 class SwaggerTest extends TestCase
7 7
 {
8 8
 
9
-    /**
10
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
11
-     */
12
-    public function testConstructor_Empty()
13
-    {
14
-        $object = new \SwaggerGen\Swagger\Swagger();
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
16
-
17
-        $this->expectException('\SwaggerGen\Exception', "No path defined");
18
-        $object->toArray();
19
-    }
20
-
21
-    /**
22
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
23
-     */
24
-    public function testConstructor_Empty_WithEndPoint()
25
-    {
26
-        $object = new \SwaggerGen\Swagger\Swagger();
27
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
28
-
29
-        $path = $object->handleCommand('endpoint');
30
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
31
-
32
-        $this->assertSame(array(
33
-            'swagger' => '2.0',
34
-            'info' => array(
35
-                'title' => 'undefined',
36
-                'version' => '0',
37
-            ),
38
-            'paths' => array(
39
-                '/' => array(),
40
-            )
41
-        ), $object->toArray());
42
-    }
43
-
44
-    /**
45
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
46
-     */
47
-    public function testConstructor_Empty_Host()
48
-    {
49
-        $object = new \SwaggerGen\Swagger\Swagger('http://localhost');
50
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
51
-
52
-        $path = $object->handleCommand('endpoint');
53
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
54
-
55
-        $this->assertSame(array(
56
-            'swagger' => '2.0',
57
-            'info' => array(
58
-                'title' => 'undefined',
59
-                'version' => '0',
60
-            ),
61
-            'host' => 'http://localhost',
62
-            'paths' => array(
63
-                '/' => array(),
64
-            )
65
-        ), $object->toArray());
66
-    }
67
-
68
-    /**
69
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
70
-     */
71
-    public function testConstructor_Empty_HostBasepath()
72
-    {
73
-        $object = new \SwaggerGen\Swagger\Swagger('http://localhost', 'api');
74
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
75
-
76
-        $path = $object->handleCommand('endpoint');
77
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
78
-
79
-        $this->assertSame(array(
80
-            'swagger' => '2.0',
81
-            'info' => array(
82
-                'title' => 'undefined',
83
-                'version' => '0',
84
-            ),
85
-            'host' => 'http://localhost',
86
-            'basePath' => 'api',
87
-            'paths' => array(
88
-                '/' => array(),
89
-            )
90
-        ), $object->toArray());
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
95
-     */
96
-    public function testHandleCommand_Info_Pass()
97
-    {
98
-        $object = new \SwaggerGen\Swagger\Swagger('http://localhost', 'api');
99
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
100
-
101
-        $path = $object->handleCommand('endpoint');
102
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
103
-
104
-        $object->handleCommand('title', 'This is the title');
105
-        $object->handleCommand('description', 'This is the description');
106
-        $object->handleCommand('license', 'BSD');
107
-        $object->handleCommand('terms', 'These are the terms');
108
-        $object->handleCommand('version', '1.2.3a');
109
-        $object->handleCommand('title', 'This is the title');
110
-        $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]');
111
-
112
-        $this->assertSame(array(
113
-            'swagger' => '2.0',
114
-            'info' => array('title' => 'This is the title',
115
-                'description' => 'This is the description',
116
-                'termsOfService' => 'These are the terms',
117
-                'contact' => array(
118
-                    'name' => 'Arthur D. Author',
119
-                    'url' => 'http://example.test',
120
-                    'email' => '[email protected]',
121
-                ),
122
-                'license' => array(
123
-                    'name' => 'BSD',
124
-                    'url' => 'https://opensource.org/licenses/BSD-2-Clause',
125
-                ),
126
-                'version' => '1.2.3a',
127
-            ),
128
-            'host' => 'http://localhost',
129
-            'basePath' => 'api',
130
-            'paths' => array(
131
-                '/' => array(),
132
-            )
133
-        ), $object->toArray());
134
-    }
135
-
136
-    /**
137
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
138
-     */
139
-    public function testHandleCommand_Schemes_Empty()
140
-    {
141
-        $object = new \SwaggerGen\Swagger\Swagger();
142
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
143
-
144
-        $return = $object->handleCommand('schemes');
145
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
146
-
147
-        $path = $object->handleCommand('endpoint');
148
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
149
-
150
-        $this->assertSame(array(
151
-            'swagger' => '2.0',
152
-            'info' => array(
153
-                'title' => 'undefined',
154
-                'version' => '0',
155
-            ),
156
-            'paths' => array(
157
-                '/' => array(),
158
-            ),
159
-        ), $object->toArray());
160
-    }
161
-
162
-    /**
163
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
164
-     */
165
-    public function testHandleCommand_Schemes()
166
-    {
167
-        $object = new \SwaggerGen\Swagger\Swagger();
168
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
169
-
170
-        $return = $object->handleCommand('schemes', 'http https');
171
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
172
-
173
-        $path = $object->handleCommand('endpoint');
174
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
175
-
176
-        $this->assertSame(array(
177
-            'swagger' => '2.0',
178
-            'info' => array(
179
-                'title' => 'undefined',
180
-                'version' => '0',
181
-            ),
182
-            'schemes' => array(
183
-                'http',
184
-                'https',
185
-            ),
186
-            'paths' => array(
187
-                '/' => array(),
188
-            ),
189
-        ), $object->toArray());
190
-    }
191
-
192
-    /**
193
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
194
-     */
195
-    public function testHandleCommand_Schemes_Append()
196
-    {
197
-        $object = new \SwaggerGen\Swagger\Swagger();
198
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
199
-
200
-        $return = $object->handleCommand('schemes', 'ws wss');
201
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
202
-
203
-        $return = $object->handleCommand('schemes', 'http ws');
204
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
205
-
206
-        $path = $object->handleCommand('endpoint');
207
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
208
-
209
-        $this->assertSame(array(
210
-            'swagger' => '2.0',
211
-            'info' => array(
212
-                'title' => 'undefined',
213
-                'version' => '0',
214
-            ),
215
-            'schemes' => array(
216
-                'http',
217
-                'ws',
218
-                'wss',
219
-            ),
220
-            'paths' => array(
221
-                '/' => array(),
222
-            ),
223
-        ), $object->toArray());
224
-    }
225
-
226
-    /**
227
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
228
-     */
229
-    public function testHandleCommand_Consumes_Empty()
230
-    {
231
-        $object = new \SwaggerGen\Swagger\Swagger();
232
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
233
-
234
-        $return = $object->handleCommand('consumes');
235
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
236
-
237
-        $path = $object->handleCommand('endpoint');
238
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
239
-
240
-        $this->assertSame(array(
241
-            'swagger' => '2.0',
242
-            'info' => array(
243
-                'title' => 'undefined',
244
-                'version' => '0',
245
-            ),
246
-            'paths' => array(
247
-                '/' => array(),
248
-            ),
249
-        ), $object->toArray());
250
-    }
251
-
252
-    /**
253
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
254
-     */
255
-    public function testHandleCommand_Consumes()
256
-    {
257
-        $object = new \SwaggerGen\Swagger\Swagger();
258
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
259
-
260
-        $return = $object->handleCommand('consumes', 'image/png text');
261
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
262
-
263
-        $path = $object->handleCommand('endpoint');
264
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
265
-
266
-        $this->assertSame(array(
267
-            'swagger' => '2.0',
268
-            'info' => array(
269
-                'title' => 'undefined',
270
-                'version' => '0',
271
-            ),
272
-            'consumes' => array(
273
-                'image/png',
274
-                'text/plain',
275
-            ),
276
-            'paths' => array(
277
-                '/' => array(),
278
-            ),
279
-        ), $object->toArray());
280
-    }
281
-
282
-    /**
283
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
284
-     */
285
-    public function testHandleCommand_Consumes_Append()
286
-    {
287
-        $object = new \SwaggerGen\Swagger\Swagger();
288
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
289
-
290
-        $return = $object->handleCommand('consumes', 'image/png text');
291
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
292
-
293
-        $return = $object->handleCommand('consumes', 'text json');
294
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
295
-
296
-        $path = $object->handleCommand('endpoint');
297
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
298
-
299
-        $this->assertSame(array(
300
-            'swagger' => '2.0',
301
-            'info' => array(
302
-                'title' => 'undefined',
303
-                'version' => '0',
304
-            ),
305
-            'consumes' => array(
306
-                'application/json',
307
-                'image/png',
308
-                'text/plain',
309
-            ),
310
-            'paths' => array(
311
-                '/' => array(),
312
-            ),
313
-        ), $object->toArray());
314
-    }
315
-
316
-    /**
317
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
318
-     */
319
-    public function testHandleCommand_Produces_Empty()
320
-    {
321
-        $object = new \SwaggerGen\Swagger\Swagger();
322
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
323
-
324
-        $return = $object->handleCommand('produces');
325
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
326
-
327
-        $path = $object->handleCommand('endpoint');
328
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
329
-
330
-        $this->assertSame(array(
331
-            'swagger' => '2.0',
332
-            'info' => array(
333
-                'title' => 'undefined',
334
-                'version' => '0',
335
-            ),
336
-            'paths' => array(
337
-                '/' => array(),
338
-            ),
339
-        ), $object->toArray());
340
-    }
341
-
342
-    /**
343
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
344
-     */
345
-    public function testHandleCommand_Produces()
346
-    {
347
-        $object = new \SwaggerGen\Swagger\Swagger();
348
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
349
-
350
-        $return = $object->handleCommand('produces', 'image/png text');
351
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
352
-
353
-        $path = $object->handleCommand('endpoint');
354
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
355
-
356
-        $this->assertSame(array(
357
-            'swagger' => '2.0',
358
-            'info' => array(
359
-                'title' => 'undefined',
360
-                'version' => '0',
361
-            ),
362
-            'produces' => array(
363
-                'image/png',
364
-                'text/plain',
365
-            ),
366
-            'paths' => array(
367
-                '/' => array(),
368
-            ),
369
-        ), $object->toArray());
370
-    }
371
-
372
-    /**
373
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
374
-     */
375
-    public function testHandleCommand_Produces_Append()
376
-    {
377
-        $object = new \SwaggerGen\Swagger\Swagger();
378
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
379
-
380
-        $return = $object->handleCommand('produces', 'image/png text');
381
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
382
-
383
-        $return = $object->handleCommand('produces', 'text json');
384
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
385
-
386
-        $path = $object->handleCommand('endpoint');
387
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
388
-
389
-        $this->assertSame(array(
390
-            'swagger' => '2.0',
391
-            'info' => array(
392
-                'title' => 'undefined',
393
-                'version' => '0',
394
-            ),
395
-            'produces' => array(
396
-                'application/json',
397
-                'image/png',
398
-                'text/plain',
399
-            ),
400
-            'paths' => array(
401
-                '/' => array(),
402
-            ),
403
-        ), $object->toArray());
404
-    }
405
-
406
-    /**
407
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
408
-     */
409
-    public function testHandleCommand_Tag_Empty()
410
-    {
411
-        $object = new \SwaggerGen\Swagger\Swagger();
412
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
413
-
414
-        $this->expectException('\SwaggerGen\Exception', "Missing tag name");
415
-        $object->handleCommand('tag');
416
-    }
417
-
418
-    /**
419
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
420
-     */
421
-    public function testHandleCommand_Tag()
422
-    {
423
-        $object = new \SwaggerGen\Swagger\Swagger();
424
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
425
-
426
-        $return = $object->handleCommand('tag', 'Users');
427
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
428
-
429
-        $path = $object->handleCommand('endpoint');
430
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
431
-        $operation = $path->handleCommand('method', 'get');
432
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
433
-        $response = $operation->handleCommand('response', 200);
434
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
435
-
436
-        $this->assertSame(array(
437
-            'swagger' => '2.0',
438
-            'info' => array(
439
-                'title' => 'undefined',
440
-                'version' => '0',
441
-            ),
442
-            'paths' => array(
443
-                '/' => array(
444
-                    'get' => array(
445
-                        'responses' => array(
446
-                            200 => array(
447
-                                'description' => 'OK',
448
-                            ),
449
-                        ),
450
-                    ),
451
-                ),
452
-            ),
453
-            'tags' => array(
454
-                array(
455
-                    'name' => 'Users',
456
-                ),
457
-            ),
458
-        ), $object->toArray());
459
-    }
460
-
461
-    /**
462
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
463
-     */
464
-    public function testHandleCommand_Api()
465
-    {
466
-        $object = new \SwaggerGen\Swagger\Swagger();
467
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
468
-
469
-        $return = $object->handleCommand('api', 'Users');
470
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
471
-
472
-        $path = $object->handleCommand('endpoint');
473
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
474
-        $operation = $path->handleCommand('method', 'get');
475
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
476
-        $response = $operation->handleCommand('response', 200);
477
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
478
-
479
-        $this->assertSame(array(
480
-            'swagger' => '2.0',
481
-            'info' => array(
482
-                'title' => 'undefined',
483
-                'version' => '0',
484
-            ),
485
-            'paths' => array(
486
-                '/' => array(
487
-                    'get' => array(
488
-                        'tags' => array(
489
-                            'Users',
490
-                        ),
491
-                        'responses' => array(
492
-                            200 => array(
493
-                                'description' => 'OK',
494
-                            ),
495
-                        ),
496
-                    ),
497
-                ),
498
-            ),
499
-            'tags' => array(
500
-                array(
501
-                    'name' => 'Users',
502
-                ),
503
-            ),
504
-        ), $object->toArray());
505
-    }
506
-
507
-    /**
508
-     * @covers \SwaggerGen\Swagger\Swagger::handleCommand
509
-     */
510
-    public function testHandleCommand_Tag_Repeat()
511
-    {
512
-        $object = new \SwaggerGen\Swagger\Swagger();
513
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
514
-
515
-        $return = $object->handleCommand('tag', 'Users Info A');
516
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
517
-
518
-        $return = $object->handleCommand('tag', 'Users Info B');
519
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
520
-
521
-        $path = $object->handleCommand('endpoint');
522
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
523
-
524
-        $this->assertSame(array(
525
-            'swagger' => '2.0',
526
-            'info' => array(
527
-                'title' => 'undefined',
528
-                'version' => '0',
529
-            ),
530
-            'paths' => array(
531
-                '/' => array(),
532
-            ),
533
-            'tags' => array(
534
-                array(
535
-                    'name' => 'Users',
536
-                    'description' => 'Info A',
537
-                ),
538
-            ),
539
-        ), $object->toArray());
540
-    }
541
-
542
-    /**
543
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
544
-     */
545
-    public function testHandleCommand_EndPoint_Empty()
546
-    {
547
-        $object = new \SwaggerGen\Swagger\Swagger();
548
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
549
-
550
-        $path = $object->handleCommand('endpoint');
551
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
552
-
553
-        $this->assertSame(array(
554
-            'swagger' => '2.0',
555
-            'info' => array(
556
-                'title' => 'undefined',
557
-                'version' => '0',
558
-            ),
559
-            'paths' => array(
560
-                '/' => array(),
561
-            )
562
-        ), $object->toArray());
563
-    }
564
-
565
-    /**
566
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
567
-     */
568
-    public function testHandleCommand_EndPoint()
569
-    {
570
-        $object = new \SwaggerGen\Swagger\Swagger();
571
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
572
-
573
-        $path = $object->handleCommand('endpoint', 'users/:userid/rights');
574
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
575
-
576
-        $this->assertSame(array(
577
-            'swagger' => '2.0',
578
-            'info' => array(
579
-                'title' => 'undefined',
580
-                'version' => '0',
581
-            ),
582
-            'paths' => array(
583
-                '/users/:userid/rights' => array(),
584
-            )
585
-        ), $object->toArray());
586
-    }
587
-
588
-    /**
589
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
590
-     */
591
-    public function testHandleCommand_EndPoint_Tag()
592
-    {
593
-        $object = new \SwaggerGen\Swagger\Swagger();
594
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
595
-
596
-        $path = $object->handleCommand('endpoint', 'users/:userid/rights Users');
597
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
598
-
599
-        $this->assertSame(array(
600
-            'swagger' => '2.0',
601
-            'info' => array(
602
-                'title' => 'undefined',
603
-                'version' => '0',
604
-            ),
605
-            'paths' => array(
606
-                '/users/:userid/rights' => array(),
607
-            ),
608
-            'tags' => array(
609
-                array(
610
-                    'name' => 'Users',
611
-                ),
612
-            ),
613
-        ), $object->toArray());
614
-    }
615
-
616
-    /**
617
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
618
-     */
619
-    public function testHandleCommand_EndPoint_Tag_NoDescriptionOverwrite()
620
-    {
621
-        $object = new \SwaggerGen\Swagger\Swagger();
622
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
623
-
624
-        $path = $object->handleCommand('api', 'Users something here');
625
-        $path = $object->handleCommand('endpoint', 'users/:userid/rights Users');
626
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
627
-
628
-        $this->assertSame(array(
629
-            'swagger' => '2.0',
630
-            'info' => array(
631
-                'title' => 'undefined',
632
-                'version' => '0',
633
-            ),
634
-            'paths' => array(
635
-                '/users/:userid/rights' => array(),
636
-            ),
637
-            'tags' => array(
638
-                array(
639
-                    'name' => 'Users',
640
-                    'description' => 'something here',
641
-                ),
642
-            ),
643
-        ), $object->toArray());
644
-    }
645
-
646
-    /**
647
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
648
-     */
649
-    public function testHandleCommand_EndPoint_Tag_Description()
650
-    {
651
-        $object = new \SwaggerGen\Swagger\Swagger();
652
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
653
-
654
-        $path = $object->handleCommand('endpoint', 'users/:userid/rights Users Description here');
655
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
656
-
657
-        $this->assertSame(array(
658
-            'swagger' => '2.0',
659
-            'info' => array(
660
-                'title' => 'undefined',
661
-                'version' => '0',
662
-            ),
663
-            'paths' => array(
664
-                '/users/:userid/rights' => array(),
665
-            ),
666
-            'tags' => array(
667
-                array(
668
-                    'name' => 'Users',
669
-                    'description' => 'Description here',
670
-                ),
671
-            ),
672
-        ), $object->toArray());
673
-    }
674
-
675
-    /**
676
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
677
-     */
678
-    public function testHandleCommand_Security_Empty()
679
-    {
680
-        $object = new \SwaggerGen\Swagger\Swagger();
681
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
682
-
683
-        $this->expectException('\SwaggerGen\Exception', "Missing security name");
684
-        $path = $object->handleCommand('security');
685
-    }
686
-
687
-    /**
688
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
689
-     */
690
-    public function testHandleCommand_Security_MissingType()
691
-    {
692
-        $object = new \SwaggerGen\Swagger\Swagger();
693
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
694
-
695
-        $this->expectException('\SwaggerGen\Exception', "Missing security type");
696
-        $path = $object->handleCommand('security', 'foo');
697
-    }
698
-
699
-    /**
700
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
701
-     */
702
-    public function testHandleCommand_Security_BadType()
703
-    {
704
-        $object = new \SwaggerGen\Swagger\Swagger();
705
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
706
-
707
-        $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'bad'");
708
-        $path = $object->handleCommand('security', 'foo bad');
709
-    }
710
-
711
-    /**
712
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
713
-     */
714
-    public function testHandleCommand_Security()
715
-    {
716
-        $object = new \SwaggerGen\Swagger\Swagger();
717
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
718
-
719
-        $security = $object->handleCommand('security', 'foo basic');
720
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $security);
721
-
722
-        $path = $object->handleCommand('endpoint');
723
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
724
-
725
-        $this->assertSame(array(
726
-            'swagger' => '2.0',
727
-            'info' => array(
728
-                'title' => 'undefined',
729
-                'version' => '0',
730
-            ),
731
-            'paths' => array(
732
-                '/' => array(),
733
-            ),
734
-            'securityDefinitions' => array(
735
-                'foo' => array(
736
-                    'type' => 'basic',
737
-                ),
738
-            ),
739
-        ), $object->toArray());
740
-    }
741
-
742
-    /**
743
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
744
-     */
745
-    public function testHandleCommand_Require_Empty()
746
-    {
747
-        $object = new \SwaggerGen\Swagger\Swagger();
748
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
749
-
750
-        $this->expectException('\SwaggerGen\Exception', "Missing require name");
751
-        $object->handleCommand('require');
752
-    }
753
-
754
-    /**
755
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
756
-     */
757
-    public function testHandleCommand_Require_Undefined()
758
-    {
759
-        $object = new \SwaggerGen\Swagger\Swagger();
760
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
761
-
762
-        $return = $object->handleCommand('require', 'foo');
763
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
764
-
765
-        $path = $object->handleCommand('endpoint');
766
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
767
-
768
-        $this->expectException('\SwaggerGen\Exception', "Required security scheme not defined: 'foo'");
769
-        $object->toArray();
770
-    }
771
-
772
-    /**
773
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
774
-     */
775
-    public function testHandleCommand_Require()
776
-    {
777
-        $object = new \SwaggerGen\Swagger\Swagger();
778
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
779
-
780
-        $return = $object->handleCommand('require', 'foo');
781
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
782
-
783
-        $security = $object->handleCommand('security', 'foo basic');
784
-        $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $security);
785
-
786
-        $path = $object->handleCommand('endpoint');
787
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
788
-
789
-        $this->assertEquals(array(
790
-            'swagger' => '2.0',
791
-            'info' => array(
792
-                'title' => 'undefined',
793
-                'version' => '0',
794
-            ),
795
-            'paths' => array(
796
-                '/' => array(),
797
-            ),
798
-            'securityDefinitions' => array(
799
-                'foo' => array(
800
-                    'type' => 'basic',
801
-                ),
802
-            ),
803
-            'security' => array(
804
-                array(
805
-                    'foo' => array(),
806
-                ),
807
-            ),
808
-        ), $object->toArray());
809
-    }
810
-
811
-    /**
812
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
813
-     */
814
-    public function testHandleCommand_Definition_Empty()
815
-    {
816
-        $object = new \SwaggerGen\Swagger\Swagger();
817
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
818
-
819
-        $this->expectException('\SwaggerGen\Exception', "Missing definition name");
820
-        $object->handleCommand('definition');
821
-    }
822
-
823
-    /**
824
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
825
-     */
826
-    public function testHandleCommand_Definition_NoName()
827
-    {
828
-        $object = new \SwaggerGen\Swagger\Swagger();
829
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
830
-
831
-        $this->expectException('\SwaggerGen\Exception', "Missing definition name");
832
-        $object->handleCommand('definition', '');
833
-    }
834
-
835
-    /**
836
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
837
-     */
838
-    public function testHandleCommand_Definition()
839
-    {
840
-        $object = new \SwaggerGen\Swagger\Swagger();
841
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
842
-
843
-        $schema = $object->handleCommand('definition', 'foo');
844
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
845
-
846
-
847
-        $path = $object->handleCommand('endpoint');
848
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
849
-
850
-        $this->assertSame(array(
851
-            'swagger' => '2.0',
852
-            'info' => array(
853
-                'title' => 'undefined',
854
-                'version' => '0',
855
-            ),
856
-            'paths' => array(
857
-                '/' => array(),
858
-            ),
859
-            'definitions' => array(
860
-                'foo' => array(
861
-                    'type' => 'object',
862
-                ),
863
-            ),
864
-        ), $object->toArray());
865
-    }
866
-
867
-    /**
868
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
869
-     */
870
-    public function testHandleCommand_Definition_ReadOnly()
871
-    {
872
-        $object = new \SwaggerGen\Swagger\Swagger();
873
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
874
-
875
-        $schema = $object->handleCommand('definition!', 'foo');
876
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
877
-
878
-
879
-        $path = $object->handleCommand('endpoint');
880
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
881
-
882
-        $this->assertSame(array(
883
-            'swagger' => '2.0',
884
-            'info' => array(
885
-                'title' => 'undefined',
886
-                'version' => '0',
887
-            ),
888
-            'paths' => array(
889
-                '/' => array(),
890
-            ),
891
-            'definitions' => array(
892
-                'foo' => array(
893
-                    'type' => 'object',
894
-                    'readOnly' => true,
895
-                ),
896
-            ),
897
-        ), $object->toArray());
898
-    }
899
-
900
-    /**
901
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
902
-     */
903
-    public function testHandleCommand_Model()
904
-    {
905
-        $object = new \SwaggerGen\Swagger\Swagger();
906
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
907
-
908
-        $schema = $object->handleCommand('model', 'foo');
909
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
910
-
911
-        $path = $object->handleCommand('endpoint');
912
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
913
-
914
-        $this->assertSame(array(
915
-            'swagger' => '2.0',
916
-            'info' => array(
917
-                'title' => 'undefined',
918
-                'version' => '0',
919
-            ),
920
-            'paths' => array(
921
-                '/' => array(),
922
-            ),
923
-            'definitions' => array(
924
-                'foo' => array(
925
-                    'type' => 'object',
926
-                ),
927
-            ),
928
-        ), $object->toArray());
929
-    }
930
-
931
-    /**
932
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
933
-     */
934
-    public function testHandleCommand_Model_ReadOnly()
935
-    {
936
-        $object = new \SwaggerGen\Swagger\Swagger();
937
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
938
-
939
-        $schema = $object->handleCommand('model!', 'foo');
940
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
941
-
942
-        $path = $object->handleCommand('endpoint');
943
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
944
-
945
-        $this->assertSame(array(
946
-            'swagger' => '2.0',
947
-            'info' => array(
948
-                'title' => 'undefined',
949
-                'version' => '0',
950
-            ),
951
-            'paths' => array(
952
-                '/' => array(),
953
-            ),
954
-            'definitions' => array(
955
-                'foo' => array(
956
-                    'type' => 'object',
957
-                    'readOnly' => true,
958
-                ),
959
-            ),
960
-        ), $object->toArray());
961
-    }
962
-
963
-    /**
964
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
965
-     */
966
-    public function testHandleCommand_Response_NoType()
967
-    {
968
-        $object = new \SwaggerGen\Swagger\Swagger();
969
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
970
-
971
-        $this->expectException('\SwaggerGen\Exception', "Response definition missing description");
972
-        $response = $object->handleCommand('response', 'NotFound');
973
-    }
974
-
975
-    /**
976
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
977
-     */
978
-    public function testHandleCommand_Response_NoDescription()
979
-    {
980
-        $object = new \SwaggerGen\Swagger\Swagger();
981
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
982
-
983
-        $this->expectException('\SwaggerGen\Exception', "Response definition missing description");
984
-        $response = $object->handleCommand('response', 'NotFound null');
985
-    }
986
-
987
-    /**
988
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
989
-     */
990
-    public function testHandleCommand_Response_WithoutDefinition()
991
-    {
992
-        $object = new \SwaggerGen\Swagger\Swagger();
993
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
994
-
995
-        $response = $object->handleCommand('response', 'NotFound null Entity not found');
996
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
997
-
998
-        $path = $object->handleCommand('endpoint');
999
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
1000
-
1001
-        $this->assertSame(array(
1002
-            'swagger' => '2.0',
1003
-            'info' => array(
1004
-                'title' => 'undefined',
1005
-                'version' => '0',
1006
-            ),
1007
-            'paths' => array(
1008
-                '/' => array(),
1009
-            ),
1010
-            'responses' => array(
1011
-                'NotFound' => array(
1012
-                    'description' => 'Entity not found',
1013
-                ),
1014
-            ),
1015
-        ), $object->toArray());
1016
-    }
1017
-
1018
-    /**
1019
-     * @covers \SwaggerGen\Swagger\Swagger::__construct
1020
-     */
1021
-    public function testHandleCommand_Response_WithDefinition()
1022
-    {
1023
-        $object = new \SwaggerGen\Swagger\Swagger();
1024
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
1025
-
1026
-        $response = $object->handleCommand('response', 'NotFound int Entity not found');
1027
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
1028
-
1029
-        $path = $object->handleCommand('endpoint');
1030
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
1031
-
1032
-        $this->assertSame(array(
1033
-            'swagger' => '2.0',
1034
-            'info' => array(
1035
-                'title' => 'undefined',
1036
-                'version' => '0',
1037
-            ),
1038
-            'paths' => array(
1039
-                '/' => array(),
1040
-            ),
1041
-            'responses' => array(
1042
-                'NotFound' => array(
1043
-                    'description' => 'Entity not found',
1044
-                    'schema' => array(
1045
-                        'type' => 'integer',
1046
-                        'format' => 'int32'
1047
-                    ),
1048
-                ),
1049
-            ),
1050
-        ), $object->toArray());
1051
-    }
9
+	/**
10
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
11
+	 */
12
+	public function testConstructor_Empty()
13
+	{
14
+		$object = new \SwaggerGen\Swagger\Swagger();
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
16
+
17
+		$this->expectException('\SwaggerGen\Exception', "No path defined");
18
+		$object->toArray();
19
+	}
20
+
21
+	/**
22
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
23
+	 */
24
+	public function testConstructor_Empty_WithEndPoint()
25
+	{
26
+		$object = new \SwaggerGen\Swagger\Swagger();
27
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
28
+
29
+		$path = $object->handleCommand('endpoint');
30
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
31
+
32
+		$this->assertSame(array(
33
+			'swagger' => '2.0',
34
+			'info' => array(
35
+				'title' => 'undefined',
36
+				'version' => '0',
37
+			),
38
+			'paths' => array(
39
+				'/' => array(),
40
+			)
41
+		), $object->toArray());
42
+	}
43
+
44
+	/**
45
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
46
+	 */
47
+	public function testConstructor_Empty_Host()
48
+	{
49
+		$object = new \SwaggerGen\Swagger\Swagger('http://localhost');
50
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
51
+
52
+		$path = $object->handleCommand('endpoint');
53
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
54
+
55
+		$this->assertSame(array(
56
+			'swagger' => '2.0',
57
+			'info' => array(
58
+				'title' => 'undefined',
59
+				'version' => '0',
60
+			),
61
+			'host' => 'http://localhost',
62
+			'paths' => array(
63
+				'/' => array(),
64
+			)
65
+		), $object->toArray());
66
+	}
67
+
68
+	/**
69
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
70
+	 */
71
+	public function testConstructor_Empty_HostBasepath()
72
+	{
73
+		$object = new \SwaggerGen\Swagger\Swagger('http://localhost', 'api');
74
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
75
+
76
+		$path = $object->handleCommand('endpoint');
77
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
78
+
79
+		$this->assertSame(array(
80
+			'swagger' => '2.0',
81
+			'info' => array(
82
+				'title' => 'undefined',
83
+				'version' => '0',
84
+			),
85
+			'host' => 'http://localhost',
86
+			'basePath' => 'api',
87
+			'paths' => array(
88
+				'/' => array(),
89
+			)
90
+		), $object->toArray());
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
95
+	 */
96
+	public function testHandleCommand_Info_Pass()
97
+	{
98
+		$object = new \SwaggerGen\Swagger\Swagger('http://localhost', 'api');
99
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
100
+
101
+		$path = $object->handleCommand('endpoint');
102
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
103
+
104
+		$object->handleCommand('title', 'This is the title');
105
+		$object->handleCommand('description', 'This is the description');
106
+		$object->handleCommand('license', 'BSD');
107
+		$object->handleCommand('terms', 'These are the terms');
108
+		$object->handleCommand('version', '1.2.3a');
109
+		$object->handleCommand('title', 'This is the title');
110
+		$object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]');
111
+
112
+		$this->assertSame(array(
113
+			'swagger' => '2.0',
114
+			'info' => array('title' => 'This is the title',
115
+				'description' => 'This is the description',
116
+				'termsOfService' => 'These are the terms',
117
+				'contact' => array(
118
+					'name' => 'Arthur D. Author',
119
+					'url' => 'http://example.test',
120
+					'email' => '[email protected]',
121
+				),
122
+				'license' => array(
123
+					'name' => 'BSD',
124
+					'url' => 'https://opensource.org/licenses/BSD-2-Clause',
125
+				),
126
+				'version' => '1.2.3a',
127
+			),
128
+			'host' => 'http://localhost',
129
+			'basePath' => 'api',
130
+			'paths' => array(
131
+				'/' => array(),
132
+			)
133
+		), $object->toArray());
134
+	}
135
+
136
+	/**
137
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
138
+	 */
139
+	public function testHandleCommand_Schemes_Empty()
140
+	{
141
+		$object = new \SwaggerGen\Swagger\Swagger();
142
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
143
+
144
+		$return = $object->handleCommand('schemes');
145
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
146
+
147
+		$path = $object->handleCommand('endpoint');
148
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
149
+
150
+		$this->assertSame(array(
151
+			'swagger' => '2.0',
152
+			'info' => array(
153
+				'title' => 'undefined',
154
+				'version' => '0',
155
+			),
156
+			'paths' => array(
157
+				'/' => array(),
158
+			),
159
+		), $object->toArray());
160
+	}
161
+
162
+	/**
163
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
164
+	 */
165
+	public function testHandleCommand_Schemes()
166
+	{
167
+		$object = new \SwaggerGen\Swagger\Swagger();
168
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
169
+
170
+		$return = $object->handleCommand('schemes', 'http https');
171
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
172
+
173
+		$path = $object->handleCommand('endpoint');
174
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
175
+
176
+		$this->assertSame(array(
177
+			'swagger' => '2.0',
178
+			'info' => array(
179
+				'title' => 'undefined',
180
+				'version' => '0',
181
+			),
182
+			'schemes' => array(
183
+				'http',
184
+				'https',
185
+			),
186
+			'paths' => array(
187
+				'/' => array(),
188
+			),
189
+		), $object->toArray());
190
+	}
191
+
192
+	/**
193
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
194
+	 */
195
+	public function testHandleCommand_Schemes_Append()
196
+	{
197
+		$object = new \SwaggerGen\Swagger\Swagger();
198
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
199
+
200
+		$return = $object->handleCommand('schemes', 'ws wss');
201
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
202
+
203
+		$return = $object->handleCommand('schemes', 'http ws');
204
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
205
+
206
+		$path = $object->handleCommand('endpoint');
207
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
208
+
209
+		$this->assertSame(array(
210
+			'swagger' => '2.0',
211
+			'info' => array(
212
+				'title' => 'undefined',
213
+				'version' => '0',
214
+			),
215
+			'schemes' => array(
216
+				'http',
217
+				'ws',
218
+				'wss',
219
+			),
220
+			'paths' => array(
221
+				'/' => array(),
222
+			),
223
+		), $object->toArray());
224
+	}
225
+
226
+	/**
227
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
228
+	 */
229
+	public function testHandleCommand_Consumes_Empty()
230
+	{
231
+		$object = new \SwaggerGen\Swagger\Swagger();
232
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
233
+
234
+		$return = $object->handleCommand('consumes');
235
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
236
+
237
+		$path = $object->handleCommand('endpoint');
238
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
239
+
240
+		$this->assertSame(array(
241
+			'swagger' => '2.0',
242
+			'info' => array(
243
+				'title' => 'undefined',
244
+				'version' => '0',
245
+			),
246
+			'paths' => array(
247
+				'/' => array(),
248
+			),
249
+		), $object->toArray());
250
+	}
251
+
252
+	/**
253
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
254
+	 */
255
+	public function testHandleCommand_Consumes()
256
+	{
257
+		$object = new \SwaggerGen\Swagger\Swagger();
258
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
259
+
260
+		$return = $object->handleCommand('consumes', 'image/png text');
261
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
262
+
263
+		$path = $object->handleCommand('endpoint');
264
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
265
+
266
+		$this->assertSame(array(
267
+			'swagger' => '2.0',
268
+			'info' => array(
269
+				'title' => 'undefined',
270
+				'version' => '0',
271
+			),
272
+			'consumes' => array(
273
+				'image/png',
274
+				'text/plain',
275
+			),
276
+			'paths' => array(
277
+				'/' => array(),
278
+			),
279
+		), $object->toArray());
280
+	}
281
+
282
+	/**
283
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
284
+	 */
285
+	public function testHandleCommand_Consumes_Append()
286
+	{
287
+		$object = new \SwaggerGen\Swagger\Swagger();
288
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
289
+
290
+		$return = $object->handleCommand('consumes', 'image/png text');
291
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
292
+
293
+		$return = $object->handleCommand('consumes', 'text json');
294
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
295
+
296
+		$path = $object->handleCommand('endpoint');
297
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
298
+
299
+		$this->assertSame(array(
300
+			'swagger' => '2.0',
301
+			'info' => array(
302
+				'title' => 'undefined',
303
+				'version' => '0',
304
+			),
305
+			'consumes' => array(
306
+				'application/json',
307
+				'image/png',
308
+				'text/plain',
309
+			),
310
+			'paths' => array(
311
+				'/' => array(),
312
+			),
313
+		), $object->toArray());
314
+	}
315
+
316
+	/**
317
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
318
+	 */
319
+	public function testHandleCommand_Produces_Empty()
320
+	{
321
+		$object = new \SwaggerGen\Swagger\Swagger();
322
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
323
+
324
+		$return = $object->handleCommand('produces');
325
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
326
+
327
+		$path = $object->handleCommand('endpoint');
328
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
329
+
330
+		$this->assertSame(array(
331
+			'swagger' => '2.0',
332
+			'info' => array(
333
+				'title' => 'undefined',
334
+				'version' => '0',
335
+			),
336
+			'paths' => array(
337
+				'/' => array(),
338
+			),
339
+		), $object->toArray());
340
+	}
341
+
342
+	/**
343
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
344
+	 */
345
+	public function testHandleCommand_Produces()
346
+	{
347
+		$object = new \SwaggerGen\Swagger\Swagger();
348
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
349
+
350
+		$return = $object->handleCommand('produces', 'image/png text');
351
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
352
+
353
+		$path = $object->handleCommand('endpoint');
354
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
355
+
356
+		$this->assertSame(array(
357
+			'swagger' => '2.0',
358
+			'info' => array(
359
+				'title' => 'undefined',
360
+				'version' => '0',
361
+			),
362
+			'produces' => array(
363
+				'image/png',
364
+				'text/plain',
365
+			),
366
+			'paths' => array(
367
+				'/' => array(),
368
+			),
369
+		), $object->toArray());
370
+	}
371
+
372
+	/**
373
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
374
+	 */
375
+	public function testHandleCommand_Produces_Append()
376
+	{
377
+		$object = new \SwaggerGen\Swagger\Swagger();
378
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
379
+
380
+		$return = $object->handleCommand('produces', 'image/png text');
381
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
382
+
383
+		$return = $object->handleCommand('produces', 'text json');
384
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
385
+
386
+		$path = $object->handleCommand('endpoint');
387
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
388
+
389
+		$this->assertSame(array(
390
+			'swagger' => '2.0',
391
+			'info' => array(
392
+				'title' => 'undefined',
393
+				'version' => '0',
394
+			),
395
+			'produces' => array(
396
+				'application/json',
397
+				'image/png',
398
+				'text/plain',
399
+			),
400
+			'paths' => array(
401
+				'/' => array(),
402
+			),
403
+		), $object->toArray());
404
+	}
405
+
406
+	/**
407
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
408
+	 */
409
+	public function testHandleCommand_Tag_Empty()
410
+	{
411
+		$object = new \SwaggerGen\Swagger\Swagger();
412
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
413
+
414
+		$this->expectException('\SwaggerGen\Exception', "Missing tag name");
415
+		$object->handleCommand('tag');
416
+	}
417
+
418
+	/**
419
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
420
+	 */
421
+	public function testHandleCommand_Tag()
422
+	{
423
+		$object = new \SwaggerGen\Swagger\Swagger();
424
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
425
+
426
+		$return = $object->handleCommand('tag', 'Users');
427
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
428
+
429
+		$path = $object->handleCommand('endpoint');
430
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
431
+		$operation = $path->handleCommand('method', 'get');
432
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
433
+		$response = $operation->handleCommand('response', 200);
434
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
435
+
436
+		$this->assertSame(array(
437
+			'swagger' => '2.0',
438
+			'info' => array(
439
+				'title' => 'undefined',
440
+				'version' => '0',
441
+			),
442
+			'paths' => array(
443
+				'/' => array(
444
+					'get' => array(
445
+						'responses' => array(
446
+							200 => array(
447
+								'description' => 'OK',
448
+							),
449
+						),
450
+					),
451
+				),
452
+			),
453
+			'tags' => array(
454
+				array(
455
+					'name' => 'Users',
456
+				),
457
+			),
458
+		), $object->toArray());
459
+	}
460
+
461
+	/**
462
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
463
+	 */
464
+	public function testHandleCommand_Api()
465
+	{
466
+		$object = new \SwaggerGen\Swagger\Swagger();
467
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
468
+
469
+		$return = $object->handleCommand('api', 'Users');
470
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
471
+
472
+		$path = $object->handleCommand('endpoint');
473
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
474
+		$operation = $path->handleCommand('method', 'get');
475
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation);
476
+		$response = $operation->handleCommand('response', 200);
477
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
478
+
479
+		$this->assertSame(array(
480
+			'swagger' => '2.0',
481
+			'info' => array(
482
+				'title' => 'undefined',
483
+				'version' => '0',
484
+			),
485
+			'paths' => array(
486
+				'/' => array(
487
+					'get' => array(
488
+						'tags' => array(
489
+							'Users',
490
+						),
491
+						'responses' => array(
492
+							200 => array(
493
+								'description' => 'OK',
494
+							),
495
+						),
496
+					),
497
+				),
498
+			),
499
+			'tags' => array(
500
+				array(
501
+					'name' => 'Users',
502
+				),
503
+			),
504
+		), $object->toArray());
505
+	}
506
+
507
+	/**
508
+	 * @covers \SwaggerGen\Swagger\Swagger::handleCommand
509
+	 */
510
+	public function testHandleCommand_Tag_Repeat()
511
+	{
512
+		$object = new \SwaggerGen\Swagger\Swagger();
513
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
514
+
515
+		$return = $object->handleCommand('tag', 'Users Info A');
516
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
517
+
518
+		$return = $object->handleCommand('tag', 'Users Info B');
519
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $return);
520
+
521
+		$path = $object->handleCommand('endpoint');
522
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
523
+
524
+		$this->assertSame(array(
525
+			'swagger' => '2.0',
526
+			'info' => array(
527
+				'title' => 'undefined',
528
+				'version' => '0',
529
+			),
530
+			'paths' => array(
531
+				'/' => array(),
532
+			),
533
+			'tags' => array(
534
+				array(
535
+					'name' => 'Users',
536
+					'description' => 'Info A',
537
+				),
538
+			),
539
+		), $object->toArray());
540
+	}
541
+
542
+	/**
543
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
544
+	 */
545
+	public function testHandleCommand_EndPoint_Empty()
546
+	{
547
+		$object = new \SwaggerGen\Swagger\Swagger();
548
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
549
+
550
+		$path = $object->handleCommand('endpoint');
551
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
552
+
553
+		$this->assertSame(array(
554
+			'swagger' => '2.0',
555
+			'info' => array(
556
+				'title' => 'undefined',
557
+				'version' => '0',
558
+			),
559
+			'paths' => array(
560
+				'/' => array(),
561
+			)
562
+		), $object->toArray());
563
+	}
564
+
565
+	/**
566
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
567
+	 */
568
+	public function testHandleCommand_EndPoint()
569
+	{
570
+		$object = new \SwaggerGen\Swagger\Swagger();
571
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
572
+
573
+		$path = $object->handleCommand('endpoint', 'users/:userid/rights');
574
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
575
+
576
+		$this->assertSame(array(
577
+			'swagger' => '2.0',
578
+			'info' => array(
579
+				'title' => 'undefined',
580
+				'version' => '0',
581
+			),
582
+			'paths' => array(
583
+				'/users/:userid/rights' => array(),
584
+			)
585
+		), $object->toArray());
586
+	}
587
+
588
+	/**
589
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
590
+	 */
591
+	public function testHandleCommand_EndPoint_Tag()
592
+	{
593
+		$object = new \SwaggerGen\Swagger\Swagger();
594
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
595
+
596
+		$path = $object->handleCommand('endpoint', 'users/:userid/rights Users');
597
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
598
+
599
+		$this->assertSame(array(
600
+			'swagger' => '2.0',
601
+			'info' => array(
602
+				'title' => 'undefined',
603
+				'version' => '0',
604
+			),
605
+			'paths' => array(
606
+				'/users/:userid/rights' => array(),
607
+			),
608
+			'tags' => array(
609
+				array(
610
+					'name' => 'Users',
611
+				),
612
+			),
613
+		), $object->toArray());
614
+	}
615
+
616
+	/**
617
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
618
+	 */
619
+	public function testHandleCommand_EndPoint_Tag_NoDescriptionOverwrite()
620
+	{
621
+		$object = new \SwaggerGen\Swagger\Swagger();
622
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
623
+
624
+		$path = $object->handleCommand('api', 'Users something here');
625
+		$path = $object->handleCommand('endpoint', 'users/:userid/rights Users');
626
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
627
+
628
+		$this->assertSame(array(
629
+			'swagger' => '2.0',
630
+			'info' => array(
631
+				'title' => 'undefined',
632
+				'version' => '0',
633
+			),
634
+			'paths' => array(
635
+				'/users/:userid/rights' => array(),
636
+			),
637
+			'tags' => array(
638
+				array(
639
+					'name' => 'Users',
640
+					'description' => 'something here',
641
+				),
642
+			),
643
+		), $object->toArray());
644
+	}
645
+
646
+	/**
647
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
648
+	 */
649
+	public function testHandleCommand_EndPoint_Tag_Description()
650
+	{
651
+		$object = new \SwaggerGen\Swagger\Swagger();
652
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
653
+
654
+		$path = $object->handleCommand('endpoint', 'users/:userid/rights Users Description here');
655
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
656
+
657
+		$this->assertSame(array(
658
+			'swagger' => '2.0',
659
+			'info' => array(
660
+				'title' => 'undefined',
661
+				'version' => '0',
662
+			),
663
+			'paths' => array(
664
+				'/users/:userid/rights' => array(),
665
+			),
666
+			'tags' => array(
667
+				array(
668
+					'name' => 'Users',
669
+					'description' => 'Description here',
670
+				),
671
+			),
672
+		), $object->toArray());
673
+	}
674
+
675
+	/**
676
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
677
+	 */
678
+	public function testHandleCommand_Security_Empty()
679
+	{
680
+		$object = new \SwaggerGen\Swagger\Swagger();
681
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
682
+
683
+		$this->expectException('\SwaggerGen\Exception', "Missing security name");
684
+		$path = $object->handleCommand('security');
685
+	}
686
+
687
+	/**
688
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
689
+	 */
690
+	public function testHandleCommand_Security_MissingType()
691
+	{
692
+		$object = new \SwaggerGen\Swagger\Swagger();
693
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
694
+
695
+		$this->expectException('\SwaggerGen\Exception', "Missing security type");
696
+		$path = $object->handleCommand('security', 'foo');
697
+	}
698
+
699
+	/**
700
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
701
+	 */
702
+	public function testHandleCommand_Security_BadType()
703
+	{
704
+		$object = new \SwaggerGen\Swagger\Swagger();
705
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
706
+
707
+		$this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'bad'");
708
+		$path = $object->handleCommand('security', 'foo bad');
709
+	}
710
+
711
+	/**
712
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
713
+	 */
714
+	public function testHandleCommand_Security()
715
+	{
716
+		$object = new \SwaggerGen\Swagger\Swagger();
717
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
718
+
719
+		$security = $object->handleCommand('security', 'foo basic');
720
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $security);
721
+
722
+		$path = $object->handleCommand('endpoint');
723
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
724
+
725
+		$this->assertSame(array(
726
+			'swagger' => '2.0',
727
+			'info' => array(
728
+				'title' => 'undefined',
729
+				'version' => '0',
730
+			),
731
+			'paths' => array(
732
+				'/' => array(),
733
+			),
734
+			'securityDefinitions' => array(
735
+				'foo' => array(
736
+					'type' => 'basic',
737
+				),
738
+			),
739
+		), $object->toArray());
740
+	}
741
+
742
+	/**
743
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
744
+	 */
745
+	public function testHandleCommand_Require_Empty()
746
+	{
747
+		$object = new \SwaggerGen\Swagger\Swagger();
748
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
749
+
750
+		$this->expectException('\SwaggerGen\Exception', "Missing require name");
751
+		$object->handleCommand('require');
752
+	}
753
+
754
+	/**
755
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
756
+	 */
757
+	public function testHandleCommand_Require_Undefined()
758
+	{
759
+		$object = new \SwaggerGen\Swagger\Swagger();
760
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
761
+
762
+		$return = $object->handleCommand('require', 'foo');
763
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
764
+
765
+		$path = $object->handleCommand('endpoint');
766
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
767
+
768
+		$this->expectException('\SwaggerGen\Exception', "Required security scheme not defined: 'foo'");
769
+		$object->toArray();
770
+	}
771
+
772
+	/**
773
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
774
+	 */
775
+	public function testHandleCommand_Require()
776
+	{
777
+		$object = new \SwaggerGen\Swagger\Swagger();
778
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
779
+
780
+		$return = $object->handleCommand('require', 'foo');
781
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $return);
782
+
783
+		$security = $object->handleCommand('security', 'foo basic');
784
+		$this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $security);
785
+
786
+		$path = $object->handleCommand('endpoint');
787
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
788
+
789
+		$this->assertEquals(array(
790
+			'swagger' => '2.0',
791
+			'info' => array(
792
+				'title' => 'undefined',
793
+				'version' => '0',
794
+			),
795
+			'paths' => array(
796
+				'/' => array(),
797
+			),
798
+			'securityDefinitions' => array(
799
+				'foo' => array(
800
+					'type' => 'basic',
801
+				),
802
+			),
803
+			'security' => array(
804
+				array(
805
+					'foo' => array(),
806
+				),
807
+			),
808
+		), $object->toArray());
809
+	}
810
+
811
+	/**
812
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
813
+	 */
814
+	public function testHandleCommand_Definition_Empty()
815
+	{
816
+		$object = new \SwaggerGen\Swagger\Swagger();
817
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
818
+
819
+		$this->expectException('\SwaggerGen\Exception', "Missing definition name");
820
+		$object->handleCommand('definition');
821
+	}
822
+
823
+	/**
824
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
825
+	 */
826
+	public function testHandleCommand_Definition_NoName()
827
+	{
828
+		$object = new \SwaggerGen\Swagger\Swagger();
829
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
830
+
831
+		$this->expectException('\SwaggerGen\Exception', "Missing definition name");
832
+		$object->handleCommand('definition', '');
833
+	}
834
+
835
+	/**
836
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
837
+	 */
838
+	public function testHandleCommand_Definition()
839
+	{
840
+		$object = new \SwaggerGen\Swagger\Swagger();
841
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
842
+
843
+		$schema = $object->handleCommand('definition', 'foo');
844
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
845
+
846
+
847
+		$path = $object->handleCommand('endpoint');
848
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
849
+
850
+		$this->assertSame(array(
851
+			'swagger' => '2.0',
852
+			'info' => array(
853
+				'title' => 'undefined',
854
+				'version' => '0',
855
+			),
856
+			'paths' => array(
857
+				'/' => array(),
858
+			),
859
+			'definitions' => array(
860
+				'foo' => array(
861
+					'type' => 'object',
862
+				),
863
+			),
864
+		), $object->toArray());
865
+	}
866
+
867
+	/**
868
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
869
+	 */
870
+	public function testHandleCommand_Definition_ReadOnly()
871
+	{
872
+		$object = new \SwaggerGen\Swagger\Swagger();
873
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
874
+
875
+		$schema = $object->handleCommand('definition!', 'foo');
876
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
877
+
878
+
879
+		$path = $object->handleCommand('endpoint');
880
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
881
+
882
+		$this->assertSame(array(
883
+			'swagger' => '2.0',
884
+			'info' => array(
885
+				'title' => 'undefined',
886
+				'version' => '0',
887
+			),
888
+			'paths' => array(
889
+				'/' => array(),
890
+			),
891
+			'definitions' => array(
892
+				'foo' => array(
893
+					'type' => 'object',
894
+					'readOnly' => true,
895
+				),
896
+			),
897
+		), $object->toArray());
898
+	}
899
+
900
+	/**
901
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
902
+	 */
903
+	public function testHandleCommand_Model()
904
+	{
905
+		$object = new \SwaggerGen\Swagger\Swagger();
906
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
907
+
908
+		$schema = $object->handleCommand('model', 'foo');
909
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
910
+
911
+		$path = $object->handleCommand('endpoint');
912
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
913
+
914
+		$this->assertSame(array(
915
+			'swagger' => '2.0',
916
+			'info' => array(
917
+				'title' => 'undefined',
918
+				'version' => '0',
919
+			),
920
+			'paths' => array(
921
+				'/' => array(),
922
+			),
923
+			'definitions' => array(
924
+				'foo' => array(
925
+					'type' => 'object',
926
+				),
927
+			),
928
+		), $object->toArray());
929
+	}
930
+
931
+	/**
932
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
933
+	 */
934
+	public function testHandleCommand_Model_ReadOnly()
935
+	{
936
+		$object = new \SwaggerGen\Swagger\Swagger();
937
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
938
+
939
+		$schema = $object->handleCommand('model!', 'foo');
940
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema);
941
+
942
+		$path = $object->handleCommand('endpoint');
943
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
944
+
945
+		$this->assertSame(array(
946
+			'swagger' => '2.0',
947
+			'info' => array(
948
+				'title' => 'undefined',
949
+				'version' => '0',
950
+			),
951
+			'paths' => array(
952
+				'/' => array(),
953
+			),
954
+			'definitions' => array(
955
+				'foo' => array(
956
+					'type' => 'object',
957
+					'readOnly' => true,
958
+				),
959
+			),
960
+		), $object->toArray());
961
+	}
962
+
963
+	/**
964
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
965
+	 */
966
+	public function testHandleCommand_Response_NoType()
967
+	{
968
+		$object = new \SwaggerGen\Swagger\Swagger();
969
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
970
+
971
+		$this->expectException('\SwaggerGen\Exception', "Response definition missing description");
972
+		$response = $object->handleCommand('response', 'NotFound');
973
+	}
974
+
975
+	/**
976
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
977
+	 */
978
+	public function testHandleCommand_Response_NoDescription()
979
+	{
980
+		$object = new \SwaggerGen\Swagger\Swagger();
981
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
982
+
983
+		$this->expectException('\SwaggerGen\Exception', "Response definition missing description");
984
+		$response = $object->handleCommand('response', 'NotFound null');
985
+	}
986
+
987
+	/**
988
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
989
+	 */
990
+	public function testHandleCommand_Response_WithoutDefinition()
991
+	{
992
+		$object = new \SwaggerGen\Swagger\Swagger();
993
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
994
+
995
+		$response = $object->handleCommand('response', 'NotFound null Entity not found');
996
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
997
+
998
+		$path = $object->handleCommand('endpoint');
999
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
1000
+
1001
+		$this->assertSame(array(
1002
+			'swagger' => '2.0',
1003
+			'info' => array(
1004
+				'title' => 'undefined',
1005
+				'version' => '0',
1006
+			),
1007
+			'paths' => array(
1008
+				'/' => array(),
1009
+			),
1010
+			'responses' => array(
1011
+				'NotFound' => array(
1012
+					'description' => 'Entity not found',
1013
+				),
1014
+			),
1015
+		), $object->toArray());
1016
+	}
1017
+
1018
+	/**
1019
+	 * @covers \SwaggerGen\Swagger\Swagger::__construct
1020
+	 */
1021
+	public function testHandleCommand_Response_WithDefinition()
1022
+	{
1023
+		$object = new \SwaggerGen\Swagger\Swagger();
1024
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object);
1025
+
1026
+		$response = $object->handleCommand('response', 'NotFound int Entity not found');
1027
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response);
1028
+
1029
+		$path = $object->handleCommand('endpoint');
1030
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path);
1031
+
1032
+		$this->assertSame(array(
1033
+			'swagger' => '2.0',
1034
+			'info' => array(
1035
+				'title' => 'undefined',
1036
+				'version' => '0',
1037
+			),
1038
+			'paths' => array(
1039
+				'/' => array(),
1040
+			),
1041
+			'responses' => array(
1042
+				'NotFound' => array(
1043
+					'description' => 'Entity not found',
1044
+					'schema' => array(
1045
+						'type' => 'integer',
1046
+						'format' => 'int32'
1047
+					),
1048
+				),
1049
+			),
1050
+		), $object->toArray());
1051
+	}
1052 1052
 
1053 1053
 }
Please login to merge, or discard this patch.
tests/Swagger/BodyParameterTest.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -6,148 +6,148 @@
 block discarded – undo
6 6
 class BodyParameterTest extends TestCase
7 7
 {
8 8
 
9
-    protected $parent;
10
-
11
-    /**
12
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
13
-     */
14
-    public function testConstructorNoType()
15
-    {
16
-        $this->expectException('\SwaggerGen\Exception', "No type definition for body parameter");
17
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, '');
18
-    }
19
-
20
-    /**
21
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
22
-     */
23
-    public function testConstructorNoName()
24
-    {
25
-        $this->expectException('\SwaggerGen\Exception', "No name for body parameter");
26
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'wrong');
27
-    }
28
-
29
-    /**
30
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
31
-     */
32
-    public function testConstructorType()
33
-    {
34
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo');
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
36
-
37
-        $this->assertSame(array(
38
-            'name' => 'foo',
39
-            'in' => 'body',
40
-            'schema' => array(
41
-                'type' => 'integer',
42
-                'format' => 'int32',
43
-            ),
44
-        ), $object->toArray());
45
-    }
46
-
47
-    /**
48
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
49
-     */
50
-    public function testConstructorReference()
51
-    {
52
-        $this->parent->handleCommand('model', 'User');
53
-
54
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'User foo');
55
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
56
-
57
-        $this->assertSame(array(
58
-            'name' => 'foo',
59
-            'in' => 'body',
60
-            'schema' => array(
61
-                '$ref' => '#/definitions/User',
62
-            ),
63
-        ), $object->toArray());
64
-    }
65
-
66
-    /**
67
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
68
-     */
69
-    public function testConstructorDescription()
70
-    {
71
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo Some more words');
72
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
73
-
74
-        $this->assertSame(array(
75
-            'name' => 'foo',
76
-            'in' => 'body',
77
-            'description' => 'Some more words',
78
-            'schema' => array(
79
-                'type' => 'integer',
80
-                'format' => 'int32',
81
-            ),
82
-        ), $object->toArray());
83
-    }
84
-
85
-    /**
86
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
87
-     */
88
-    public function testConstructorRequired()
89
-    {
90
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', true);
91
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
92
-
93
-        $this->assertSame(array(
94
-            'name' => 'foo',
95
-            'in' => 'body',
96
-            'required' => true,
97
-            'schema' => array(
98
-                'type' => 'integer',
99
-                'format' => 'int32',
100
-            ),
101
-        ), $object->toArray());
102
-    }
103
-
104
-    /**
105
-     * @covers \SwaggerGen\Swagger\BodyParameter::__construct
106
-     */
107
-    public function testConstructorNotRequired()
108
-    {
109
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false);
110
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
111
-
112
-        $this->assertSame(array(
113
-            'name' => 'foo',
114
-            'in' => 'body',
115
-            'schema' => array(
116
-                'type' => 'integer',
117
-                'format' => 'int32',
118
-            ),
119
-        ), $object->toArray());
120
-    }
121
-
122
-    /**
123
-     * @covers \SwaggerGen\Swagger\Type\BodyParameter->handleCommand
124
-     */
125
-    public function testCommandPassing()
126
-    {
127
-        $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false);
128
-        $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
129
-
130
-        $object->handleCommand('default', '123');
131
-
132
-        $this->assertSame(array(
133
-            'name' => 'foo',
134
-            'in' => 'body',
135
-            'schema' => array(
136
-                'type' => 'integer',
137
-                'format' => 'int32',
138
-                'default' => 123,
139
-            ),
140
-        ), $object->toArray());
141
-    }
142
-
143
-    protected function setUp(): void
144
-    {
145
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
146
-    }
147
-
148
-    protected function assertPreConditions(): void
149
-    {
150
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
151
-    }
9
+	protected $parent;
10
+
11
+	/**
12
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
13
+	 */
14
+	public function testConstructorNoType()
15
+	{
16
+		$this->expectException('\SwaggerGen\Exception', "No type definition for body parameter");
17
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, '');
18
+	}
19
+
20
+	/**
21
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
22
+	 */
23
+	public function testConstructorNoName()
24
+	{
25
+		$this->expectException('\SwaggerGen\Exception', "No name for body parameter");
26
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'wrong');
27
+	}
28
+
29
+	/**
30
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
31
+	 */
32
+	public function testConstructorType()
33
+	{
34
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo');
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
36
+
37
+		$this->assertSame(array(
38
+			'name' => 'foo',
39
+			'in' => 'body',
40
+			'schema' => array(
41
+				'type' => 'integer',
42
+				'format' => 'int32',
43
+			),
44
+		), $object->toArray());
45
+	}
46
+
47
+	/**
48
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
49
+	 */
50
+	public function testConstructorReference()
51
+	{
52
+		$this->parent->handleCommand('model', 'User');
53
+
54
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'User foo');
55
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
56
+
57
+		$this->assertSame(array(
58
+			'name' => 'foo',
59
+			'in' => 'body',
60
+			'schema' => array(
61
+				'$ref' => '#/definitions/User',
62
+			),
63
+		), $object->toArray());
64
+	}
65
+
66
+	/**
67
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
68
+	 */
69
+	public function testConstructorDescription()
70
+	{
71
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo Some more words');
72
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
73
+
74
+		$this->assertSame(array(
75
+			'name' => 'foo',
76
+			'in' => 'body',
77
+			'description' => 'Some more words',
78
+			'schema' => array(
79
+				'type' => 'integer',
80
+				'format' => 'int32',
81
+			),
82
+		), $object->toArray());
83
+	}
84
+
85
+	/**
86
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
87
+	 */
88
+	public function testConstructorRequired()
89
+	{
90
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', true);
91
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
92
+
93
+		$this->assertSame(array(
94
+			'name' => 'foo',
95
+			'in' => 'body',
96
+			'required' => true,
97
+			'schema' => array(
98
+				'type' => 'integer',
99
+				'format' => 'int32',
100
+			),
101
+		), $object->toArray());
102
+	}
103
+
104
+	/**
105
+	 * @covers \SwaggerGen\Swagger\BodyParameter::__construct
106
+	 */
107
+	public function testConstructorNotRequired()
108
+	{
109
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false);
110
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
111
+
112
+		$this->assertSame(array(
113
+			'name' => 'foo',
114
+			'in' => 'body',
115
+			'schema' => array(
116
+				'type' => 'integer',
117
+				'format' => 'int32',
118
+			),
119
+		), $object->toArray());
120
+	}
121
+
122
+	/**
123
+	 * @covers \SwaggerGen\Swagger\Type\BodyParameter->handleCommand
124
+	 */
125
+	public function testCommandPassing()
126
+	{
127
+		$object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false);
128
+		$this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object);
129
+
130
+		$object->handleCommand('default', '123');
131
+
132
+		$this->assertSame(array(
133
+			'name' => 'foo',
134
+			'in' => 'body',
135
+			'schema' => array(
136
+				'type' => 'integer',
137
+				'format' => 'int32',
138
+				'default' => 123,
139
+			),
140
+		), $object->toArray());
141
+	}
142
+
143
+	protected function setUp(): void
144
+	{
145
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
146
+	}
147
+
148
+	protected function assertPreConditions(): void
149
+	{
150
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
151
+	}
152 152
 
153 153
 }
Please login to merge, or discard this patch.
tests/Swagger/LicenseTest.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -7,113 +7,113 @@
 block discarded – undo
7 7
 class LicenseTest extends TestCase
8 8
 {
9 9
 
10
-    protected $parent;
11
-
12
-    /**
13
-     * @covers \SwaggerGen\Swagger\License::__construct
14
-     * @covers \SwaggerGen\Swagger\License::toArray
15
-     */
16
-    public function testConstructor2Unknown(): void
17
-    {
18
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'Name');
19
-
20
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
21
-
22
-        $this->assertSame(array(
23
-            'name' => 'Name',
24
-        ), $object->toArray());
25
-    }
26
-
27
-    /**
28
-     * @covers \SwaggerGen\Swagger\License::__construct
29
-     * @covers \SwaggerGen\Swagger\License::toArray
30
-     */
31
-    public function testConstructor2Known()
32
-    {
33
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
36
-
37
-        $this->assertSame(array(
38
-            'name' => 'MIT',
39
-            'url' => 'http://opensource.org/licenses/MIT',
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\License::__construct
45
-     * @covers \SwaggerGen\Swagger\License::toArray
46
-     */
47
-    public function testConstructor3Unknown()
48
-    {
49
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example');
50
-
51
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
52
-
53
-        $this->assertSame(array(
54
-            'name' => 'Name',
55
-            'url' => 'http://example',
56
-        ), $object->toArray());
57
-    }
58
-
59
-    /**
60
-     * @covers \SwaggerGen\Swagger\License::__construct
61
-     * @covers \SwaggerGen\Swagger\License::toArray
62
-     */
63
-    public function testConstructor3Known()
64
-    {
65
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example');
66
-
67
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
68
-
69
-        $this->assertSame(array(
70
-            'name' => 'MIT',
71
-            'url' => 'http://example',
72
-        ), $object->toArray());
73
-    }
74
-
75
-    /**
76
-     * @covers \SwaggerGen\Swagger\Tag::handleCommand
77
-     */
78
-    public function testCommandName()
79
-    {
80
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
81
-
82
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
83
-
84
-        $object->handleCommand('name', 'GPL-3');
85
-
86
-        $this->assertSame(array(
87
-            'name' => 'GPL-3',
88
-            'url' => 'http://opensource.org/licenses/MIT',
89
-        ), $object->toArray());
90
-    }
91
-
92
-    /**
93
-     * @covers \SwaggerGen\Swagger\Tag::handleCommand
94
-     */
95
-    public function testCommandUrl()
96
-    {
97
-        $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
98
-
99
-        $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
100
-
101
-        $object->handleCommand('url', 'http://example');
102
-
103
-        $this->assertSame(array(
104
-            'name' => 'MIT',
105
-            'url' => 'http://example',
106
-        ), $object->toArray());
107
-    }
108
-
109
-    protected function setUp(): void
110
-    {
111
-        $this->parent = $this->getMockForAbstractClass(AbstractObject::class);
112
-    }
113
-
114
-    protected function assertPreConditions(): void
115
-    {
116
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
117
-    }
10
+	protected $parent;
11
+
12
+	/**
13
+	 * @covers \SwaggerGen\Swagger\License::__construct
14
+	 * @covers \SwaggerGen\Swagger\License::toArray
15
+	 */
16
+	public function testConstructor2Unknown(): void
17
+	{
18
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'Name');
19
+
20
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
21
+
22
+		$this->assertSame(array(
23
+			'name' => 'Name',
24
+		), $object->toArray());
25
+	}
26
+
27
+	/**
28
+	 * @covers \SwaggerGen\Swagger\License::__construct
29
+	 * @covers \SwaggerGen\Swagger\License::toArray
30
+	 */
31
+	public function testConstructor2Known()
32
+	{
33
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
36
+
37
+		$this->assertSame(array(
38
+			'name' => 'MIT',
39
+			'url' => 'http://opensource.org/licenses/MIT',
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\License::__construct
45
+	 * @covers \SwaggerGen\Swagger\License::toArray
46
+	 */
47
+	public function testConstructor3Unknown()
48
+	{
49
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example');
50
+
51
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
52
+
53
+		$this->assertSame(array(
54
+			'name' => 'Name',
55
+			'url' => 'http://example',
56
+		), $object->toArray());
57
+	}
58
+
59
+	/**
60
+	 * @covers \SwaggerGen\Swagger\License::__construct
61
+	 * @covers \SwaggerGen\Swagger\License::toArray
62
+	 */
63
+	public function testConstructor3Known()
64
+	{
65
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example');
66
+
67
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
68
+
69
+		$this->assertSame(array(
70
+			'name' => 'MIT',
71
+			'url' => 'http://example',
72
+		), $object->toArray());
73
+	}
74
+
75
+	/**
76
+	 * @covers \SwaggerGen\Swagger\Tag::handleCommand
77
+	 */
78
+	public function testCommandName()
79
+	{
80
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
81
+
82
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
83
+
84
+		$object->handleCommand('name', 'GPL-3');
85
+
86
+		$this->assertSame(array(
87
+			'name' => 'GPL-3',
88
+			'url' => 'http://opensource.org/licenses/MIT',
89
+		), $object->toArray());
90
+	}
91
+
92
+	/**
93
+	 * @covers \SwaggerGen\Swagger\Tag::handleCommand
94
+	 */
95
+	public function testCommandUrl()
96
+	{
97
+		$object = new \SwaggerGen\Swagger\License($this->parent, 'MIT');
98
+
99
+		$this->assertInstanceOf('\SwaggerGen\Swagger\License', $object);
100
+
101
+		$object->handleCommand('url', 'http://example');
102
+
103
+		$this->assertSame(array(
104
+			'name' => 'MIT',
105
+			'url' => 'http://example',
106
+		), $object->toArray());
107
+	}
108
+
109
+	protected function setUp(): void
110
+	{
111
+		$this->parent = $this->getMockForAbstractClass(AbstractObject::class);
112
+	}
113
+
114
+	protected function assertPreConditions(): void
115
+	{
116
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
117
+	}
118 118
 
119 119
 }
Please login to merge, or discard this patch.
tests/Swagger/ExternalDocumentationTest.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -7,79 +7,79 @@
 block discarded – undo
7 7
 class ExternalDocumentationTest extends TestCase
8 8
 {
9 9
 
10
-    protected $parent;
11
-
12
-    /**
13
-     * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct
14
-     */
15
-    public function testConstructorUrl(): void
16
-    {
17
-        $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test');
18
-
19
-        $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
20
-
21
-        $this->assertSame(array(
22
-            'url' => 'http://example.test',
23
-        ), $object->toArray());
24
-    }
25
-
26
-    /**
27
-     * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct
28
-     */
29
-    public function testConstructorFull()
30
-    {
31
-        $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
32
-
33
-        $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
34
-
35
-        $this->assertSame(array(
36
-            'url' => 'http://example.test',
37
-            'description' => 'Descriptive text',
38
-        ), $object->toArray());
39
-    }
40
-
41
-    /**
42
-     * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand
43
-     */
44
-    public function testCommandUrl()
45
-    {
46
-        $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
47
-
48
-        $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
49
-
50
-        $object->handleCommand('url', 'http://other.test');
51
-
52
-        $this->assertSame(array(
53
-            'url' => 'http://other.test',
54
-            'description' => 'Descriptive text',
55
-        ), $object->toArray());
56
-    }
57
-
58
-    /**
59
-     * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand
60
-     */
61
-    public function testCommandDescription()
62
-    {
63
-        $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
64
-
65
-        $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
66
-
67
-        $object->handleCommand('description', 'Some other words');
68
-
69
-        $this->assertSame(array(
70
-            'url' => 'http://example.test',
71
-            'description' => 'Some other words',
72
-        ), $object->toArray());
73
-    }
74
-
75
-    protected function setUp(): void
76
-    {
77
-        $this->parent = $this->getMockForAbstractClass(AbstractObject::class);
78
-    }
79
-
80
-    protected function assertPreConditions(): void
81
-    {
82
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
83
-    }
10
+	protected $parent;
11
+
12
+	/**
13
+	 * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct
14
+	 */
15
+	public function testConstructorUrl(): void
16
+	{
17
+		$object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test');
18
+
19
+		$this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
20
+
21
+		$this->assertSame(array(
22
+			'url' => 'http://example.test',
23
+		), $object->toArray());
24
+	}
25
+
26
+	/**
27
+	 * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct
28
+	 */
29
+	public function testConstructorFull()
30
+	{
31
+		$object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
32
+
33
+		$this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
34
+
35
+		$this->assertSame(array(
36
+			'url' => 'http://example.test',
37
+			'description' => 'Descriptive text',
38
+		), $object->toArray());
39
+	}
40
+
41
+	/**
42
+	 * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand
43
+	 */
44
+	public function testCommandUrl()
45
+	{
46
+		$object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
47
+
48
+		$this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
49
+
50
+		$object->handleCommand('url', 'http://other.test');
51
+
52
+		$this->assertSame(array(
53
+			'url' => 'http://other.test',
54
+			'description' => 'Descriptive text',
55
+		), $object->toArray());
56
+	}
57
+
58
+	/**
59
+	 * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand
60
+	 */
61
+	public function testCommandDescription()
62
+	{
63
+		$object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text');
64
+
65
+		$this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object);
66
+
67
+		$object->handleCommand('description', 'Some other words');
68
+
69
+		$this->assertSame(array(
70
+			'url' => 'http://example.test',
71
+			'description' => 'Some other words',
72
+		), $object->toArray());
73
+	}
74
+
75
+	protected function setUp(): void
76
+	{
77
+		$this->parent = $this->getMockForAbstractClass(AbstractObject::class);
78
+	}
79
+
80
+	protected function assertPreConditions(): void
81
+	{
82
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
83
+	}
84 84
 
85 85
 }
Please login to merge, or discard this patch.
tests/Swagger/AbstractObjectTest.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -6,84 +6,84 @@
 block discarded – undo
6 6
 class AbstractObjectTest extends TestCase
7 7
 {
8 8
 
9
-    /**
10
-     * @covers \SwaggerGen\Swagger\AbstractObject::words_shift
11
-     */
12
-    public function testWords_shift()
13
-    {
14
-        $text = 'quite a few words';
15
-
16
-        $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
17
-        $this->assertSame('a few words', $text);
18
-
19
-        $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
20
-        $this->assertSame('few words', $text);
21
-
22
-        $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
23
-        $this->assertSame('words', $text);
24
-
25
-        $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
26
-        $this->assertSame('', $text);
27
-
28
-        $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text));
29
-        $this->assertSame('', $text);
30
-    }
31
-
32
-    /**
33
-     * @covers \SwaggerGen\Swagger\AbstractObject::words_shift
34
-     */
35
-    public function testWords_shift_whitespace()
36
-    {
37
-        $text = "    quite  a\nfew   \r  \n\r words \t";
38
-
39
-        $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
40
-        $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
41
-        $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
42
-        $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
43
-        $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text));
44
-        $this->assertSame('', $text);
45
-    }
46
-
47
-    /**
48
-     * @covers \SwaggerGen\Swagger\AbstractObject::mb_trim
49
-     */
50
-    public function testMb_trim()
51
-    {
52
-        $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed"));
53
-        $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed "));
54
-        $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed"));
55
-        $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("   trimmed   "));
56
-        $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("\n \t trimmed \f \r"));
57
-    }
58
-
59
-    /**
60
-     * @covers \SwaggerGen\Swagger\AbstractObject::toArray
61
-     */
62
-    public function testToArray()
63
-    {
64
-        $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
65
-
66
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object);
67
-
68
-        $this->assertSame(array(), $object->toArray());
69
-    }
70
-
71
-    /**
72
-     * @covers \SwaggerGen\Swagger\AbstractObject::handleCommand
73
-     */
74
-    public function testCommandExtensions()
75
-    {
76
-        $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
77
-
78
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object);
79
-
80
-        $object->handleCommand('x-someTag', 'some value');
81
-        $object->handleCommand('x-anyTag', 'any value');
82
-
83
-        $this->assertSame(array(
84
-            'x-someTag' => 'some value',
85
-            'x-anyTag' => 'any value',
86
-        ), $object->toArray());
87
-    }
9
+	/**
10
+	 * @covers \SwaggerGen\Swagger\AbstractObject::words_shift
11
+	 */
12
+	public function testWords_shift()
13
+	{
14
+		$text = 'quite a few words';
15
+
16
+		$this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
17
+		$this->assertSame('a few words', $text);
18
+
19
+		$this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
20
+		$this->assertSame('few words', $text);
21
+
22
+		$this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
23
+		$this->assertSame('words', $text);
24
+
25
+		$this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
26
+		$this->assertSame('', $text);
27
+
28
+		$this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text));
29
+		$this->assertSame('', $text);
30
+	}
31
+
32
+	/**
33
+	 * @covers \SwaggerGen\Swagger\AbstractObject::words_shift
34
+	 */
35
+	public function testWords_shift_whitespace()
36
+	{
37
+		$text = "    quite  a\nfew   \r  \n\r words \t";
38
+
39
+		$this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
40
+		$this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
41
+		$this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
42
+		$this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text));
43
+		$this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text));
44
+		$this->assertSame('', $text);
45
+	}
46
+
47
+	/**
48
+	 * @covers \SwaggerGen\Swagger\AbstractObject::mb_trim
49
+	 */
50
+	public function testMb_trim()
51
+	{
52
+		$this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed"));
53
+		$this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed "));
54
+		$this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed"));
55
+		$this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("   trimmed   "));
56
+		$this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("\n \t trimmed \f \r"));
57
+	}
58
+
59
+	/**
60
+	 * @covers \SwaggerGen\Swagger\AbstractObject::toArray
61
+	 */
62
+	public function testToArray()
63
+	{
64
+		$object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
65
+
66
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object);
67
+
68
+		$this->assertSame(array(), $object->toArray());
69
+	}
70
+
71
+	/**
72
+	 * @covers \SwaggerGen\Swagger\AbstractObject::handleCommand
73
+	 */
74
+	public function testCommandExtensions()
75
+	{
76
+		$object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
77
+
78
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object);
79
+
80
+		$object->handleCommand('x-someTag', 'some value');
81
+		$object->handleCommand('x-anyTag', 'any value');
82
+
83
+		$this->assertSame(array(
84
+			'x-someTag' => 'some value',
85
+			'x-anyTag' => 'any value',
86
+		), $object->toArray());
87
+	}
88 88
 
89 89
 }
Please login to merge, or discard this patch.