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