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