@@ -3,293 +3,293 @@ |
||
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 | } |
@@ -3,118 +3,118 @@ |
||
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 | } |
@@ -3,154 +3,154 @@ |
||
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 | } |
@@ -3,138 +3,138 @@ |
||
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 | } |
@@ -3,118 +3,118 @@ |
||
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 | } |
@@ -3,148 +3,148 @@ |
||
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 | } |
@@ -3,112 +3,112 @@ |
||
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 | } |
@@ -3,372 +3,372 @@ |
||
3 | 3 | class ArrayTypeTest 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\ArrayType::__construct |
|
20 | - */ |
|
21 | - public function testConstructNotAArray() |
|
22 | - { |
|
23 | - $this->expectException('\SwaggerGen\Exception', "Not an array: 'wrong'"); |
|
24 | - |
|
25 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'wrong'); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
30 | - */ |
|
31 | - public function testConstructInvalidDefault() |
|
32 | - { |
|
33 | - $this->expectException('\SwaggerGen\Exception', "Unparseable array definition: 'array=null'"); |
|
34 | - |
|
35 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array=null'); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
40 | - */ |
|
41 | - public function testConstructMultiLimit() |
|
42 | - { |
|
43 | - $this->expectException('\SwaggerGen\Exception', "Multi array only allowed on query or form parameter: 'multi'"); |
|
44 | - |
|
45 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'multi'); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
50 | - */ |
|
51 | - public function testConstructMultiOnFormParam() |
|
52 | - { |
|
53 | - $param = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'multi foo'); |
|
54 | - |
|
55 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $param); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
60 | - */ |
|
61 | - public function testConstructEmptyRange() |
|
62 | - { |
|
63 | - $this->expectException('\SwaggerGen\Exception', "Empty array range: 'array[,]'"); |
|
64 | - |
|
65 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[,]'); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
70 | - */ |
|
71 | - public function testConstructRangeStart() |
|
72 | - { |
|
73 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[0,]'); |
|
74 | - |
|
75 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
76 | - |
|
77 | - $this->assertSame(array( |
|
78 | - 'type' => 'array', |
|
79 | - 'minItems' => 0, |
|
80 | - ), $object->toArray()); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
85 | - */ |
|
86 | - public function testConstructRangeBoth() |
|
87 | - { |
|
88 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array<2,4]'); |
|
89 | - |
|
90 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
91 | - |
|
92 | - $this->assertSame(array( |
|
93 | - 'type' => 'array', |
|
94 | - 'minItems' => 3, |
|
95 | - 'maxItems' => 4, |
|
96 | - ), $object->toArray()); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
101 | - */ |
|
102 | - public function testConstructEmptyItems() |
|
103 | - { |
|
104 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array()'); |
|
105 | - |
|
106 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
107 | - |
|
108 | - $this->assertSame(array( |
|
109 | - 'type' => 'array', |
|
110 | - ), $object->toArray()); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
115 | - */ |
|
116 | - public function testConstructBadItems() |
|
117 | - { |
|
118 | - $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'"); |
|
119 | - |
|
120 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(1)'); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
125 | - */ |
|
126 | - public function testConstructTypeItems() |
|
127 | - { |
|
128 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)'); |
|
129 | - |
|
130 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
131 | - |
|
132 | - $this->assertSame(array( |
|
133 | - 'type' => 'array', |
|
134 | - 'items' => array( |
|
135 | - 'type' => 'string', |
|
136 | - ), |
|
137 | - ), $object->toArray()); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
142 | - */ |
|
143 | - public function testConstructBracketsTypeItems() |
|
144 | - { |
|
145 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, '[string]'); |
|
146 | - |
|
147 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
148 | - |
|
149 | - $this->assertSame(array( |
|
150 | - 'type' => 'array', |
|
151 | - 'items' => array( |
|
152 | - 'type' => 'string', |
|
153 | - ), |
|
154 | - ), $object->toArray()); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
159 | - */ |
|
160 | - public function testConstructTypeItemsPipes() |
|
161 | - { |
|
162 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'pipes(string)'); |
|
163 | - |
|
164 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
165 | - |
|
166 | - $this->assertSame(array( |
|
167 | - 'type' => 'array', |
|
168 | - 'items' => array( |
|
169 | - 'type' => 'string', |
|
170 | - ), |
|
171 | - 'collectionFormat' => 'pipes', |
|
172 | - ), $object->toArray()); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
177 | - */ |
|
178 | - public function testConstructReferenceItems() |
|
179 | - { |
|
180 | - $this->parent->handleCommand('model', 'Item'); |
|
181 | - |
|
182 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(Item)'); |
|
183 | - |
|
184 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
185 | - |
|
186 | - $this->assertSame(array( |
|
187 | - 'type' => 'array', |
|
188 | - 'items' => array( |
|
189 | - '$ref' => '#/definitions/Item', |
|
190 | - ), |
|
191 | - ), $object->toArray()); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
196 | - */ |
|
197 | - public function testCommandMinUpperBound() |
|
198 | - { |
|
199 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
200 | - |
|
201 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
202 | - |
|
203 | - $this->expectException('\SwaggerGen\Exception', "Minimum greater than maximum: '6'"); |
|
204 | - |
|
205 | - $object->handleCommand('min', '6'); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
210 | - */ |
|
211 | - public function testCommandMinLowerBound() |
|
212 | - { |
|
213 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
214 | - |
|
215 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
216 | - |
|
217 | - $this->expectException('\SwaggerGen\Exception', "Minimum less than zero: '-1'"); |
|
218 | - |
|
219 | - $object->handleCommand('min', '-1'); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
224 | - */ |
|
225 | - public function testCommandMin() |
|
226 | - { |
|
227 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
228 | - |
|
229 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
230 | - |
|
231 | - $object->handleCommand('min', '4'); |
|
232 | - |
|
233 | - $this->assertSame(array( |
|
234 | - 'type' => 'array', |
|
235 | - 'minItems' => 4, |
|
236 | - 'maxItems' => 5, |
|
237 | - ), $object->toArray()); |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
242 | - */ |
|
243 | - public function testCommandMaxLowerBound() |
|
244 | - { |
|
245 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,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\ArrayType::__construct |
|
20 | + */ |
|
21 | + public function testConstructNotAArray() |
|
22 | + { |
|
23 | + $this->expectException('\SwaggerGen\Exception', "Not an array: 'wrong'"); |
|
24 | + |
|
25 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'wrong'); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
30 | + */ |
|
31 | + public function testConstructInvalidDefault() |
|
32 | + { |
|
33 | + $this->expectException('\SwaggerGen\Exception', "Unparseable array definition: 'array=null'"); |
|
34 | + |
|
35 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array=null'); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
40 | + */ |
|
41 | + public function testConstructMultiLimit() |
|
42 | + { |
|
43 | + $this->expectException('\SwaggerGen\Exception', "Multi array only allowed on query or form parameter: 'multi'"); |
|
44 | + |
|
45 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'multi'); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
50 | + */ |
|
51 | + public function testConstructMultiOnFormParam() |
|
52 | + { |
|
53 | + $param = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'multi foo'); |
|
54 | + |
|
55 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $param); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
60 | + */ |
|
61 | + public function testConstructEmptyRange() |
|
62 | + { |
|
63 | + $this->expectException('\SwaggerGen\Exception', "Empty array range: 'array[,]'"); |
|
64 | + |
|
65 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[,]'); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
70 | + */ |
|
71 | + public function testConstructRangeStart() |
|
72 | + { |
|
73 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[0,]'); |
|
74 | + |
|
75 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
76 | + |
|
77 | + $this->assertSame(array( |
|
78 | + 'type' => 'array', |
|
79 | + 'minItems' => 0, |
|
80 | + ), $object->toArray()); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
85 | + */ |
|
86 | + public function testConstructRangeBoth() |
|
87 | + { |
|
88 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array<2,4]'); |
|
89 | + |
|
90 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
91 | + |
|
92 | + $this->assertSame(array( |
|
93 | + 'type' => 'array', |
|
94 | + 'minItems' => 3, |
|
95 | + 'maxItems' => 4, |
|
96 | + ), $object->toArray()); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
101 | + */ |
|
102 | + public function testConstructEmptyItems() |
|
103 | + { |
|
104 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array()'); |
|
105 | + |
|
106 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
107 | + |
|
108 | + $this->assertSame(array( |
|
109 | + 'type' => 'array', |
|
110 | + ), $object->toArray()); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
115 | + */ |
|
116 | + public function testConstructBadItems() |
|
117 | + { |
|
118 | + $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'"); |
|
119 | + |
|
120 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(1)'); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
125 | + */ |
|
126 | + public function testConstructTypeItems() |
|
127 | + { |
|
128 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)'); |
|
129 | + |
|
130 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
131 | + |
|
132 | + $this->assertSame(array( |
|
133 | + 'type' => 'array', |
|
134 | + 'items' => array( |
|
135 | + 'type' => 'string', |
|
136 | + ), |
|
137 | + ), $object->toArray()); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
142 | + */ |
|
143 | + public function testConstructBracketsTypeItems() |
|
144 | + { |
|
145 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, '[string]'); |
|
146 | + |
|
147 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
148 | + |
|
149 | + $this->assertSame(array( |
|
150 | + 'type' => 'array', |
|
151 | + 'items' => array( |
|
152 | + 'type' => 'string', |
|
153 | + ), |
|
154 | + ), $object->toArray()); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
159 | + */ |
|
160 | + public function testConstructTypeItemsPipes() |
|
161 | + { |
|
162 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'pipes(string)'); |
|
163 | + |
|
164 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
165 | + |
|
166 | + $this->assertSame(array( |
|
167 | + 'type' => 'array', |
|
168 | + 'items' => array( |
|
169 | + 'type' => 'string', |
|
170 | + ), |
|
171 | + 'collectionFormat' => 'pipes', |
|
172 | + ), $object->toArray()); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @covers \SwaggerGen\Swagger\Type\ArrayType::__construct |
|
177 | + */ |
|
178 | + public function testConstructReferenceItems() |
|
179 | + { |
|
180 | + $this->parent->handleCommand('model', 'Item'); |
|
181 | + |
|
182 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(Item)'); |
|
183 | + |
|
184 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
185 | + |
|
186 | + $this->assertSame(array( |
|
187 | + 'type' => 'array', |
|
188 | + 'items' => array( |
|
189 | + '$ref' => '#/definitions/Item', |
|
190 | + ), |
|
191 | + ), $object->toArray()); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
196 | + */ |
|
197 | + public function testCommandMinUpperBound() |
|
198 | + { |
|
199 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
200 | + |
|
201 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
202 | + |
|
203 | + $this->expectException('\SwaggerGen\Exception', "Minimum greater than maximum: '6'"); |
|
204 | + |
|
205 | + $object->handleCommand('min', '6'); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
210 | + */ |
|
211 | + public function testCommandMinLowerBound() |
|
212 | + { |
|
213 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
214 | + |
|
215 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
216 | + |
|
217 | + $this->expectException('\SwaggerGen\Exception', "Minimum less than zero: '-1'"); |
|
218 | + |
|
219 | + $object->handleCommand('min', '-1'); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
224 | + */ |
|
225 | + public function testCommandMin() |
|
226 | + { |
|
227 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
228 | + |
|
229 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
230 | + |
|
231 | + $object->handleCommand('min', '4'); |
|
232 | + |
|
233 | + $this->assertSame(array( |
|
234 | + 'type' => 'array', |
|
235 | + 'minItems' => 4, |
|
236 | + 'maxItems' => 5, |
|
237 | + ), $object->toArray()); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
242 | + */ |
|
243 | + public function testCommandMaxLowerBound() |
|
244 | + { |
|
245 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
246 | 246 | |
247 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
248 | - |
|
249 | - $this->expectException('\SwaggerGen\Exception', "Maximum less than minimum: '2'"); |
|
250 | - |
|
251 | - $object->handleCommand('max', '2'); |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
256 | - */ |
|
257 | - public function testCommandMaxUpperBound() |
|
258 | - { |
|
259 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
260 | - |
|
261 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
247 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
248 | + |
|
249 | + $this->expectException('\SwaggerGen\Exception', "Maximum less than minimum: '2'"); |
|
250 | + |
|
251 | + $object->handleCommand('max', '2'); |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
256 | + */ |
|
257 | + public function testCommandMaxUpperBound() |
|
258 | + { |
|
259 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
260 | + |
|
261 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
262 | 262 | |
263 | - $this->expectException('\SwaggerGen\Exception', "Maximum less than zero: '-1'"); |
|
263 | + $this->expectException('\SwaggerGen\Exception', "Maximum less than zero: '-1'"); |
|
264 | 264 | |
265 | - $object->handleCommand('max', '-1'); |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
270 | - */ |
|
271 | - public function testCommandMax() |
|
272 | - { |
|
273 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
265 | + $object->handleCommand('max', '-1'); |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
270 | + */ |
|
271 | + public function testCommandMax() |
|
272 | + { |
|
273 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
274 | 274 | |
275 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
276 | - |
|
277 | - $object->handleCommand('max', '4'); |
|
275 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
276 | + |
|
277 | + $object->handleCommand('max', '4'); |
|
278 | 278 | |
279 | - $this->assertSame(array( |
|
280 | - 'type' => 'array', |
|
281 | - 'minItems' => 3, |
|
282 | - 'maxItems' => 4, |
|
283 | - ), $object->toArray()); |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
288 | - */ |
|
289 | - public function testCommandEmptyItems() |
|
290 | - { |
|
291 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
279 | + $this->assertSame(array( |
|
280 | + 'type' => 'array', |
|
281 | + 'minItems' => 3, |
|
282 | + 'maxItems' => 4, |
|
283 | + ), $object->toArray()); |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
288 | + */ |
|
289 | + public function testCommandEmptyItems() |
|
290 | + { |
|
291 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
292 | 292 | |
293 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
293 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
294 | 294 | |
295 | - $this->expectException('\SwaggerGen\Exception', "Empty items definition: ''"); |
|
295 | + $this->expectException('\SwaggerGen\Exception', "Empty items definition: ''"); |
|
296 | 296 | |
297 | - $object->handleCommand('items', ''); |
|
298 | - } |
|
297 | + $object->handleCommand('items', ''); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
302 | - */ |
|
303 | - public function testCommandBadItems() |
|
304 | - { |
|
305 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
300 | + /** |
|
301 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
302 | + */ |
|
303 | + public function testCommandBadItems() |
|
304 | + { |
|
305 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array[3,5]'); |
|
306 | 306 | |
307 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
308 | - |
|
309 | - $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'"); |
|
307 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
308 | + |
|
309 | + $this->expectException('\SwaggerGen\Exception', "Unparseable items definition: '1'"); |
|
310 | 310 | |
311 | - $object->handleCommand('items', '1'); |
|
312 | - } |
|
311 | + $object->handleCommand('items', '1'); |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
316 | - */ |
|
317 | - public function testCommandTypeItems() |
|
318 | - { |
|
319 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
320 | - |
|
321 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
322 | - |
|
323 | - $object->handleCommand('items', 'string'); |
|
324 | - |
|
325 | - $this->assertSame(array( |
|
326 | - 'type' => 'array', |
|
327 | - 'items' => array( |
|
328 | - 'type' => 'string', |
|
329 | - ), |
|
330 | - ), $object->toArray()); |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
335 | - */ |
|
336 | - public function testCommandReferenceItems() |
|
337 | - { |
|
338 | - $this->parent->handleCommand('model', 'Item'); |
|
314 | + /** |
|
315 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
316 | + */ |
|
317 | + public function testCommandTypeItems() |
|
318 | + { |
|
319 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
320 | + |
|
321 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
322 | + |
|
323 | + $object->handleCommand('items', 'string'); |
|
324 | + |
|
325 | + $this->assertSame(array( |
|
326 | + 'type' => 'array', |
|
327 | + 'items' => array( |
|
328 | + 'type' => 'string', |
|
329 | + ), |
|
330 | + ), $object->toArray()); |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
335 | + */ |
|
336 | + public function testCommandReferenceItems() |
|
337 | + { |
|
338 | + $this->parent->handleCommand('model', 'Item'); |
|
339 | 339 | |
340 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
341 | - |
|
342 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
340 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array'); |
|
341 | + |
|
342 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
343 | 343 | |
344 | - $object->handleCommand('items', 'Item'); |
|
344 | + $object->handleCommand('items', 'Item'); |
|
345 | 345 | |
346 | - $this->assertSame(array( |
|
347 | - 'type' => 'array', |
|
348 | - 'items' => array( |
|
349 | - '$ref' => '#/definitions/Item', |
|
350 | - ), |
|
351 | - ), $object->toArray()); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
356 | - */ |
|
357 | - public function testCommandPassing() |
|
358 | - { |
|
359 | - $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)'); |
|
346 | + $this->assertSame(array( |
|
347 | + 'type' => 'array', |
|
348 | + 'items' => array( |
|
349 | + '$ref' => '#/definitions/Item', |
|
350 | + ), |
|
351 | + ), $object->toArray()); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * @covers \SwaggerGen\Swagger\Type\ArrayType->handleCommand |
|
356 | + */ |
|
357 | + public function testCommandPassing() |
|
358 | + { |
|
359 | + $object = new SwaggerGen\Swagger\Type\ArrayType($this->parent, 'array(string)'); |
|
360 | 360 | |
361 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
361 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\ArrayType', $object); |
|
362 | 362 | |
363 | - $object->handleCommand('default', 'good'); |
|
364 | - |
|
365 | - $this->assertSame(array( |
|
366 | - 'type' => 'array', |
|
367 | - 'items' => array( |
|
368 | - 'type' => 'string', |
|
369 | - 'default' => 'good', |
|
370 | - ), |
|
371 | - ), $object->toArray()); |
|
372 | - } |
|
363 | + $object->handleCommand('default', 'good'); |
|
364 | + |
|
365 | + $this->assertSame(array( |
|
366 | + 'type' => 'array', |
|
367 | + 'items' => array( |
|
368 | + 'type' => 'string', |
|
369 | + 'default' => 'good', |
|
370 | + ), |
|
371 | + ), $object->toArray()); |
|
372 | + } |
|
373 | 373 | |
374 | 374 | } |
@@ -3,358 +3,358 @@ |
||
3 | 3 | class IntegerTypeTest 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\IntegerType::__construct |
|
20 | - */ |
|
21 | - public function testConstructNotAInteger() |
|
22 | - { |
|
23 | - $this->expectException('\SwaggerGen\Exception', "Not an integer: 'wrong'"); |
|
24 | - |
|
25 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'wrong'); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
30 | - */ |
|
31 | - public function testConstructInvalidDefault() |
|
32 | - { |
|
33 | - $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer=null'"); |
|
34 | - |
|
35 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=null'); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
40 | - */ |
|
41 | - public function testConstructNoSpecificationAllowed() |
|
42 | - { |
|
43 | - $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer()=1'"); |
|
44 | - |
|
45 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer()=1'); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
50 | - */ |
|
51 | - public function testConstructEmptyRange() |
|
52 | - { |
|
53 | - $this->expectException('\SwaggerGen\Exception', "Empty integer range: 'integer[,]=1'"); |
|
54 | - |
|
55 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[,]=1'); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
60 | - */ |
|
61 | - public function testConstructNotEmptyRange() |
|
62 | - { |
|
63 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'int[0,]'); |
|
64 | - |
|
65 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
66 | - |
|
67 | - $this->assertSame(array( |
|
68 | - 'type' => 'integer', |
|
69 | - 'format' => 'int32', |
|
70 | - 'minimum' => 0, |
|
71 | - ), $object->toArray()); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
76 | - */ |
|
77 | - public function testConstructInteger() |
|
78 | - { |
|
79 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
80 | - |
|
81 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
82 | - |
|
83 | - $this->assertSame(array( |
|
84 | - 'type' => 'integer', |
|
85 | - 'format' => 'int32', |
|
86 | - ), $object->toArray()); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
91 | - */ |
|
92 | - public function testConstructLong() |
|
93 | - { |
|
94 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'long'); |
|
95 | - |
|
96 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
97 | - |
|
98 | - $this->assertSame(array( |
|
99 | - 'type' => 'integer', |
|
100 | - 'format' => 'int64', |
|
101 | - ), $object->toArray()); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
106 | - */ |
|
107 | - public function testConstructZero() |
|
108 | - { |
|
109 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=0'); |
|
110 | - |
|
111 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
112 | - |
|
113 | - $this->assertSame(array( |
|
114 | - 'type' => 'integer', |
|
115 | - 'format' => 'int32', |
|
116 | - 'default' => 0, |
|
117 | - ), $object->toArray()); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
122 | - */ |
|
123 | - public function testConstructPositive() |
|
124 | - { |
|
125 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=1'); |
|
126 | - |
|
127 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
128 | - |
|
129 | - $this->assertSame(array( |
|
130 | - 'type' => 'integer', |
|
131 | - 'format' => 'int32', |
|
132 | - 'default' => 1, |
|
133 | - ), $object->toArray()); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
138 | - */ |
|
139 | - public function testConstructNegative() |
|
140 | - { |
|
141 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=-1'); |
|
142 | - |
|
143 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
144 | - |
|
145 | - $this->assertSame(array( |
|
146 | - 'type' => 'integer', |
|
147 | - 'format' => 'int32', |
|
148 | - 'default' => -1, |
|
149 | - ), $object->toArray()); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
154 | - */ |
|
155 | - public function testConstructRangeInclusive() |
|
156 | - { |
|
157 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=3'); |
|
158 | - |
|
159 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
160 | - |
|
161 | - $this->assertSame(array( |
|
162 | - 'type' => 'integer', |
|
163 | - 'format' => 'int32', |
|
164 | - 'default' => 3, |
|
165 | - 'minimum' => 2, |
|
166 | - 'maximum' => 5, |
|
167 | - ), $object->toArray()); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
172 | - */ |
|
173 | - public function testConstructRangeExclusive() |
|
174 | - { |
|
175 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3'); |
|
176 | - |
|
177 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
178 | - |
|
179 | - $this->assertSame(array( |
|
180 | - 'type' => 'integer', |
|
181 | - 'format' => 'int32', |
|
182 | - 'default' => 3, |
|
183 | - 'minimum' => 2, |
|
184 | - 'exclusiveMinimum' => true, |
|
185 | - 'maximum' => 5, |
|
186 | - 'exclusiveMaximum' => true, |
|
187 | - ), $object->toArray()); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
192 | - */ |
|
193 | - public function testConstructDefaultBeyondMaximumExclusive() |
|
194 | - { |
|
195 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=4'); |
|
196 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
197 | - |
|
198 | - $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '5'"); |
|
199 | - |
|
200 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=5'); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
205 | - */ |
|
206 | - public function testConstructDefaultBeyondMaximum() |
|
207 | - { |
|
208 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=5'); |
|
209 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
210 | - |
|
211 | - $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '6'"); |
|
212 | - |
|
213 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=6'); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
218 | - */ |
|
219 | - public function testConstructDefaultBeyondMinimumExclusive() |
|
220 | - { |
|
221 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3'); |
|
222 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
223 | - |
|
224 | - $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '2'"); |
|
225 | - |
|
226 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=2'); |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
231 | - */ |
|
232 | - public function testConstructDefaultBeyondMinimum() |
|
233 | - { |
|
234 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=2'); |
|
235 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
236 | - |
|
237 | - $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '1'"); |
|
238 | - |
|
239 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=1'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
244 | - */ |
|
245 | - public function testCommandDefaultNoValue() |
|
246 | - { |
|
247 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
248 | - |
|
249 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
250 | - |
|
251 | - $this->expectException('\SwaggerGen\Exception', "Invalid integer default: ''"); |
|
252 | - $object->handleCommand('default', ''); |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
257 | - */ |
|
258 | - public function testCommandDefaultInvalidValue() |
|
259 | - { |
|
260 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
261 | - |
|
262 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
263 | - |
|
264 | - $this->expectException('\SwaggerGen\Exception', "Invalid integer default: 'foo'"); |
|
265 | - $object->handleCommand('default', 'foo'); |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
270 | - */ |
|
271 | - public function testCommandDefaultPositive() |
|
272 | - { |
|
273 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
274 | - |
|
275 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
276 | - |
|
277 | - $object->handleCommand('default', '123'); |
|
278 | - |
|
279 | - $this->assertSame(array( |
|
280 | - 'type' => 'integer', |
|
281 | - 'format' => 'int32', |
|
282 | - 'default' => 123, |
|
283 | - ), $object->toArray()); |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
288 | - */ |
|
289 | - public function testCommandDefaultNegative() |
|
290 | - { |
|
291 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
292 | - |
|
293 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
294 | - |
|
295 | - $object->handleCommand('default', '-123'); |
|
296 | - |
|
297 | - $this->assertSame(array( |
|
298 | - 'type' => 'integer', |
|
299 | - 'format' => 'int32', |
|
300 | - 'default' => -123, |
|
301 | - ), $object->toArray()); |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
306 | - */ |
|
307 | - public function testCommandDefaultBeyondRange() |
|
308 | - { |
|
309 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[-100,100]'); |
|
310 | - |
|
311 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
312 | - |
|
313 | - $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '-123'"); |
|
314 | - $object->handleCommand('default', '-123'); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
319 | - */ |
|
320 | - public function testCommandEnum() |
|
321 | - { |
|
322 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
323 | - |
|
324 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
325 | - |
|
326 | - $object->handleCommand('enum', '-1 2 123'); |
|
327 | - $object->handleCommand('enum', '-123 0'); |
|
328 | - |
|
329 | - $this->assertEquals(array( |
|
330 | - 'type' => 'integer', |
|
331 | - 'format' => 'int32', |
|
332 | - 'enum' => array( |
|
333 | - -1, |
|
334 | - 2, |
|
335 | - 123, |
|
336 | - -123, |
|
337 | - 0, |
|
338 | - ), |
|
339 | - ), $object->toArray()); |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
344 | - */ |
|
345 | - public function testCommandStep() |
|
346 | - { |
|
347 | - $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
348 | - |
|
349 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
350 | - |
|
351 | - $object->handleCommand('step', '3'); |
|
352 | - |
|
353 | - $this->assertEquals(array( |
|
354 | - 'type' => 'integer', |
|
355 | - 'format' => 'int32', |
|
356 | - 'multipleOf' => 3, |
|
357 | - ), $object->toArray()); |
|
358 | - } |
|
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\IntegerType::__construct |
|
20 | + */ |
|
21 | + public function testConstructNotAInteger() |
|
22 | + { |
|
23 | + $this->expectException('\SwaggerGen\Exception', "Not an integer: 'wrong'"); |
|
24 | + |
|
25 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'wrong'); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
30 | + */ |
|
31 | + public function testConstructInvalidDefault() |
|
32 | + { |
|
33 | + $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer=null'"); |
|
34 | + |
|
35 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=null'); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
40 | + */ |
|
41 | + public function testConstructNoSpecificationAllowed() |
|
42 | + { |
|
43 | + $this->expectException('\SwaggerGen\Exception', "Unparseable integer definition: 'integer()=1'"); |
|
44 | + |
|
45 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer()=1'); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
50 | + */ |
|
51 | + public function testConstructEmptyRange() |
|
52 | + { |
|
53 | + $this->expectException('\SwaggerGen\Exception', "Empty integer range: 'integer[,]=1'"); |
|
54 | + |
|
55 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[,]=1'); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
60 | + */ |
|
61 | + public function testConstructNotEmptyRange() |
|
62 | + { |
|
63 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'int[0,]'); |
|
64 | + |
|
65 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
66 | + |
|
67 | + $this->assertSame(array( |
|
68 | + 'type' => 'integer', |
|
69 | + 'format' => 'int32', |
|
70 | + 'minimum' => 0, |
|
71 | + ), $object->toArray()); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
76 | + */ |
|
77 | + public function testConstructInteger() |
|
78 | + { |
|
79 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
80 | + |
|
81 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
82 | + |
|
83 | + $this->assertSame(array( |
|
84 | + 'type' => 'integer', |
|
85 | + 'format' => 'int32', |
|
86 | + ), $object->toArray()); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
91 | + */ |
|
92 | + public function testConstructLong() |
|
93 | + { |
|
94 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'long'); |
|
95 | + |
|
96 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
97 | + |
|
98 | + $this->assertSame(array( |
|
99 | + 'type' => 'integer', |
|
100 | + 'format' => 'int64', |
|
101 | + ), $object->toArray()); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
106 | + */ |
|
107 | + public function testConstructZero() |
|
108 | + { |
|
109 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=0'); |
|
110 | + |
|
111 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
112 | + |
|
113 | + $this->assertSame(array( |
|
114 | + 'type' => 'integer', |
|
115 | + 'format' => 'int32', |
|
116 | + 'default' => 0, |
|
117 | + ), $object->toArray()); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
122 | + */ |
|
123 | + public function testConstructPositive() |
|
124 | + { |
|
125 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=1'); |
|
126 | + |
|
127 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
128 | + |
|
129 | + $this->assertSame(array( |
|
130 | + 'type' => 'integer', |
|
131 | + 'format' => 'int32', |
|
132 | + 'default' => 1, |
|
133 | + ), $object->toArray()); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
138 | + */ |
|
139 | + public function testConstructNegative() |
|
140 | + { |
|
141 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer=-1'); |
|
142 | + |
|
143 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
144 | + |
|
145 | + $this->assertSame(array( |
|
146 | + 'type' => 'integer', |
|
147 | + 'format' => 'int32', |
|
148 | + 'default' => -1, |
|
149 | + ), $object->toArray()); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
154 | + */ |
|
155 | + public function testConstructRangeInclusive() |
|
156 | + { |
|
157 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=3'); |
|
158 | + |
|
159 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
160 | + |
|
161 | + $this->assertSame(array( |
|
162 | + 'type' => 'integer', |
|
163 | + 'format' => 'int32', |
|
164 | + 'default' => 3, |
|
165 | + 'minimum' => 2, |
|
166 | + 'maximum' => 5, |
|
167 | + ), $object->toArray()); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
172 | + */ |
|
173 | + public function testConstructRangeExclusive() |
|
174 | + { |
|
175 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3'); |
|
176 | + |
|
177 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
178 | + |
|
179 | + $this->assertSame(array( |
|
180 | + 'type' => 'integer', |
|
181 | + 'format' => 'int32', |
|
182 | + 'default' => 3, |
|
183 | + 'minimum' => 2, |
|
184 | + 'exclusiveMinimum' => true, |
|
185 | + 'maximum' => 5, |
|
186 | + 'exclusiveMaximum' => true, |
|
187 | + ), $object->toArray()); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
192 | + */ |
|
193 | + public function testConstructDefaultBeyondMaximumExclusive() |
|
194 | + { |
|
195 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=4'); |
|
196 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
197 | + |
|
198 | + $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '5'"); |
|
199 | + |
|
200 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=5'); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
205 | + */ |
|
206 | + public function testConstructDefaultBeyondMaximum() |
|
207 | + { |
|
208 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=5'); |
|
209 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
210 | + |
|
211 | + $this->expectException('\SwaggerGen\Exception', "Default integer beyond maximum: '6'"); |
|
212 | + |
|
213 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=6'); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
218 | + */ |
|
219 | + public function testConstructDefaultBeyondMinimumExclusive() |
|
220 | + { |
|
221 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=3'); |
|
222 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
223 | + |
|
224 | + $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '2'"); |
|
225 | + |
|
226 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer<2,5>=2'); |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @covers \SwaggerGen\Swagger\Type\IntegerType::__construct |
|
231 | + */ |
|
232 | + public function testConstructDefaultBeyondMinimum() |
|
233 | + { |
|
234 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=2'); |
|
235 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
236 | + |
|
237 | + $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '1'"); |
|
238 | + |
|
239 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[2,5]=1'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
244 | + */ |
|
245 | + public function testCommandDefaultNoValue() |
|
246 | + { |
|
247 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
248 | + |
|
249 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
250 | + |
|
251 | + $this->expectException('\SwaggerGen\Exception', "Invalid integer default: ''"); |
|
252 | + $object->handleCommand('default', ''); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
257 | + */ |
|
258 | + public function testCommandDefaultInvalidValue() |
|
259 | + { |
|
260 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
261 | + |
|
262 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
263 | + |
|
264 | + $this->expectException('\SwaggerGen\Exception', "Invalid integer default: 'foo'"); |
|
265 | + $object->handleCommand('default', 'foo'); |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
270 | + */ |
|
271 | + public function testCommandDefaultPositive() |
|
272 | + { |
|
273 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
274 | + |
|
275 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
276 | + |
|
277 | + $object->handleCommand('default', '123'); |
|
278 | + |
|
279 | + $this->assertSame(array( |
|
280 | + 'type' => 'integer', |
|
281 | + 'format' => 'int32', |
|
282 | + 'default' => 123, |
|
283 | + ), $object->toArray()); |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
288 | + */ |
|
289 | + public function testCommandDefaultNegative() |
|
290 | + { |
|
291 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
292 | + |
|
293 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
294 | + |
|
295 | + $object->handleCommand('default', '-123'); |
|
296 | + |
|
297 | + $this->assertSame(array( |
|
298 | + 'type' => 'integer', |
|
299 | + 'format' => 'int32', |
|
300 | + 'default' => -123, |
|
301 | + ), $object->toArray()); |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
306 | + */ |
|
307 | + public function testCommandDefaultBeyondRange() |
|
308 | + { |
|
309 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer[-100,100]'); |
|
310 | + |
|
311 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
312 | + |
|
313 | + $this->expectException('\SwaggerGen\Exception', "Default integer beyond minimum: '-123'"); |
|
314 | + $object->handleCommand('default', '-123'); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
319 | + */ |
|
320 | + public function testCommandEnum() |
|
321 | + { |
|
322 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
323 | + |
|
324 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
325 | + |
|
326 | + $object->handleCommand('enum', '-1 2 123'); |
|
327 | + $object->handleCommand('enum', '-123 0'); |
|
328 | + |
|
329 | + $this->assertEquals(array( |
|
330 | + 'type' => 'integer', |
|
331 | + 'format' => 'int32', |
|
332 | + 'enum' => array( |
|
333 | + -1, |
|
334 | + 2, |
|
335 | + 123, |
|
336 | + -123, |
|
337 | + 0, |
|
338 | + ), |
|
339 | + ), $object->toArray()); |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * @covers \SwaggerGen\Swagger\Type\IntegerType->handleCommand |
|
344 | + */ |
|
345 | + public function testCommandStep() |
|
346 | + { |
|
347 | + $object = new SwaggerGen\Swagger\Type\IntegerType($this->parent, 'integer'); |
|
348 | + |
|
349 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\IntegerType', $object); |
|
350 | + |
|
351 | + $object->handleCommand('step', '3'); |
|
352 | + |
|
353 | + $this->assertEquals(array( |
|
354 | + 'type' => 'integer', |
|
355 | + 'format' => 'int32', |
|
356 | + 'multipleOf' => 3, |
|
357 | + ), $object->toArray()); |
|
358 | + } |
|
359 | 359 | |
360 | 360 | } |