Completed
Push — master ( 2f1531...a6cc58 )
by Martijn
17s
created
tests/Swagger/Type/PropertyTest.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -3,130 +3,130 @@
 block discarded – undo
3 3
 class PropertyTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
20
-     */
21
-    public function testConstructEmpty()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a property: ''");
24
-
25
-        new SwaggerGen\Swagger\Type\Property($this->parent, '');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
30
-     */
31
-    public function testConstructReference()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'Address');
34
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
35
-
36
-        $this->assertSame(array(
37
-            '$ref' => '#/definitions/Address',
38
-        ), $object->toArray());
39
-    }
40
-
41
-    /**
42
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
43
-     */
44
-    public function testConstructReferences()
45
-    {
46
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'array(Address)');
47
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
48
-
49
-        $this->assertSame(array(
50
-            'type' => 'array',
51
-            'items' => array(
52
-                '$ref' => '#/definitions/Address',
53
-            ),
54
-        ), $object->toArray());
55
-    }
56
-
57
-    /**
58
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
59
-     */
60
-    public function testConstructString()
61
-    {
62
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string');
63
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
64
-
65
-        $this->assertSame(array(
66
-            'type' => 'string',
67
-        ), $object->toArray());
68
-    }
69
-
70
-    /**
71
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
72
-     */
73
-    public function testConstructDescription()
74
-    {
75
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here');
76
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
77
-
78
-        $this->assertSame(array(
79
-            'type' => 'string',
80
-            'description' => 'Some words here',
81
-        ), $object->toArray());
82
-    }
83
-
84
-    /**
85
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
86
-     */
87
-    public function testConstructReadOnly()
88
-    {
89
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here', true);
90
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
91
-
92
-        $this->assertSame(array(
93
-            'type' => 'string',
94
-            'description' => 'Some words here',
95
-            'readOnly' => true
96
-        ), $object->toArray());
97
-    }
98
-
99
-    /**
100
-     * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
101
-     */
102
-    public function testConstructComplex()
103
-    {
104
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'int[3,10>=6');
105
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
106
-
107
-        $this->assertSame(array(
108
-            'type' => 'integer',
109
-            'format' => 'int32',
110
-            'default' => 6,
111
-            'minimum' => 3,
112
-            'maximum' => 10,
113
-            'exclusiveMaximum' => true,
114
-        ), $object->toArray());
115
-    }
116
-
117
-    /**
118
-     * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
119
-     */
120
-    public function testCommandPassing()
121
-    {
122
-        $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string');
123
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
124
-
125
-        $object->handleCommand('default', 'good');
126
-        $this->assertSame(array(
127
-            'type' => 'string',
128
-            'default' => 'good',
129
-        ), $object->toArray());
130
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
20
+	 */
21
+	public function testConstructEmpty()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a property: ''");
24
+
25
+		new SwaggerGen\Swagger\Type\Property($this->parent, '');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
30
+	 */
31
+	public function testConstructReference()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'Address');
34
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
35
+
36
+		$this->assertSame(array(
37
+			'$ref' => '#/definitions/Address',
38
+		), $object->toArray());
39
+	}
40
+
41
+	/**
42
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
43
+	 */
44
+	public function testConstructReferences()
45
+	{
46
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'array(Address)');
47
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
48
+
49
+		$this->assertSame(array(
50
+			'type' => 'array',
51
+			'items' => array(
52
+				'$ref' => '#/definitions/Address',
53
+			),
54
+		), $object->toArray());
55
+	}
56
+
57
+	/**
58
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
59
+	 */
60
+	public function testConstructString()
61
+	{
62
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string');
63
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
64
+
65
+		$this->assertSame(array(
66
+			'type' => 'string',
67
+		), $object->toArray());
68
+	}
69
+
70
+	/**
71
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
72
+	 */
73
+	public function testConstructDescription()
74
+	{
75
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here');
76
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
77
+
78
+		$this->assertSame(array(
79
+			'type' => 'string',
80
+			'description' => 'Some words here',
81
+		), $object->toArray());
82
+	}
83
+
84
+	/**
85
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
86
+	 */
87
+	public function testConstructReadOnly()
88
+	{
89
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here', true);
90
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
91
+
92
+		$this->assertSame(array(
93
+			'type' => 'string',
94
+			'description' => 'Some words here',
95
+			'readOnly' => true
96
+		), $object->toArray());
97
+	}
98
+
99
+	/**
100
+	 * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct
101
+	 */
102
+	public function testConstructComplex()
103
+	{
104
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'int[3,10>=6');
105
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
106
+
107
+		$this->assertSame(array(
108
+			'type' => 'integer',
109
+			'format' => 'int32',
110
+			'default' => 6,
111
+			'minimum' => 3,
112
+			'maximum' => 10,
113
+			'exclusiveMaximum' => true,
114
+		), $object->toArray());
115
+	}
116
+
117
+	/**
118
+	 * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand
119
+	 */
120
+	public function testCommandPassing()
121
+	{
122
+		$object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string');
123
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object);
124
+
125
+		$object->handleCommand('default', 'good');
126
+		$this->assertSame(array(
127
+			'type' => 'string',
128
+			'default' => 'good',
129
+		), $object->toArray());
130
+	}
131 131
 
132 132
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/ReferenceObjectTypeTest.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 class ReferenceObjectTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
6
+	protected $parent;
7 7
 
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
-    }
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger');
11
+	}
12 12
 
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17 17
 
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\ReferenceObjectType::__construct
20
-     */
21
-    public function testConstructBothConsumes()
22
-    {
23
-        $this->parent->handleCommand('model', 'blah');
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\ReferenceObjectType::__construct
20
+	 */
21
+	public function testConstructBothConsumes()
22
+	{
23
+		$this->parent->handleCommand('model', 'blah');
24 24
 
25
-        $object = new SwaggerGen\Swagger\Type\ReferenceObjectType($this->parent, 'blah');
25
+		$object = new SwaggerGen\Swagger\Type\ReferenceObjectType($this->parent, 'blah');
26 26
 
27
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ReferenceObjectType', $object);
27
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\ReferenceObjectType', $object);
28 28
 
29
-        $this->assertSame(array(
30
-            '$ref' => '#/definitions/blah',
31
-        ), $object->toArray());
32
-    }
29
+		$this->assertSame(array(
30
+			'$ref' => '#/definitions/blah',
31
+		), $object->toArray());
32
+	}
33 33
 
34 34
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/StringTypeTest.php 1 patch
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -3,293 +3,293 @@
 block discarded – undo
3 3
 class StringTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
20
-     */
21
-    public function testConstructNotAString()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a string: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
30
-     */
31
-    public function testConstructEmptyRange()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "Empty string range: 'string[,]=1'");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,]=1');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
40
-     */
41
-    public function testConstructDefaultTooLongInclusive()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "Default string length beyond maximum: 'long'");
44
-
45
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,3]=long');
46
-    }
47
-
48
-    /**
49
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
50
-     */
51
-    public function testConstructDefaultTooLongExclusive()
52
-    {
53
-        $this->expectException('\SwaggerGen\Exception', "Default string length beyond maximum: 'long'");
54
-
55
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,4>=long');
56
-    }
57
-
58
-    /**
59
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
60
-     */
61
-    public function testConstructDefaultTooShortInclusive()
62
-    {
63
-        $this->expectException('\SwaggerGen\Exception', "Default string length beyond minimum: 'short'");
64
-
65
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[6,]=short');
66
-    }
67
-
68
-    /**
69
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
70
-     */
71
-    public function testConstructDefaultTooShortExclusive()
72
-    {
73
-        $this->expectException('\SwaggerGen\Exception', "Default string length beyond minimum: 'short'");
74
-
75
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string<5,]=short');
76
-    }
77
-
78
-    /**
79
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
80
-     */
81
-    public function testConstructString()
82
-    {
83
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
84
-
85
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
86
-
87
-        $this->assertSame(array(
88
-            'type' => 'string',
89
-        ), $object->toArray());
90
-    }
91
-
92
-    /**
93
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
94
-     */
95
-    public function testConstructStringEmptyDefault()
96
-    {
97
-        $this->expectException('\SwaggerGen\Exception', "Unparseable string definition: 'string='");
98
-
99
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string= ');
100
-    }
101
-
102
-    /**
103
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
104
-     */
105
-    public function testConstructStringDefaultLengthInclusive()
106
-    {
107
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[4,4]=word');
108
-
109
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
110
-
111
-        $this->assertSame(array(
112
-            'type' => 'string',
113
-            'default' => 'word',
114
-            'minLength' => 4,
115
-            'maxLength' => 4,
116
-        ), $object->toArray());
117
-    }
118
-
119
-    /**
120
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
121
-     */
122
-    public function testConstructStringDefaultLengthExclusive()
123
-    {
124
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string<3,5>=word');
125
-
126
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
127
-
128
-        $this->assertSame(array(
129
-            'type' => 'string',
130
-            'default' => 'word',
131
-            'minLength' => 4,
132
-            'maxLength' => 4,
133
-        ), $object->toArray());
134
-    }
135
-
136
-    /**
137
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
138
-     */
139
-    public function testConstructBinary()
140
-    {
141
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'binary');
142
-
143
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
144
-
145
-        $this->assertSame(array(
146
-            'type' => 'string',
147
-            'format' => 'binary',
148
-        ), $object->toArray());
149
-    }
150
-
151
-    /**
152
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
153
-     */
154
-    public function testConstructEnumRange()
155
-    {
156
-        $this->expectException('\SwaggerGen\Exception', "Range not allowed in enumeration definition: 'enum(a,b)[,]'");
157
-
158
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)[,]');
159
-    }
160
-
161
-    /**
162
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
163
-     */
164
-    public function testConstructEnumInvalidDefault()
165
-    {
166
-        $this->expectException('\SwaggerGen\Exception', "Invalid enum default: 'c'");
167
-
168
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)=c');
169
-    }
170
-
171
-    /**
172
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
173
-     */
174
-    public function testConstructEnum()
175
-    {
176
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)');
177
-
178
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
179
-
180
-        $this->assertSame(array(
181
-            'type' => 'string',
182
-            'enum' => array('a', 'b'),
183
-        ), $object->toArray());
184
-    }
185
-
186
-    /**
187
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
188
-     */
189
-    public function testConstructEnumWithDefault()
190
-    {
191
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)=a');
192
-
193
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
194
-
195
-        $this->assertSame(array(
196
-            'type' => 'string',
197
-            'default' => 'a',
198
-            'enum' => array('a', 'b'),
199
-        ), $object->toArray());
200
-    }
201
-
202
-    /**
203
-     * @covers \SwaggerGen\Swagger\Type\StringType::__construct
204
-     */
205
-    public function testConstructPattern()
206
-    {
207
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string([a-z])');
208
-
209
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
210
-
211
-        $this->assertSame(array(
212
-            'type' => 'string',
213
-            'pattern' => '[a-z]',
214
-        ), $object->toArray());
215
-    }
216
-
217
-    /**
218
-     * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
219
-     */
220
-    public function testCommandDefaultNoValue()
221
-    {
222
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
223
-
224
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
225
-
226
-        $this->expectException('\SwaggerGen\Exception', "Empty string default");
227
-        $object->handleCommand('default', '');
228
-    }
229
-
230
-    /**
231
-     * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
232
-     */
233
-    public function testCommandDefault()
234
-    {
235
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
236
-
237
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
238
-
239
-        $object->handleCommand('default', 'word');
240
-
241
-        $this->assertSame(array(
242
-            'type' => 'string',
243
-            'default' => 'word',
244
-        ), $object->toArray());
245
-    }
246
-
247
-    /**
248
-     * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
249
-     */
250
-    public function testCommandPattern()
251
-    {
252
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
253
-
254
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
255
-
256
-        $object->handleCommand('pattern', '[a-z]');
257
-
258
-        $this->assertSame(array(
259
-            'type' => 'string',
260
-            'pattern' => '[a-z]',
261
-        ), $object->toArray());
262
-    }
263
-
264
-    /**
265
-     * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
266
-     */
267
-    public function testCommandEnumWhenRange()
268
-    {
269
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[0,]');
270
-
271
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
272
-
273
-        $this->expectException('\SwaggerGen\Exception', "Enumeration not allowed in ranged string: 'red green blue'");
274
-
275
-        $object->handleCommand('enum', 'red green blue');
276
-    }
277
-
278
-    /**
279
-     * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
280
-     */
281
-    public function testCommandEnum()
282
-    {
283
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
284
-
285
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
286
-
287
-        $object->handleCommand('enum', 'red green blue');
288
-
289
-        $this->assertSame(array(
290
-            'type' => 'string',
291
-            'enum' => array('red', 'green', 'blue'),
292
-        ), $object->toArray());
293
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
20
+	 */
21
+	public function testConstructNotAString()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a string: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
30
+	 */
31
+	public function testConstructEmptyRange()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "Empty string range: 'string[,]=1'");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,]=1');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
40
+	 */
41
+	public function testConstructDefaultTooLongInclusive()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "Default string length beyond maximum: 'long'");
44
+
45
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,3]=long');
46
+	}
47
+
48
+	/**
49
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
50
+	 */
51
+	public function testConstructDefaultTooLongExclusive()
52
+	{
53
+		$this->expectException('\SwaggerGen\Exception', "Default string length beyond maximum: 'long'");
54
+
55
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[,4>=long');
56
+	}
57
+
58
+	/**
59
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
60
+	 */
61
+	public function testConstructDefaultTooShortInclusive()
62
+	{
63
+		$this->expectException('\SwaggerGen\Exception', "Default string length beyond minimum: 'short'");
64
+
65
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[6,]=short');
66
+	}
67
+
68
+	/**
69
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
70
+	 */
71
+	public function testConstructDefaultTooShortExclusive()
72
+	{
73
+		$this->expectException('\SwaggerGen\Exception', "Default string length beyond minimum: 'short'");
74
+
75
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string<5,]=short');
76
+	}
77
+
78
+	/**
79
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
80
+	 */
81
+	public function testConstructString()
82
+	{
83
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
84
+
85
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
86
+
87
+		$this->assertSame(array(
88
+			'type' => 'string',
89
+		), $object->toArray());
90
+	}
91
+
92
+	/**
93
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
94
+	 */
95
+	public function testConstructStringEmptyDefault()
96
+	{
97
+		$this->expectException('\SwaggerGen\Exception', "Unparseable string definition: 'string='");
98
+
99
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string= ');
100
+	}
101
+
102
+	/**
103
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
104
+	 */
105
+	public function testConstructStringDefaultLengthInclusive()
106
+	{
107
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[4,4]=word');
108
+
109
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
110
+
111
+		$this->assertSame(array(
112
+			'type' => 'string',
113
+			'default' => 'word',
114
+			'minLength' => 4,
115
+			'maxLength' => 4,
116
+		), $object->toArray());
117
+	}
118
+
119
+	/**
120
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
121
+	 */
122
+	public function testConstructStringDefaultLengthExclusive()
123
+	{
124
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string<3,5>=word');
125
+
126
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
127
+
128
+		$this->assertSame(array(
129
+			'type' => 'string',
130
+			'default' => 'word',
131
+			'minLength' => 4,
132
+			'maxLength' => 4,
133
+		), $object->toArray());
134
+	}
135
+
136
+	/**
137
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
138
+	 */
139
+	public function testConstructBinary()
140
+	{
141
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'binary');
142
+
143
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
144
+
145
+		$this->assertSame(array(
146
+			'type' => 'string',
147
+			'format' => 'binary',
148
+		), $object->toArray());
149
+	}
150
+
151
+	/**
152
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
153
+	 */
154
+	public function testConstructEnumRange()
155
+	{
156
+		$this->expectException('\SwaggerGen\Exception', "Range not allowed in enumeration definition: 'enum(a,b)[,]'");
157
+
158
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)[,]');
159
+	}
160
+
161
+	/**
162
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
163
+	 */
164
+	public function testConstructEnumInvalidDefault()
165
+	{
166
+		$this->expectException('\SwaggerGen\Exception', "Invalid enum default: 'c'");
167
+
168
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)=c');
169
+	}
170
+
171
+	/**
172
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
173
+	 */
174
+	public function testConstructEnum()
175
+	{
176
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)');
177
+
178
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
179
+
180
+		$this->assertSame(array(
181
+			'type' => 'string',
182
+			'enum' => array('a', 'b'),
183
+		), $object->toArray());
184
+	}
185
+
186
+	/**
187
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
188
+	 */
189
+	public function testConstructEnumWithDefault()
190
+	{
191
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'enum(a,b)=a');
192
+
193
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
194
+
195
+		$this->assertSame(array(
196
+			'type' => 'string',
197
+			'default' => 'a',
198
+			'enum' => array('a', 'b'),
199
+		), $object->toArray());
200
+	}
201
+
202
+	/**
203
+	 * @covers \SwaggerGen\Swagger\Type\StringType::__construct
204
+	 */
205
+	public function testConstructPattern()
206
+	{
207
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string([a-z])');
208
+
209
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
210
+
211
+		$this->assertSame(array(
212
+			'type' => 'string',
213
+			'pattern' => '[a-z]',
214
+		), $object->toArray());
215
+	}
216
+
217
+	/**
218
+	 * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
219
+	 */
220
+	public function testCommandDefaultNoValue()
221
+	{
222
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
223
+
224
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
225
+
226
+		$this->expectException('\SwaggerGen\Exception', "Empty string default");
227
+		$object->handleCommand('default', '');
228
+	}
229
+
230
+	/**
231
+	 * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
232
+	 */
233
+	public function testCommandDefault()
234
+	{
235
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
236
+
237
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
238
+
239
+		$object->handleCommand('default', 'word');
240
+
241
+		$this->assertSame(array(
242
+			'type' => 'string',
243
+			'default' => 'word',
244
+		), $object->toArray());
245
+	}
246
+
247
+	/**
248
+	 * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
249
+	 */
250
+	public function testCommandPattern()
251
+	{
252
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
253
+
254
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
255
+
256
+		$object->handleCommand('pattern', '[a-z]');
257
+
258
+		$this->assertSame(array(
259
+			'type' => 'string',
260
+			'pattern' => '[a-z]',
261
+		), $object->toArray());
262
+	}
263
+
264
+	/**
265
+	 * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
266
+	 */
267
+	public function testCommandEnumWhenRange()
268
+	{
269
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string[0,]');
270
+
271
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
272
+
273
+		$this->expectException('\SwaggerGen\Exception', "Enumeration not allowed in ranged string: 'red green blue'");
274
+
275
+		$object->handleCommand('enum', 'red green blue');
276
+	}
277
+
278
+	/**
279
+	 * @covers \SwaggerGen\Swagger\Type\StringType->handleCommand
280
+	 */
281
+	public function testCommandEnum()
282
+	{
283
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
284
+
285
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
286
+
287
+		$object->handleCommand('enum', 'red green blue');
288
+
289
+		$this->assertSame(array(
290
+			'type' => 'string',
291
+			'enum' => array('red', 'green', 'blue'),
292
+		), $object->toArray());
293
+	}
294 294
 
295 295
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/AbstractTypeTest.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -3,118 +3,118 @@
 block discarded – undo
3 3
 class AbstractTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\AbstractType::__construct
20
-     */
21
-    public function testConstruct()
22
-    {
23
-        $stub = $this->getMockForAbstractClass('SwaggerGen\Swagger\Type\AbstractType', array(
24
-            $this->parent,
25
-            'whatever'
26
-        ));
27
-
28
-        $this->assertFalse($stub->handleCommand('x-extra', 'whatever'));
29
-    }
30
-
31
-    /**
32
-     * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
33
-     */
34
-    public function testCommand_Example()
35
-    {
36
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
37
-
38
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
39
-
40
-        $object->handleCommand('example', 'foo');
41
-
42
-        $this->assertSame(array(
43
-            'type' => 'string',
44
-            'example' => 'foo',
45
-        ), $object->toArray());
46
-    }
47
-
48
-    /**
49
-     * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
50
-     */
51
-    public function testCommand_Example_Json()
52
-    {
53
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
54
-
55
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
56
-
57
-        $object->handleCommand('example', '{foo:bar}');
58
-
59
-        $this->assertSame(array(
60
-            'type' => 'string',
61
-            'example' => array(
62
-                'foo' => 'bar',
63
-            ),
64
-        ), $object->toArray());
65
-    }
66
-
67
-    /**
68
-     * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
69
-     */
70
-    public function testCommand_Example_Json_Multiple_Properties()
71
-    {
72
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
73
-
74
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
75
-
76
-        $object->handleCommand('example', '{foo:bar,baz:bat}');
77
-
78
-        $this->assertSame(array(
79
-            'type' => 'string',
80
-            'example' => array(
81
-                'foo' => 'bar',
82
-                'baz' => 'bat',
83
-            ),
84
-        ), $object->toArray());
85
-    }
86
-
87
-    /**
88
-     * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
89
-     */
90
-    public function testCommand_Example_Json_String_With_Special_Chars()
91
-    {
92
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
93
-
94
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
95
-
96
-        $object->handleCommand('example', '"2019-01-01 17:59:59"');
97
-
98
-        $this->assertSame(array(
99
-            'type' => 'string',
100
-            'example' => '2019-01-01 17:59:59',
101
-        ), $object->toArray());
102
-    }
103
-
104
-    /**
105
-     * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
106
-     */
107
-    public function testCommand_Example_Invalid_Json_Not_Ignored()
108
-    {
109
-        $object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
110
-
111
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
112
-
113
-        $object->handleCommand('example', '2019-01-01{}');
114
-
115
-        $this->assertSame(array(
116
-            'type' => 'string',
117
-            'example' => '2019-01-01{}',
118
-        ), $object->toArray());
119
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\AbstractType::__construct
20
+	 */
21
+	public function testConstruct()
22
+	{
23
+		$stub = $this->getMockForAbstractClass('SwaggerGen\Swagger\Type\AbstractType', array(
24
+			$this->parent,
25
+			'whatever'
26
+		));
27
+
28
+		$this->assertFalse($stub->handleCommand('x-extra', 'whatever'));
29
+	}
30
+
31
+	/**
32
+	 * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
33
+	 */
34
+	public function testCommand_Example()
35
+	{
36
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
37
+
38
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
39
+
40
+		$object->handleCommand('example', 'foo');
41
+
42
+		$this->assertSame(array(
43
+			'type' => 'string',
44
+			'example' => 'foo',
45
+		), $object->toArray());
46
+	}
47
+
48
+	/**
49
+	 * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
50
+	 */
51
+	public function testCommand_Example_Json()
52
+	{
53
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
54
+
55
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
56
+
57
+		$object->handleCommand('example', '{foo:bar}');
58
+
59
+		$this->assertSame(array(
60
+			'type' => 'string',
61
+			'example' => array(
62
+				'foo' => 'bar',
63
+			),
64
+		), $object->toArray());
65
+	}
66
+
67
+	/**
68
+	 * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
69
+	 */
70
+	public function testCommand_Example_Json_Multiple_Properties()
71
+	{
72
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
73
+
74
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
75
+
76
+		$object->handleCommand('example', '{foo:bar,baz:bat}');
77
+
78
+		$this->assertSame(array(
79
+			'type' => 'string',
80
+			'example' => array(
81
+				'foo' => 'bar',
82
+				'baz' => 'bat',
83
+			),
84
+		), $object->toArray());
85
+	}
86
+
87
+	/**
88
+	 * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
89
+	 */
90
+	public function testCommand_Example_Json_String_With_Special_Chars()
91
+	{
92
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
93
+
94
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
95
+
96
+		$object->handleCommand('example', '"2019-01-01 17:59:59"');
97
+
98
+		$this->assertSame(array(
99
+			'type' => 'string',
100
+			'example' => '2019-01-01 17:59:59',
101
+		), $object->toArray());
102
+	}
103
+
104
+	/**
105
+	 * @covers \SwaggerGen\Swagger\Type\AbstractType->handleCommand
106
+	 */
107
+	public function testCommand_Example_Invalid_Json_Not_Ignored()
108
+	{
109
+		$object = new SwaggerGen\Swagger\Type\StringType($this->parent, 'string');
110
+
111
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\StringType', $object);
112
+
113
+		$object->handleCommand('example', '2019-01-01{}');
114
+
115
+		$this->assertSame(array(
116
+			'type' => 'string',
117
+			'example' => '2019-01-01{}',
118
+		), $object->toArray());
119
+	}
120 120
 }
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
@@ -3,154 +3,154 @@
 block discarded – undo
3 3
 class Ipv6TypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
20
-     */
21
-    public function testConstructNotAnIpv6()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
55
-     */
56
-    public function testConstructDefaultTooManyDigits()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
65
-     */
66
-    public function testConstructDefaultTooFewParts()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
75
-     */
76
-    public function testConstructDefaultTooManyParts()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
85
-     */
86
-    public function testConstructDefaultUntrimmed()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
95
-     */
96
-    public function testConstructDefault()
97
-    {
98
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344');
99
-
100
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
101
-
102
-        $this->assertSame(array(
103
-            'type' => 'string',
104
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
105
-            'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
106
-        ), $object->toArray());
107
-    }
108
-
109
-    /**
110
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
111
-     */
112
-    public function testConstructDefaultNoZeroes()
113
-    {
114
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344');
115
-
116
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
117
-
118
-        $this->assertSame(array(
119
-            'type' => 'string',
120
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
121
-            'default' => '2001:0db8:85a3::1319:8a2e:0370:7344',
122
-        ), $object->toArray());
123
-    }
124
-
125
-    /**
126
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
127
-     */
128
-    public function testCommandDefaultNoValue()
129
-    {
130
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
131
-
132
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
133
-
134
-        $this->expectException('\SwaggerGen\Exception', "Empty IPv6 default");
135
-        $object->handleCommand('default', '');
136
-    }
137
-
138
-    /**
139
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
140
-     */
141
-    public function testCommandDefault()
142
-    {
143
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
144
-
145
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
146
-
147
-        $object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344');
148
-
149
-        $this->assertSame(array(
150
-            'type' => 'string',
151
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
152
-            'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
153
-        ), $object->toArray());
154
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
20
+	 */
21
+	public function testConstructNotAnIpv6()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
55
+	 */
56
+	public function testConstructDefaultTooManyDigits()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
65
+	 */
66
+	public function testConstructDefaultTooFewParts()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
75
+	 */
76
+	public function testConstructDefaultTooManyParts()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
85
+	 */
86
+	public function testConstructDefaultUntrimmed()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
95
+	 */
96
+	public function testConstructDefault()
97
+	{
98
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344');
99
+
100
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
101
+
102
+		$this->assertSame(array(
103
+			'type' => 'string',
104
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
105
+			'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
106
+		), $object->toArray());
107
+	}
108
+
109
+	/**
110
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct
111
+	 */
112
+	public function testConstructDefaultNoZeroes()
113
+	{
114
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344');
115
+
116
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
117
+
118
+		$this->assertSame(array(
119
+			'type' => 'string',
120
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
121
+			'default' => '2001:0db8:85a3::1319:8a2e:0370:7344',
122
+		), $object->toArray());
123
+	}
124
+
125
+	/**
126
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
127
+	 */
128
+	public function testCommandDefaultNoValue()
129
+	{
130
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
131
+
132
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
133
+
134
+		$this->expectException('\SwaggerGen\Exception', "Empty IPv6 default");
135
+		$object->handleCommand('default', '');
136
+	}
137
+
138
+	/**
139
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand
140
+	 */
141
+	public function testCommandDefault()
142
+	{
143
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6');
144
+
145
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object);
146
+
147
+		$object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344');
148
+
149
+		$this->assertSame(array(
150
+			'type' => 'string',
151
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN,
152
+			'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344',
153
+		), $object->toArray());
154
+	}
155 155
 
156 156
 }
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
@@ -3,138 +3,138 @@
 block discarded – undo
3 3
 class Ipv4TypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
20
-     */
21
-    public function testConstructNotAnIpv4()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
55
-     */
56
-    public function testConstructDefaultRange()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
65
-     */
66
-    public function testConstructDefault3Numbers()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
75
-     */
76
-    public function testConstructDefault5Numbers()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
85
-     */
86
-    public function testConstructDefaultUntrimmed()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
95
-     */
96
-    public function testConstructDefault()
97
-    {
98
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89');
99
-
100
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
101
-
102
-        $this->assertSame(array(
103
-            'type' => 'string',
104
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
105
-            'default' => '123.45.67.89',
106
-        ), $object->toArray());
107
-    }
108
-
109
-    /**
110
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
111
-     */
112
-    public function testCommandDefaultNoValue()
113
-    {
114
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
115
-
116
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
117
-
118
-        $this->expectException('\SwaggerGen\Exception', "Empty IPv4 default");
119
-        $object->handleCommand('default', '');
120
-    }
121
-
122
-    /**
123
-     * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
124
-     */
125
-    public function testCommandDefault()
126
-    {
127
-        $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
128
-
129
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
130
-
131
-        $object->handleCommand('default', '123.45.67.89');
132
-
133
-        $this->assertSame(array(
134
-            'type' => 'string',
135
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
136
-            'default' => '123.45.67.89',
137
-        ), $object->toArray());
138
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
20
+	 */
21
+	public function testConstructNotAnIpv4()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
55
+	 */
56
+	public function testConstructDefaultRange()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
65
+	 */
66
+	public function testConstructDefault3Numbers()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
75
+	 */
76
+	public function testConstructDefault5Numbers()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
85
+	 */
86
+	public function testConstructDefaultUntrimmed()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct
95
+	 */
96
+	public function testConstructDefault()
97
+	{
98
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89');
99
+
100
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
101
+
102
+		$this->assertSame(array(
103
+			'type' => 'string',
104
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
105
+			'default' => '123.45.67.89',
106
+		), $object->toArray());
107
+	}
108
+
109
+	/**
110
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
111
+	 */
112
+	public function testCommandDefaultNoValue()
113
+	{
114
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
115
+
116
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
117
+
118
+		$this->expectException('\SwaggerGen\Exception', "Empty IPv4 default");
119
+		$object->handleCommand('default', '');
120
+	}
121
+
122
+	/**
123
+	 * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand
124
+	 */
125
+	public function testCommandDefault()
126
+	{
127
+		$object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4');
128
+
129
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object);
130
+
131
+		$object->handleCommand('default', '123.45.67.89');
132
+
133
+		$this->assertSame(array(
134
+			'type' => 'string',
135
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN,
136
+			'default' => '123.45.67.89',
137
+		), $object->toArray());
138
+	}
139 139
 
140 140
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/Custom/EmailTypeTest.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -3,118 +3,118 @@
 block discarded – undo
3 3
 class EmailTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
20
-     */
21
-    public function testConstructNotAnEmail()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
55
-     */
56
-    public function testConstructDefaultDoubleAt()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
65
-     */
66
-    public function testConstructDefaultUntrimmed()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
75
-     */
76
-    public function testConstructDefault()
77
-    {
78
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]');
79
-
80
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
81
-
82
-        $this->assertSame(array(
83
-            'type' => 'string',
84
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
85
-            'default' => '[email protected]',
86
-        ), $object->toArray());
87
-    }
88
-
89
-    /**
90
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
91
-     */
92
-    public function testCommandDefaultNoValue()
93
-    {
94
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
95
-
96
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
97
-
98
-        $this->expectException('\SwaggerGen\Exception', "Empty email default");
99
-        $object->handleCommand('default', '');
100
-    }
101
-
102
-    /**
103
-     * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
104
-     */
105
-    public function testCommandDefault()
106
-    {
107
-        $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
108
-
109
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
110
-
111
-        $object->handleCommand('default', '[email protected]');
112
-
113
-        $this->assertSame(array(
114
-            'type' => 'string',
115
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
116
-            'default' => '[email protected]',
117
-        ), $object->toArray());
118
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
20
+	 */
21
+	public function testConstructNotAnEmail()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
55
+	 */
56
+	public function testConstructDefaultDoubleAt()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
65
+	 */
66
+	public function testConstructDefaultUntrimmed()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct
75
+	 */
76
+	public function testConstructDefault()
77
+	{
78
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]');
79
+
80
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
81
+
82
+		$this->assertSame(array(
83
+			'type' => 'string',
84
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
85
+			'default' => '[email protected]',
86
+		), $object->toArray());
87
+	}
88
+
89
+	/**
90
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
91
+	 */
92
+	public function testCommandDefaultNoValue()
93
+	{
94
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
95
+
96
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
97
+
98
+		$this->expectException('\SwaggerGen\Exception', "Empty email default");
99
+		$object->handleCommand('default', '');
100
+	}
101
+
102
+	/**
103
+	 * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand
104
+	 */
105
+	public function testCommandDefault()
106
+	{
107
+		$object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email');
108
+
109
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object);
110
+
111
+		$object->handleCommand('default', '[email protected]');
112
+
113
+		$this->assertSame(array(
114
+			'type' => 'string',
115
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN,
116
+			'default' => '[email protected]',
117
+		), $object->toArray());
118
+	}
119 119
 
120 120
 }
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
@@ -3,148 +3,148 @@
 block discarded – undo
3 3
 class MacTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
20
-     */
21
-    public function testConstructNotAnMac()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'");
24
-
25
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
30
-     */
31
-    public function testConstruct()
32
-    {
33
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
34
-
35
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
36
-
37
-        $this->assertSame(array(
38
-            'type' => 'string',
39
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
40
-        ), $object->toArray());
41
-    }
42
-
43
-    /**
44
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
45
-     */
46
-    public function testConstructEmptyDefault()
47
-    {
48
-        $this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='");
49
-
50
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= ');
51
-    }
52
-
53
-    /**
54
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
55
-     */
56
-    public function testConstructDefaultTooFewBytes()
57
-    {
58
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'");
59
-
60
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF');
61
-    }
62
-
63
-    /**
64
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
65
-     */
66
-    public function testConstructDefaultTooManyBytes()
67
-    {
68
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'");
69
-
70
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF');
71
-    }
72
-
73
-    /**
74
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
75
-     */
76
-    public function testConstructDefaultTooFewDigits()
77
-    {
78
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'");
79
-
80
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF');
81
-    }
82
-
83
-    /**
84
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
85
-     */
86
-    public function testConstructDefaultTooManyDigits()
87
-    {
88
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'");
89
-
90
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF');
91
-    }
92
-
93
-    /**
94
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
95
-     */
96
-    public function testConstructDefaultUntrimmed()
97
-    {
98
-        $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'");
99
-
100
-        new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF');
101
-    }
102
-
103
-    /**
104
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
105
-     */
106
-    public function testConstructDefault()
107
-    {
108
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF');
109
-
110
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
111
-
112
-        $this->assertSame(array(
113
-            'type' => 'string',
114
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
115
-            'default' => 'FF:FF:FF:FF:FF:FF',
116
-        ), $object->toArray());
117
-    }
118
-
119
-    /**
120
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
121
-     */
122
-    public function testCommandDefaultNoValue()
123
-    {
124
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
125
-
126
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
127
-
128
-        $this->expectException('\SwaggerGen\Exception', "Empty MAC default");
129
-        $object->handleCommand('default', '');
130
-    }
131
-
132
-    /**
133
-     * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
134
-     */
135
-    public function testCommandDefault()
136
-    {
137
-        $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
138
-
139
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
140
-
141
-        $object->handleCommand('default', 'FF:FF:FF:FF:FF:FF');
142
-
143
-        $this->assertSame(array(
144
-            'type' => 'string',
145
-            'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
146
-            'default' => 'FF:FF:FF:FF:FF:FF',
147
-        ), $object->toArray());
148
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject');
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
20
+	 */
21
+	public function testConstructNotAnMac()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'");
24
+
25
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
30
+	 */
31
+	public function testConstruct()
32
+	{
33
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
34
+
35
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
36
+
37
+		$this->assertSame(array(
38
+			'type' => 'string',
39
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
40
+		), $object->toArray());
41
+	}
42
+
43
+	/**
44
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
45
+	 */
46
+	public function testConstructEmptyDefault()
47
+	{
48
+		$this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='");
49
+
50
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= ');
51
+	}
52
+
53
+	/**
54
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
55
+	 */
56
+	public function testConstructDefaultTooFewBytes()
57
+	{
58
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'");
59
+
60
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF');
61
+	}
62
+
63
+	/**
64
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
65
+	 */
66
+	public function testConstructDefaultTooManyBytes()
67
+	{
68
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'");
69
+
70
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF');
71
+	}
72
+
73
+	/**
74
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
75
+	 */
76
+	public function testConstructDefaultTooFewDigits()
77
+	{
78
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'");
79
+
80
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF');
81
+	}
82
+
83
+	/**
84
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
85
+	 */
86
+	public function testConstructDefaultTooManyDigits()
87
+	{
88
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'");
89
+
90
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF');
91
+	}
92
+
93
+	/**
94
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
95
+	 */
96
+	public function testConstructDefaultUntrimmed()
97
+	{
98
+		$this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'");
99
+
100
+		new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF');
101
+	}
102
+
103
+	/**
104
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct
105
+	 */
106
+	public function testConstructDefault()
107
+	{
108
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF');
109
+
110
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
111
+
112
+		$this->assertSame(array(
113
+			'type' => 'string',
114
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
115
+			'default' => 'FF:FF:FF:FF:FF:FF',
116
+		), $object->toArray());
117
+	}
118
+
119
+	/**
120
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
121
+	 */
122
+	public function testCommandDefaultNoValue()
123
+	{
124
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
125
+
126
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
127
+
128
+		$this->expectException('\SwaggerGen\Exception', "Empty MAC default");
129
+		$object->handleCommand('default', '');
130
+	}
131
+
132
+	/**
133
+	 * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand
134
+	 */
135
+	public function testCommandDefault()
136
+	{
137
+		$object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac');
138
+
139
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object);
140
+
141
+		$object->handleCommand('default', 'FF:FF:FF:FF:FF:FF');
142
+
143
+		$this->assertSame(array(
144
+			'type' => 'string',
145
+			'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN,
146
+			'default' => 'FF:FF:FF:FF:FF:FF',
147
+		), $object->toArray());
148
+	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
tests/Swagger/Type/FileTypeTest.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -3,112 +3,112 @@
 block discarded – undo
3 3
 class FileTypeTest extends SwaggerGen_TestCase
4 4
 {
5 5
 
6
-    protected $parent;
7
-
8
-    protected function setUp(): void
9
-    {
10
-        $this->parent = new \SwaggerGen\Swagger\Swagger;
11
-    }
12
-
13
-    protected function assertPreConditions(): void
14
-    {
15
-        $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
-    }
17
-
18
-    /**
19
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
20
-     */
21
-    public function testConstructNotAFile()
22
-    {
23
-        $this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'");
24
-
25
-        $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong');
26
-    }
27
-
28
-    /**
29
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
30
-     */
31
-    public function testConstructNotParameter()
32
-    {
33
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
34
-
35
-        $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file');
36
-    }
37
-
38
-    /**
39
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
40
-     */
41
-    public function testConstructNotFormParameter()
42
-    {
43
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
44
-
45
-        $parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever');
46
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
47
-    }
48
-
49
-    /**
50
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
51
-     */
52
-    public function testConstructNoFormConsumes()
53
-    {
54
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
55
-
56
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
57
-        $operation->handleCommand('consumes', 'text');
58
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
59
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
60
-    }
61
-
62
-    /**
63
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
64
-     */
65
-    public function testConstructNotExclusiveFormConsumes()
66
-    {
67
-        $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
68
-
69
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
70
-        $operation->handleCommand('consumes', 'text file');
71
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
72
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
73
-    }
74
-
75
-    /**
76
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
77
-     */
78
-    public function testConstructFormConsumes()
79
-    {
80
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
81
-        $operation->handleCommand('consumes', 'form');
82
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
83
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
84
-    }
85
-
86
-    /**
87
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
88
-     */
89
-    public function testConstructFileformConsumes()
90
-    {
91
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
92
-        $operation->handleCommand('consumes', 'fileform');
93
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
94
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
95
-    }
96
-
97
-    /**
98
-     * @covers \SwaggerGen\Swagger\Type\FileType::__construct
99
-     */
100
-    public function testConstructBothConsumes()
101
-    {
102
-        $operation = new SwaggerGen\Swagger\Operation($this->parent);
103
-        $operation->handleCommand('consumes', 'fileform form');
104
-        $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
105
-        $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
106
-
107
-        $this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object);
108
-
109
-        $this->assertSame(array(
110
-            'type' => 'file',
111
-        ), $object->toArray());
112
-    }
6
+	protected $parent;
7
+
8
+	protected function setUp(): void
9
+	{
10
+		$this->parent = new \SwaggerGen\Swagger\Swagger;
11
+	}
12
+
13
+	protected function assertPreConditions(): void
14
+	{
15
+		$this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent);
16
+	}
17
+
18
+	/**
19
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
20
+	 */
21
+	public function testConstructNotAFile()
22
+	{
23
+		$this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'");
24
+
25
+		$object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong');
26
+	}
27
+
28
+	/**
29
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
30
+	 */
31
+	public function testConstructNotParameter()
32
+	{
33
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
34
+
35
+		$object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file');
36
+	}
37
+
38
+	/**
39
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
40
+	 */
41
+	public function testConstructNotFormParameter()
42
+	{
43
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter");
44
+
45
+		$parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever');
46
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
47
+	}
48
+
49
+	/**
50
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
51
+	 */
52
+	public function testConstructNoFormConsumes()
53
+	{
54
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
55
+
56
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
57
+		$operation->handleCommand('consumes', 'text');
58
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
59
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
60
+	}
61
+
62
+	/**
63
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
64
+	 */
65
+	public function testConstructNotExclusiveFormConsumes()
66
+	{
67
+		$this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume");
68
+
69
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
70
+		$operation->handleCommand('consumes', 'text file');
71
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
72
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
73
+	}
74
+
75
+	/**
76
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
77
+	 */
78
+	public function testConstructFormConsumes()
79
+	{
80
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
81
+		$operation->handleCommand('consumes', 'form');
82
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
83
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
84
+	}
85
+
86
+	/**
87
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
88
+	 */
89
+	public function testConstructFileformConsumes()
90
+	{
91
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
92
+		$operation->handleCommand('consumes', 'fileform');
93
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
94
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
95
+	}
96
+
97
+	/**
98
+	 * @covers \SwaggerGen\Swagger\Type\FileType::__construct
99
+	 */
100
+	public function testConstructBothConsumes()
101
+	{
102
+		$operation = new SwaggerGen\Swagger\Operation($this->parent);
103
+		$operation->handleCommand('consumes', 'fileform form');
104
+		$parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever');
105
+		$object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file');
106
+
107
+		$this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object);
108
+
109
+		$this->assertSame(array(
110
+			'type' => 'file',
111
+		), $object->toArray());
112
+	}
113 113
 
114 114
 }
Please login to merge, or discard this patch.