@@ -11,15 +11,15 @@ |
||
| 11 | 11 | class Example |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @rest\endpoint /endpoint/{listid} |
|
| 16 | - * @rest\method GET Something |
|
| 17 | - * @rest\param listid |
|
| 18 | - * @rest\response 200 |
|
| 19 | - */ |
|
| 20 | - public function Dummy() |
|
| 21 | - { |
|
| 14 | + /** |
|
| 15 | + * @rest\endpoint /endpoint/{listid} |
|
| 16 | + * @rest\method GET Something |
|
| 17 | + * @rest\param listid |
|
| 18 | + * @rest\response 200 |
|
| 19 | + */ |
|
| 20 | + public function Dummy() |
|
| 21 | + { |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
@@ -11,17 +11,17 @@ |
||
| 11 | 11 | class Example |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @rest\endpoint /endpoint/{listid} |
|
| 16 | - * @rest\method GET Something |
|
| 17 | - * @rest\ifndef skip |
|
| 18 | - * @rest\param listid |
|
| 19 | - * @rest\endif |
|
| 20 | - * @rest\response 200 |
|
| 21 | - */ |
|
| 22 | - public function Dummy() |
|
| 23 | - { |
|
| 14 | + /** |
|
| 15 | + * @rest\endpoint /endpoint/{listid} |
|
| 16 | + * @rest\method GET Something |
|
| 17 | + * @rest\ifndef skip |
|
| 18 | + * @rest\param listid |
|
| 19 | + * @rest\endif |
|
| 20 | + * @rest\response 200 |
|
| 21 | + */ |
|
| 22 | + public function Dummy() |
|
| 23 | + { |
|
| 24 | 24 | |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | } |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | class Example |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - public function Dummy() |
|
| 17 | - { |
|
| 18 | - /** |
|
| 19 | - * @rest\endpoint /v1/users/{id} |
|
| 20 | - * @rest\method GET Return a JSON with all the user attributes |
|
| 21 | - * @rest\path Int id The ID of the User |
|
| 22 | - * @rest\response 200 User |
|
| 23 | - */ |
|
| 24 | - $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) { |
|
| 25 | - // ... |
|
| 26 | - }); |
|
| 27 | - } |
|
| 16 | + public function Dummy() |
|
| 17 | + { |
|
| 18 | + /** |
|
| 19 | + * @rest\endpoint /v1/users/{id} |
|
| 20 | + * @rest\method GET Return a JSON with all the user attributes |
|
| 21 | + * @rest\path Int id The ID of the User |
|
| 22 | + * @rest\response 200 User |
|
| 23 | + */ |
|
| 24 | + $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) { |
|
| 25 | + // ... |
|
| 26 | + }); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | * @rest\path Int id The ID of the User |
| 22 | 22 | * @rest\response 200 User |
| 23 | 23 | */ |
| 24 | - $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) { |
|
| 24 | + $app->get('/v1/users/{id:[0-9]+}', function($request, $response, $args) { |
|
| 25 | 25 | // ... |
| 26 | 26 | }); |
| 27 | 27 | } |
@@ -3,403 +3,403 @@ |
||
| 3 | 3 | class ResponseTest 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\Response::__construct |
|
| 20 | - */ |
|
| 21 | - public function testConstructor_200() |
|
| 22 | - { |
|
| 23 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 24 | - |
|
| 25 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 26 | - |
|
| 27 | - $this->assertSame(array( |
|
| 28 | - 'description' => 'OK', |
|
| 29 | - ), $object->toArray()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 34 | - */ |
|
| 35 | - public function testConstructor_404Type() |
|
| 36 | - { |
|
| 37 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 404); |
|
| 38 | - |
|
| 39 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 40 | - |
|
| 41 | - $this->assertSame(array( |
|
| 42 | - 'description' => 'Not Found', |
|
| 43 | - ), $object->toArray()); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructor_Type() |
|
| 50 | - { |
|
| 51 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'int'); |
|
| 52 | - |
|
| 53 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 54 | - |
|
| 55 | - $this->assertSame(array( |
|
| 56 | - 'description' => 'OK', |
|
| 57 | - 'schema' => array( |
|
| 58 | - 'type' => 'integer', |
|
| 59 | - 'format' => 'int32', |
|
| 60 | - ), |
|
| 61 | - ), $object->toArray()); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 66 | - */ |
|
| 67 | - public function testConstructor_Reference() |
|
| 68 | - { |
|
| 69 | - $this->parent->handleCommand('model', 'User'); |
|
| 70 | - |
|
| 71 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'User'); |
|
| 72 | - |
|
| 73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 74 | - |
|
| 75 | - $this->assertSame(array( |
|
| 76 | - 'description' => 'OK', |
|
| 77 | - 'schema' => array( |
|
| 78 | - '$ref' => '#/definitions/User', |
|
| 79 | - ), |
|
| 80 | - ), $object->toArray()); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 85 | - */ |
|
| 86 | - public function testConstructor_Description() |
|
| 87 | - { |
|
| 88 | - $object = new \SwaggerGen\Swagger\Response($this->parent, '200', null, 'Fine And Dandy'); |
|
| 89 | - |
|
| 90 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 91 | - |
|
| 92 | - $this->assertSame(array( |
|
| 93 | - 'description' => 'Fine And Dandy', |
|
| 94 | - ), $object->toArray()); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 99 | - */ |
|
| 100 | - public function testCommand_Header_NoType() |
|
| 101 | - { |
|
| 102 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 103 | - |
|
| 104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 105 | - |
|
| 106 | - $this->expectException('\SwaggerGen\Exception', "Missing type for header"); |
|
| 107 | - |
|
| 108 | - $object->handleCommand('header', ''); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 113 | - */ |
|
| 114 | - public function testCommand_Header_NoName() |
|
| 115 | - { |
|
| 116 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 117 | - |
|
| 118 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 119 | - |
|
| 120 | - $this->expectException('\SwaggerGen\Exception', "Missing name for header type 'int'"); |
|
| 121 | - |
|
| 122 | - $object->handleCommand('header', 'int'); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 127 | - */ |
|
| 128 | - public function testCommand_Header_InvalidType() |
|
| 129 | - { |
|
| 130 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 131 | - |
|
| 132 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 133 | - |
|
| 134 | - $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'foo'"); |
|
| 135 | - |
|
| 136 | - $object->handleCommand('header', 'foo bar'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 141 | - */ |
|
| 142 | - public function testCommand_Header() |
|
| 143 | - { |
|
| 144 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 145 | - |
|
| 146 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 147 | - |
|
| 148 | - $object->handleCommand('header', 'integer bar'); |
|
| 149 | - |
|
| 150 | - $this->assertSame(array( |
|
| 151 | - 'description' => 'OK', |
|
| 152 | - 'headers' => array( |
|
| 153 | - 'bar' => array( |
|
| 154 | - 'type' => 'integer', |
|
| 155 | - ), |
|
| 156 | - ), |
|
| 157 | - ), $object->toArray()); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 162 | - */ |
|
| 163 | - public function testCommand_Header_Description() |
|
| 164 | - { |
|
| 165 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 166 | - |
|
| 167 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 168 | - |
|
| 169 | - $object->handleCommand('header', 'integer bar Some text'); |
|
| 170 | - |
|
| 171 | - $this->assertSame(array( |
|
| 172 | - 'description' => 'OK', |
|
| 173 | - 'headers' => array( |
|
| 174 | - 'bar' => array( |
|
| 175 | - 'type' => 'integer', |
|
| 176 | - 'description' => 'Some text', |
|
| 177 | - ), |
|
| 178 | - ), |
|
| 179 | - ), $object->toArray()); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 184 | - */ |
|
| 185 | - public function testCommand_Header_Multiple() |
|
| 186 | - { |
|
| 187 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 188 | - |
|
| 189 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 190 | - |
|
| 191 | - $object->handleCommand('header', 'integer bar'); |
|
| 192 | - $object->handleCommand('header', 'string X-Whatever'); |
|
| 193 | - |
|
| 194 | - $this->assertSame(array( |
|
| 195 | - 'description' => 'OK', |
|
| 196 | - 'headers' => array( |
|
| 197 | - 'bar' => array( |
|
| 198 | - 'type' => 'integer', |
|
| 199 | - ), |
|
| 200 | - 'X-Whatever' => array( |
|
| 201 | - 'type' => 'string', |
|
| 202 | - ), |
|
| 203 | - ), |
|
| 204 | - ), $object->toArray()); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 209 | - */ |
|
| 210 | - public function testCommand_Example_NoName() |
|
| 211 | - { |
|
| 212 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 213 | - |
|
| 214 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 215 | - |
|
| 216 | - $this->expectException('\SwaggerGen\Exception', "Missing name for example"); |
|
| 217 | - |
|
| 218 | - $object->handleCommand('example', ''); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 223 | - */ |
|
| 224 | - public function testCommand_Example_NoData() |
|
| 225 | - { |
|
| 226 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 227 | - |
|
| 228 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 229 | - |
|
| 230 | - $this->expectException('\SwaggerGen\Exception', "Missing content for example `Foo`"); |
|
| 231 | - |
|
| 232 | - $object->handleCommand('example', 'Foo'); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 237 | - */ |
|
| 238 | - public function testCommand_Example_Text() |
|
| 239 | - { |
|
| 240 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 241 | - |
|
| 242 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 243 | - |
|
| 244 | - $object->handleCommand('example', 'Foo bar'); |
|
| 245 | - |
|
| 246 | - $this->assertSame(array( |
|
| 247 | - 'description' => 'OK', |
|
| 248 | - 'examples' => array( |
|
| 249 | - 'Foo' => 'bar', |
|
| 250 | - ), |
|
| 251 | - ), $object->toArray()); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 256 | - */ |
|
| 257 | - public function testCommand_Example_Number() |
|
| 258 | - { |
|
| 259 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 260 | - |
|
| 261 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 262 | - |
|
| 263 | - $object->handleCommand('example', 'Foo 123.45'); |
|
| 264 | - |
|
| 265 | - $this->assertSame(array( |
|
| 266 | - 'description' => 'OK', |
|
| 267 | - 'examples' => array( |
|
| 268 | - 'Foo' => 123.45, |
|
| 269 | - ), |
|
| 270 | - ), $object->toArray()); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 275 | - */ |
|
| 276 | - public function testCommand_Example_Json() |
|
| 277 | - { |
|
| 278 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 279 | - |
|
| 280 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 281 | - |
|
| 282 | - $object->handleCommand('example', 'Foo {"bar":"baz"}'); |
|
| 283 | - |
|
| 284 | - $this->assertSame(array( |
|
| 285 | - 'description' => 'OK', |
|
| 286 | - 'examples' => array( |
|
| 287 | - 'Foo' => array( |
|
| 288 | - 'bar' => 'baz', |
|
| 289 | - ), |
|
| 290 | - ), |
|
| 291 | - ), $object->toArray()); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 296 | - */ |
|
| 297 | - public function testCommand_Example_Json_Unquoted() |
|
| 298 | - { |
|
| 299 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 300 | - |
|
| 301 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 302 | - |
|
| 303 | - $object->handleCommand('example', 'Foo {bar:baz}'); |
|
| 304 | - |
|
| 305 | - $this->assertSame(array( |
|
| 306 | - 'description' => 'OK', |
|
| 307 | - 'examples' => array( |
|
| 308 | - 'Foo' => array( |
|
| 309 | - 'bar' => 'baz', |
|
| 310 | - ), |
|
| 311 | - ), |
|
| 312 | - ), $object->toArray()); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 317 | - */ |
|
| 318 | - public function testCommand_Example_Json_Whitespace() |
|
| 319 | - { |
|
| 320 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 321 | - |
|
| 322 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 323 | - |
|
| 324 | - $object->handleCommand('example', 'Foo { "bar" : "baz" } '); |
|
| 325 | - |
|
| 326 | - $this->assertSame(array( |
|
| 327 | - 'description' => 'OK', |
|
| 328 | - 'examples' => array( |
|
| 329 | - 'Foo' => array( |
|
| 330 | - 'bar' => 'baz', |
|
| 331 | - ), |
|
| 332 | - ), |
|
| 333 | - ), $object->toArray()); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 338 | - */ |
|
| 339 | - public function testCommand_Example_Json_Multiple() |
|
| 340 | - { |
|
| 341 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 342 | - |
|
| 343 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 344 | - |
|
| 345 | - $object->handleCommand('example', 'Foo "Bar" '); |
|
| 346 | - $object->handleCommand('example', 'Baz false'); |
|
| 347 | - |
|
| 348 | - $this->assertSame(array( |
|
| 349 | - 'description' => 'OK', |
|
| 350 | - 'examples' => array( |
|
| 351 | - 'Foo' => 'Bar', |
|
| 352 | - 'Baz' => false, |
|
| 353 | - ), |
|
| 354 | - ), $object->toArray()); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 359 | - */ |
|
| 360 | - public function testGetCode_Numeric() |
|
| 361 | - { |
|
| 362 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode(200)); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 367 | - */ |
|
| 368 | - public function testGetCode_CaseSensitive() |
|
| 369 | - { |
|
| 370 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('OK')); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 375 | - */ |
|
| 376 | - public function testGetCode_CaseInsensitive() |
|
| 377 | - { |
|
| 378 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('ok')); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 383 | - */ |
|
| 384 | - public function testGetCode_Space() |
|
| 385 | - { |
|
| 386 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('not Found')); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 391 | - */ |
|
| 392 | - public function testGetCode_Crap() |
|
| 393 | - { |
|
| 394 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode(' not___F-ou/nd ')); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 399 | - */ |
|
| 400 | - public function testGetCode_Smashed() |
|
| 401 | - { |
|
| 402 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('nOtfOund')); |
|
| 403 | - } |
|
| 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\Response::__construct |
|
| 20 | + */ |
|
| 21 | + public function testConstructor_200() |
|
| 22 | + { |
|
| 23 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 24 | + |
|
| 25 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 26 | + |
|
| 27 | + $this->assertSame(array( |
|
| 28 | + 'description' => 'OK', |
|
| 29 | + ), $object->toArray()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 34 | + */ |
|
| 35 | + public function testConstructor_404Type() |
|
| 36 | + { |
|
| 37 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 404); |
|
| 38 | + |
|
| 39 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 40 | + |
|
| 41 | + $this->assertSame(array( |
|
| 42 | + 'description' => 'Not Found', |
|
| 43 | + ), $object->toArray()); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructor_Type() |
|
| 50 | + { |
|
| 51 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'int'); |
|
| 52 | + |
|
| 53 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 54 | + |
|
| 55 | + $this->assertSame(array( |
|
| 56 | + 'description' => 'OK', |
|
| 57 | + 'schema' => array( |
|
| 58 | + 'type' => 'integer', |
|
| 59 | + 'format' => 'int32', |
|
| 60 | + ), |
|
| 61 | + ), $object->toArray()); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 66 | + */ |
|
| 67 | + public function testConstructor_Reference() |
|
| 68 | + { |
|
| 69 | + $this->parent->handleCommand('model', 'User'); |
|
| 70 | + |
|
| 71 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'User'); |
|
| 72 | + |
|
| 73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 74 | + |
|
| 75 | + $this->assertSame(array( |
|
| 76 | + 'description' => 'OK', |
|
| 77 | + 'schema' => array( |
|
| 78 | + '$ref' => '#/definitions/User', |
|
| 79 | + ), |
|
| 80 | + ), $object->toArray()); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 85 | + */ |
|
| 86 | + public function testConstructor_Description() |
|
| 87 | + { |
|
| 88 | + $object = new \SwaggerGen\Swagger\Response($this->parent, '200', null, 'Fine And Dandy'); |
|
| 89 | + |
|
| 90 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 91 | + |
|
| 92 | + $this->assertSame(array( |
|
| 93 | + 'description' => 'Fine And Dandy', |
|
| 94 | + ), $object->toArray()); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 99 | + */ |
|
| 100 | + public function testCommand_Header_NoType() |
|
| 101 | + { |
|
| 102 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 103 | + |
|
| 104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 105 | + |
|
| 106 | + $this->expectException('\SwaggerGen\Exception', "Missing type for header"); |
|
| 107 | + |
|
| 108 | + $object->handleCommand('header', ''); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 113 | + */ |
|
| 114 | + public function testCommand_Header_NoName() |
|
| 115 | + { |
|
| 116 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 117 | + |
|
| 118 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 119 | + |
|
| 120 | + $this->expectException('\SwaggerGen\Exception', "Missing name for header type 'int'"); |
|
| 121 | + |
|
| 122 | + $object->handleCommand('header', 'int'); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 127 | + */ |
|
| 128 | + public function testCommand_Header_InvalidType() |
|
| 129 | + { |
|
| 130 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 131 | + |
|
| 132 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 133 | + |
|
| 134 | + $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'foo'"); |
|
| 135 | + |
|
| 136 | + $object->handleCommand('header', 'foo bar'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 141 | + */ |
|
| 142 | + public function testCommand_Header() |
|
| 143 | + { |
|
| 144 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 145 | + |
|
| 146 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 147 | + |
|
| 148 | + $object->handleCommand('header', 'integer bar'); |
|
| 149 | + |
|
| 150 | + $this->assertSame(array( |
|
| 151 | + 'description' => 'OK', |
|
| 152 | + 'headers' => array( |
|
| 153 | + 'bar' => array( |
|
| 154 | + 'type' => 'integer', |
|
| 155 | + ), |
|
| 156 | + ), |
|
| 157 | + ), $object->toArray()); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 162 | + */ |
|
| 163 | + public function testCommand_Header_Description() |
|
| 164 | + { |
|
| 165 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 166 | + |
|
| 167 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 168 | + |
|
| 169 | + $object->handleCommand('header', 'integer bar Some text'); |
|
| 170 | + |
|
| 171 | + $this->assertSame(array( |
|
| 172 | + 'description' => 'OK', |
|
| 173 | + 'headers' => array( |
|
| 174 | + 'bar' => array( |
|
| 175 | + 'type' => 'integer', |
|
| 176 | + 'description' => 'Some text', |
|
| 177 | + ), |
|
| 178 | + ), |
|
| 179 | + ), $object->toArray()); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 184 | + */ |
|
| 185 | + public function testCommand_Header_Multiple() |
|
| 186 | + { |
|
| 187 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 188 | + |
|
| 189 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 190 | + |
|
| 191 | + $object->handleCommand('header', 'integer bar'); |
|
| 192 | + $object->handleCommand('header', 'string X-Whatever'); |
|
| 193 | + |
|
| 194 | + $this->assertSame(array( |
|
| 195 | + 'description' => 'OK', |
|
| 196 | + 'headers' => array( |
|
| 197 | + 'bar' => array( |
|
| 198 | + 'type' => 'integer', |
|
| 199 | + ), |
|
| 200 | + 'X-Whatever' => array( |
|
| 201 | + 'type' => 'string', |
|
| 202 | + ), |
|
| 203 | + ), |
|
| 204 | + ), $object->toArray()); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 209 | + */ |
|
| 210 | + public function testCommand_Example_NoName() |
|
| 211 | + { |
|
| 212 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 213 | + |
|
| 214 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 215 | + |
|
| 216 | + $this->expectException('\SwaggerGen\Exception', "Missing name for example"); |
|
| 217 | + |
|
| 218 | + $object->handleCommand('example', ''); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 223 | + */ |
|
| 224 | + public function testCommand_Example_NoData() |
|
| 225 | + { |
|
| 226 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 227 | + |
|
| 228 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 229 | + |
|
| 230 | + $this->expectException('\SwaggerGen\Exception', "Missing content for example `Foo`"); |
|
| 231 | + |
|
| 232 | + $object->handleCommand('example', 'Foo'); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 237 | + */ |
|
| 238 | + public function testCommand_Example_Text() |
|
| 239 | + { |
|
| 240 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 241 | + |
|
| 242 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 243 | + |
|
| 244 | + $object->handleCommand('example', 'Foo bar'); |
|
| 245 | + |
|
| 246 | + $this->assertSame(array( |
|
| 247 | + 'description' => 'OK', |
|
| 248 | + 'examples' => array( |
|
| 249 | + 'Foo' => 'bar', |
|
| 250 | + ), |
|
| 251 | + ), $object->toArray()); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 256 | + */ |
|
| 257 | + public function testCommand_Example_Number() |
|
| 258 | + { |
|
| 259 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 260 | + |
|
| 261 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 262 | + |
|
| 263 | + $object->handleCommand('example', 'Foo 123.45'); |
|
| 264 | + |
|
| 265 | + $this->assertSame(array( |
|
| 266 | + 'description' => 'OK', |
|
| 267 | + 'examples' => array( |
|
| 268 | + 'Foo' => 123.45, |
|
| 269 | + ), |
|
| 270 | + ), $object->toArray()); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 275 | + */ |
|
| 276 | + public function testCommand_Example_Json() |
|
| 277 | + { |
|
| 278 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 279 | + |
|
| 280 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 281 | + |
|
| 282 | + $object->handleCommand('example', 'Foo {"bar":"baz"}'); |
|
| 283 | + |
|
| 284 | + $this->assertSame(array( |
|
| 285 | + 'description' => 'OK', |
|
| 286 | + 'examples' => array( |
|
| 287 | + 'Foo' => array( |
|
| 288 | + 'bar' => 'baz', |
|
| 289 | + ), |
|
| 290 | + ), |
|
| 291 | + ), $object->toArray()); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 296 | + */ |
|
| 297 | + public function testCommand_Example_Json_Unquoted() |
|
| 298 | + { |
|
| 299 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 300 | + |
|
| 301 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 302 | + |
|
| 303 | + $object->handleCommand('example', 'Foo {bar:baz}'); |
|
| 304 | + |
|
| 305 | + $this->assertSame(array( |
|
| 306 | + 'description' => 'OK', |
|
| 307 | + 'examples' => array( |
|
| 308 | + 'Foo' => array( |
|
| 309 | + 'bar' => 'baz', |
|
| 310 | + ), |
|
| 311 | + ), |
|
| 312 | + ), $object->toArray()); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 317 | + */ |
|
| 318 | + public function testCommand_Example_Json_Whitespace() |
|
| 319 | + { |
|
| 320 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 321 | + |
|
| 322 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 323 | + |
|
| 324 | + $object->handleCommand('example', 'Foo { "bar" : "baz" } '); |
|
| 325 | + |
|
| 326 | + $this->assertSame(array( |
|
| 327 | + 'description' => 'OK', |
|
| 328 | + 'examples' => array( |
|
| 329 | + 'Foo' => array( |
|
| 330 | + 'bar' => 'baz', |
|
| 331 | + ), |
|
| 332 | + ), |
|
| 333 | + ), $object->toArray()); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 338 | + */ |
|
| 339 | + public function testCommand_Example_Json_Multiple() |
|
| 340 | + { |
|
| 341 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 342 | + |
|
| 343 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 344 | + |
|
| 345 | + $object->handleCommand('example', 'Foo "Bar" '); |
|
| 346 | + $object->handleCommand('example', 'Baz false'); |
|
| 347 | + |
|
| 348 | + $this->assertSame(array( |
|
| 349 | + 'description' => 'OK', |
|
| 350 | + 'examples' => array( |
|
| 351 | + 'Foo' => 'Bar', |
|
| 352 | + 'Baz' => false, |
|
| 353 | + ), |
|
| 354 | + ), $object->toArray()); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 359 | + */ |
|
| 360 | + public function testGetCode_Numeric() |
|
| 361 | + { |
|
| 362 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode(200)); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 367 | + */ |
|
| 368 | + public function testGetCode_CaseSensitive() |
|
| 369 | + { |
|
| 370 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('OK')); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 375 | + */ |
|
| 376 | + public function testGetCode_CaseInsensitive() |
|
| 377 | + { |
|
| 378 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('ok')); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 383 | + */ |
|
| 384 | + public function testGetCode_Space() |
|
| 385 | + { |
|
| 386 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('not Found')); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 391 | + */ |
|
| 392 | + public function testGetCode_Crap() |
|
| 393 | + { |
|
| 394 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode(' not___F-ou/nd ')); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 399 | + */ |
|
| 400 | + public function testGetCode_Smashed() |
|
| 401 | + { |
|
| 402 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('nOtfOund')); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | 405 | } |
@@ -3,99 +3,99 @@ |
||
| 3 | 3 | class HeaderTest 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\Header::__construct |
|
| 20 | - */ |
|
| 21 | - public function testConstructorType(): void |
|
| 22 | - { |
|
| 23 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 24 | - |
|
| 25 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 26 | - |
|
| 27 | - $this->assertSame(array( |
|
| 28 | - 'type' => 'integer', |
|
| 29 | - ), $object->toArray()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 34 | - */ |
|
| 35 | - public function testConstructorInvalidType() |
|
| 36 | - { |
|
| 37 | - $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'BadType'"); |
|
| 38 | - |
|
| 39 | - new \SwaggerGen\Swagger\Header($this->parent, 'BadType'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 44 | - */ |
|
| 45 | - public function testConstructorNoDescription() |
|
| 46 | - { |
|
| 47 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 48 | - |
|
| 49 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 50 | - |
|
| 51 | - $this->assertSame(array( |
|
| 52 | - 'type' => 'integer', |
|
| 53 | - ), $object->toArray()); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 58 | - */ |
|
| 59 | - public function testConstructorBlankDescription() |
|
| 60 | - { |
|
| 61 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', ''); |
|
| 62 | - |
|
| 63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 64 | - |
|
| 65 | - $this->assertSame(array( |
|
| 66 | - 'type' => 'integer', |
|
| 67 | - ), $object->toArray()); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 72 | - */ |
|
| 73 | - public function testConstructorFull() |
|
| 74 | - { |
|
| 75 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 76 | - |
|
| 77 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 78 | - |
|
| 79 | - $this->assertSame(array( |
|
| 80 | - 'type' => 'integer', |
|
| 81 | - 'description' => 'descriptive text', |
|
| 82 | - ), $object->toArray()); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @covers \SwaggerGen\Swagger\Header->handleCommand |
|
| 87 | - */ |
|
| 88 | - public function testCommandDescription() |
|
| 89 | - { |
|
| 90 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 91 | - |
|
| 92 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 93 | - |
|
| 94 | - $object->handleCommand('description', 'Some other lines'); |
|
| 95 | - |
|
| 96 | - $this->assertSame(array( |
|
| 97 | - 'type' => 'integer', |
|
| 98 | - 'description' => 'Some other lines', |
|
| 99 | - ), $object->toArray()); |
|
| 100 | - } |
|
| 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\Header::__construct |
|
| 20 | + */ |
|
| 21 | + public function testConstructorType(): void |
|
| 22 | + { |
|
| 23 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 24 | + |
|
| 25 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 26 | + |
|
| 27 | + $this->assertSame(array( |
|
| 28 | + 'type' => 'integer', |
|
| 29 | + ), $object->toArray()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 34 | + */ |
|
| 35 | + public function testConstructorInvalidType() |
|
| 36 | + { |
|
| 37 | + $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'BadType'"); |
|
| 38 | + |
|
| 39 | + new \SwaggerGen\Swagger\Header($this->parent, 'BadType'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 44 | + */ |
|
| 45 | + public function testConstructorNoDescription() |
|
| 46 | + { |
|
| 47 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 48 | + |
|
| 49 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 50 | + |
|
| 51 | + $this->assertSame(array( |
|
| 52 | + 'type' => 'integer', |
|
| 53 | + ), $object->toArray()); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 58 | + */ |
|
| 59 | + public function testConstructorBlankDescription() |
|
| 60 | + { |
|
| 61 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', ''); |
|
| 62 | + |
|
| 63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 64 | + |
|
| 65 | + $this->assertSame(array( |
|
| 66 | + 'type' => 'integer', |
|
| 67 | + ), $object->toArray()); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 72 | + */ |
|
| 73 | + public function testConstructorFull() |
|
| 74 | + { |
|
| 75 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 76 | + |
|
| 77 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 78 | + |
|
| 79 | + $this->assertSame(array( |
|
| 80 | + 'type' => 'integer', |
|
| 81 | + 'description' => 'descriptive text', |
|
| 82 | + ), $object->toArray()); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @covers \SwaggerGen\Swagger\Header->handleCommand |
|
| 87 | + */ |
|
| 88 | + public function testCommandDescription() |
|
| 89 | + { |
|
| 90 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 91 | + |
|
| 92 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 93 | + |
|
| 94 | + $object->handleCommand('description', 'Some other lines'); |
|
| 95 | + |
|
| 96 | + $this->assertSame(array( |
|
| 97 | + 'type' => 'integer', |
|
| 98 | + 'description' => 'Some other lines', |
|
| 99 | + ), $object->toArray()); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -3,81 +3,81 @@ |
||
| 3 | 3 | class ErrorTest 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\Error::__construct |
|
| 20 | - */ |
|
| 21 | - public function testConstructor_200(): void |
|
| 22 | - { |
|
| 23 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
| 24 | - |
|
| 25 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 26 | - |
|
| 27 | - $this->assertSame(array( |
|
| 28 | - 'description' => 'OK', |
|
| 29 | - ), $object->toArray()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @covers \SwaggerGen\Swagger\Error::__construct |
|
| 34 | - */ |
|
| 35 | - public function testConstructor_404(): void |
|
| 36 | - { |
|
| 37 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 404); |
|
| 38 | - |
|
| 39 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 40 | - |
|
| 41 | - $this->assertSame(array( |
|
| 42 | - 'description' => 'Not Found', |
|
| 43 | - ), $object->toArray()); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Error::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructor_Description(): void |
|
| 50 | - { |
|
| 51 | - $object = new \SwaggerGen\Swagger\Error($this->parent, '200', 'Fine And Dandy'); |
|
| 52 | - |
|
| 53 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 54 | - |
|
| 55 | - $this->assertSame(array( |
|
| 56 | - 'description' => 'Fine And Dandy', |
|
| 57 | - ), $object->toArray()); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Just checks that the `header` command is inherited. Actual tests for |
|
| 62 | - * this command are in `ResponseTest` |
|
| 63 | - * @covers \SwaggerGen\Swagger\Type\Error->handleCommand |
|
| 64 | - */ |
|
| 65 | - public function testHandleCommand_Header(): void |
|
| 66 | - { |
|
| 67 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
| 68 | - |
|
| 69 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 70 | - |
|
| 71 | - $object->handleCommand('header', 'integer bar'); |
|
| 72 | - |
|
| 73 | - $this->assertSame(array( |
|
| 74 | - 'description' => 'OK', |
|
| 75 | - 'headers' => array( |
|
| 76 | - 'bar' => array( |
|
| 77 | - 'type' => 'integer', |
|
| 78 | - ), |
|
| 79 | - ), |
|
| 80 | - ), $object->toArray()); |
|
| 81 | - } |
|
| 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\Error::__construct |
|
| 20 | + */ |
|
| 21 | + public function testConstructor_200(): void |
|
| 22 | + { |
|
| 23 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
| 24 | + |
|
| 25 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 26 | + |
|
| 27 | + $this->assertSame(array( |
|
| 28 | + 'description' => 'OK', |
|
| 29 | + ), $object->toArray()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @covers \SwaggerGen\Swagger\Error::__construct |
|
| 34 | + */ |
|
| 35 | + public function testConstructor_404(): void |
|
| 36 | + { |
|
| 37 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 404); |
|
| 38 | + |
|
| 39 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 40 | + |
|
| 41 | + $this->assertSame(array( |
|
| 42 | + 'description' => 'Not Found', |
|
| 43 | + ), $object->toArray()); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Error::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructor_Description(): void |
|
| 50 | + { |
|
| 51 | + $object = new \SwaggerGen\Swagger\Error($this->parent, '200', 'Fine And Dandy'); |
|
| 52 | + |
|
| 53 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 54 | + |
|
| 55 | + $this->assertSame(array( |
|
| 56 | + 'description' => 'Fine And Dandy', |
|
| 57 | + ), $object->toArray()); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Just checks that the `header` command is inherited. Actual tests for |
|
| 62 | + * this command are in `ResponseTest` |
|
| 63 | + * @covers \SwaggerGen\Swagger\Type\Error->handleCommand |
|
| 64 | + */ |
|
| 65 | + public function testHandleCommand_Header(): void |
|
| 66 | + { |
|
| 67 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
| 68 | + |
|
| 69 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
| 70 | + |
|
| 71 | + $object->handleCommand('header', 'integer bar'); |
|
| 72 | + |
|
| 73 | + $this->assertSame(array( |
|
| 74 | + 'description' => 'OK', |
|
| 75 | + 'headers' => array( |
|
| 76 | + 'bar' => array( |
|
| 77 | + 'type' => 'integer', |
|
| 78 | + ), |
|
| 79 | + ), |
|
| 80 | + ), $object->toArray()); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
@@ -3,232 +3,232 @@ |
||
| 3 | 3 | class PathTest extends SwaggerGen_TestCase |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - protected $parent; |
|
| 7 | - |
|
| 8 | - protected function setUp(): void |
|
| 9 | - { |
|
| 10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - protected function assertPreConditions(): void |
|
| 14 | - { |
|
| 15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 20 | - */ |
|
| 21 | - public function testConstructor_Empty() |
|
| 22 | - { |
|
| 23 | - $object = new \SwaggerGen\Swagger\Path($this->parent); |
|
| 24 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 25 | - |
|
| 26 | - $this->assertSame(array(), $object->toArray()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 31 | - */ |
|
| 32 | - public function testConstructor_Tag() |
|
| 33 | - { |
|
| 34 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 35 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 36 | - |
|
| 37 | - $this->assertSame(array(), $object->toArray()); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 42 | - */ |
|
| 43 | - public function testHandleCommand_Method_Empty() |
|
| 44 | - { |
|
| 45 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 46 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 47 | - |
|
| 48 | - $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''"); |
|
| 49 | - $return = $object->handleCommand('method'); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 54 | - */ |
|
| 55 | - public function testHandleCommand_Method_Unknown() |
|
| 56 | - { |
|
| 57 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 58 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 59 | - |
|
| 60 | - $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'"); |
|
| 61 | - $return = $object->handleCommand('method', 'foo'); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 66 | - */ |
|
| 67 | - public function testHandleCommand_Method_Get() |
|
| 68 | - { |
|
| 69 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 70 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 71 | - |
|
| 72 | - $operation = $object->handleCommand('method', 'get'); |
|
| 73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 74 | - $operation->handleCommand('response', 200); |
|
| 75 | - |
|
| 76 | - $this->assertSame(array( |
|
| 77 | - 'get' => array( |
|
| 78 | - 'tags' => array( |
|
| 79 | - 'Tag', |
|
| 80 | - ), |
|
| 81 | - 'responses' => array( |
|
| 82 | - 200 => array( |
|
| 83 | - 'description' => 'OK', |
|
| 84 | - ), |
|
| 85 | - ), |
|
| 86 | - ), |
|
| 87 | - ), $object->toArray()); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 92 | - */ |
|
| 93 | - public function testHandleCommand_Method_Description() |
|
| 94 | - { |
|
| 95 | - $this->markTestIncomplete('This test has not been implemented yet.'); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 100 | - */ |
|
| 101 | - public function testHandleCommand_Operation_Get() |
|
| 102 | - { |
|
| 103 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 105 | - |
|
| 106 | - $operation = $object->handleCommand('operation', 'get'); |
|
| 107 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 108 | - $operation->handleCommand('response', 200); |
|
| 109 | - |
|
| 110 | - $this->assertSame(array( |
|
| 111 | - 'get' => array( |
|
| 112 | - 'tags' => array( |
|
| 113 | - 'Tag', |
|
| 114 | - ), |
|
| 115 | - 'responses' => array( |
|
| 116 | - 200 => array( |
|
| 117 | - 'description' => 'OK', |
|
| 118 | - ), |
|
| 119 | - ), |
|
| 120 | - ), |
|
| 121 | - ), $object->toArray()); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 126 | - */ |
|
| 127 | - public function testHandleCommand_MethodOrdering() |
|
| 128 | - { |
|
| 129 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 130 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 131 | - |
|
| 132 | - $operation = $object->handleCommand('method', 'post'); |
|
| 133 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 134 | - $operation->handleCommand('response', 200); |
|
| 135 | - |
|
| 136 | - $operation = $object->handleCommand('method', 'delete'); |
|
| 137 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 138 | - $operation->handleCommand('response', 200); |
|
| 139 | - |
|
| 140 | - $operation = $object->handleCommand('method', 'patch'); |
|
| 141 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 142 | - $operation->handleCommand('response', 200); |
|
| 143 | - |
|
| 144 | - $operation = $object->handleCommand('method', 'put'); |
|
| 145 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 146 | - $operation->handleCommand('response', 200); |
|
| 147 | - |
|
| 148 | - $operation = $object->handleCommand('method', 'head'); |
|
| 149 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 150 | - $operation->handleCommand('response', 200); |
|
| 151 | - |
|
| 152 | - $operation = $object->handleCommand('method', 'get'); |
|
| 153 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 154 | - $operation->handleCommand('response', 200); |
|
| 155 | - |
|
| 156 | - $operation = $object->handleCommand('method', 'options'); |
|
| 157 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 158 | - $operation->handleCommand('response', 200); |
|
| 159 | - |
|
| 160 | - $this->assertSame(array( |
|
| 161 | - 'get' => array( |
|
| 162 | - 'tags' => array( |
|
| 163 | - 'Tag', |
|
| 164 | - ), |
|
| 165 | - 'responses' => array( |
|
| 166 | - 200 => array( |
|
| 167 | - 'description' => 'OK', |
|
| 168 | - ), |
|
| 169 | - ), |
|
| 170 | - ), |
|
| 171 | - 'put' => array( |
|
| 172 | - 'tags' => array( |
|
| 173 | - 'Tag', |
|
| 174 | - ), |
|
| 175 | - 'responses' => array( |
|
| 176 | - 200 => array( |
|
| 177 | - 'description' => 'OK', |
|
| 178 | - ), |
|
| 179 | - ), |
|
| 180 | - ), |
|
| 181 | - 'post' => array( |
|
| 182 | - 'tags' => array( |
|
| 183 | - 'Tag', |
|
| 184 | - ), |
|
| 185 | - 'responses' => array( |
|
| 186 | - 200 => array( |
|
| 187 | - 'description' => 'OK', |
|
| 188 | - ), |
|
| 189 | - ), |
|
| 190 | - ), |
|
| 191 | - 'delete' => array( |
|
| 192 | - 'tags' => array( |
|
| 193 | - 'Tag', |
|
| 194 | - ), |
|
| 195 | - 'responses' => array( |
|
| 196 | - 200 => array( |
|
| 197 | - 'description' => 'OK', |
|
| 198 | - ), |
|
| 199 | - ), |
|
| 200 | - ), |
|
| 201 | - 'options' => array( |
|
| 202 | - 'tags' => array( |
|
| 203 | - 'Tag', |
|
| 204 | - ), |
|
| 205 | - 'responses' => array( |
|
| 206 | - 200 => array( |
|
| 207 | - 'description' => 'OK', |
|
| 208 | - ), |
|
| 209 | - ), |
|
| 210 | - ), |
|
| 211 | - 'head' => array( |
|
| 212 | - 'tags' => array( |
|
| 213 | - 'Tag', |
|
| 214 | - ), |
|
| 215 | - 'responses' => array( |
|
| 216 | - 200 => array( |
|
| 217 | - 'description' => 'OK', |
|
| 218 | - ), |
|
| 219 | - ), |
|
| 220 | - ), |
|
| 221 | - 'patch' => array( |
|
| 222 | - 'tags' => array( |
|
| 223 | - 'Tag', |
|
| 224 | - ), |
|
| 225 | - 'responses' => array( |
|
| 226 | - 200 => array( |
|
| 227 | - 'description' => 'OK', |
|
| 228 | - ), |
|
| 229 | - ), |
|
| 230 | - ), |
|
| 231 | - ), $object->toArray()); |
|
| 232 | - } |
|
| 6 | + protected $parent; |
|
| 7 | + |
|
| 8 | + protected function setUp(): void |
|
| 9 | + { |
|
| 10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + protected function assertPreConditions(): void |
|
| 14 | + { |
|
| 15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 20 | + */ |
|
| 21 | + public function testConstructor_Empty() |
|
| 22 | + { |
|
| 23 | + $object = new \SwaggerGen\Swagger\Path($this->parent); |
|
| 24 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 25 | + |
|
| 26 | + $this->assertSame(array(), $object->toArray()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 31 | + */ |
|
| 32 | + public function testConstructor_Tag() |
|
| 33 | + { |
|
| 34 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 35 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 36 | + |
|
| 37 | + $this->assertSame(array(), $object->toArray()); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 42 | + */ |
|
| 43 | + public function testHandleCommand_Method_Empty() |
|
| 44 | + { |
|
| 45 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 46 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 47 | + |
|
| 48 | + $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''"); |
|
| 49 | + $return = $object->handleCommand('method'); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 54 | + */ |
|
| 55 | + public function testHandleCommand_Method_Unknown() |
|
| 56 | + { |
|
| 57 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 58 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 59 | + |
|
| 60 | + $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'"); |
|
| 61 | + $return = $object->handleCommand('method', 'foo'); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 66 | + */ |
|
| 67 | + public function testHandleCommand_Method_Get() |
|
| 68 | + { |
|
| 69 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 70 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 71 | + |
|
| 72 | + $operation = $object->handleCommand('method', 'get'); |
|
| 73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 74 | + $operation->handleCommand('response', 200); |
|
| 75 | + |
|
| 76 | + $this->assertSame(array( |
|
| 77 | + 'get' => array( |
|
| 78 | + 'tags' => array( |
|
| 79 | + 'Tag', |
|
| 80 | + ), |
|
| 81 | + 'responses' => array( |
|
| 82 | + 200 => array( |
|
| 83 | + 'description' => 'OK', |
|
| 84 | + ), |
|
| 85 | + ), |
|
| 86 | + ), |
|
| 87 | + ), $object->toArray()); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 92 | + */ |
|
| 93 | + public function testHandleCommand_Method_Description() |
|
| 94 | + { |
|
| 95 | + $this->markTestIncomplete('This test has not been implemented yet.'); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 100 | + */ |
|
| 101 | + public function testHandleCommand_Operation_Get() |
|
| 102 | + { |
|
| 103 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 105 | + |
|
| 106 | + $operation = $object->handleCommand('operation', 'get'); |
|
| 107 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 108 | + $operation->handleCommand('response', 200); |
|
| 109 | + |
|
| 110 | + $this->assertSame(array( |
|
| 111 | + 'get' => array( |
|
| 112 | + 'tags' => array( |
|
| 113 | + 'Tag', |
|
| 114 | + ), |
|
| 115 | + 'responses' => array( |
|
| 116 | + 200 => array( |
|
| 117 | + 'description' => 'OK', |
|
| 118 | + ), |
|
| 119 | + ), |
|
| 120 | + ), |
|
| 121 | + ), $object->toArray()); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 126 | + */ |
|
| 127 | + public function testHandleCommand_MethodOrdering() |
|
| 128 | + { |
|
| 129 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 130 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 131 | + |
|
| 132 | + $operation = $object->handleCommand('method', 'post'); |
|
| 133 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 134 | + $operation->handleCommand('response', 200); |
|
| 135 | + |
|
| 136 | + $operation = $object->handleCommand('method', 'delete'); |
|
| 137 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 138 | + $operation->handleCommand('response', 200); |
|
| 139 | + |
|
| 140 | + $operation = $object->handleCommand('method', 'patch'); |
|
| 141 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 142 | + $operation->handleCommand('response', 200); |
|
| 143 | + |
|
| 144 | + $operation = $object->handleCommand('method', 'put'); |
|
| 145 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 146 | + $operation->handleCommand('response', 200); |
|
| 147 | + |
|
| 148 | + $operation = $object->handleCommand('method', 'head'); |
|
| 149 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 150 | + $operation->handleCommand('response', 200); |
|
| 151 | + |
|
| 152 | + $operation = $object->handleCommand('method', 'get'); |
|
| 153 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 154 | + $operation->handleCommand('response', 200); |
|
| 155 | + |
|
| 156 | + $operation = $object->handleCommand('method', 'options'); |
|
| 157 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 158 | + $operation->handleCommand('response', 200); |
|
| 159 | + |
|
| 160 | + $this->assertSame(array( |
|
| 161 | + 'get' => array( |
|
| 162 | + 'tags' => array( |
|
| 163 | + 'Tag', |
|
| 164 | + ), |
|
| 165 | + 'responses' => array( |
|
| 166 | + 200 => array( |
|
| 167 | + 'description' => 'OK', |
|
| 168 | + ), |
|
| 169 | + ), |
|
| 170 | + ), |
|
| 171 | + 'put' => array( |
|
| 172 | + 'tags' => array( |
|
| 173 | + 'Tag', |
|
| 174 | + ), |
|
| 175 | + 'responses' => array( |
|
| 176 | + 200 => array( |
|
| 177 | + 'description' => 'OK', |
|
| 178 | + ), |
|
| 179 | + ), |
|
| 180 | + ), |
|
| 181 | + 'post' => array( |
|
| 182 | + 'tags' => array( |
|
| 183 | + 'Tag', |
|
| 184 | + ), |
|
| 185 | + 'responses' => array( |
|
| 186 | + 200 => array( |
|
| 187 | + 'description' => 'OK', |
|
| 188 | + ), |
|
| 189 | + ), |
|
| 190 | + ), |
|
| 191 | + 'delete' => array( |
|
| 192 | + 'tags' => array( |
|
| 193 | + 'Tag', |
|
| 194 | + ), |
|
| 195 | + 'responses' => array( |
|
| 196 | + 200 => array( |
|
| 197 | + 'description' => 'OK', |
|
| 198 | + ), |
|
| 199 | + ), |
|
| 200 | + ), |
|
| 201 | + 'options' => array( |
|
| 202 | + 'tags' => array( |
|
| 203 | + 'Tag', |
|
| 204 | + ), |
|
| 205 | + 'responses' => array( |
|
| 206 | + 200 => array( |
|
| 207 | + 'description' => 'OK', |
|
| 208 | + ), |
|
| 209 | + ), |
|
| 210 | + ), |
|
| 211 | + 'head' => array( |
|
| 212 | + 'tags' => array( |
|
| 213 | + 'Tag', |
|
| 214 | + ), |
|
| 215 | + 'responses' => array( |
|
| 216 | + 200 => array( |
|
| 217 | + 'description' => 'OK', |
|
| 218 | + ), |
|
| 219 | + ), |
|
| 220 | + ), |
|
| 221 | + 'patch' => array( |
|
| 222 | + 'tags' => array( |
|
| 223 | + 'Tag', |
|
| 224 | + ), |
|
| 225 | + 'responses' => array( |
|
| 226 | + 200 => array( |
|
| 227 | + 'description' => 'OK', |
|
| 228 | + ), |
|
| 229 | + ), |
|
| 230 | + ), |
|
| 231 | + ), $object->toArray()); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | } |
@@ -3,138 +3,138 @@ |
||
| 3 | 3 | class SchemaTest extends SwaggerGen_TestCase |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - protected $parent; |
|
| 7 | - |
|
| 8 | - protected function setUp(): void |
|
| 9 | - { |
|
| 10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - protected function assertPreConditions(): void |
|
| 14 | - { |
|
| 15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 20 | - */ |
|
| 21 | - public function testConstructorEmpty() |
|
| 22 | - { |
|
| 23 | - $object = new \SwaggerGen\Swagger\Schema($this->parent); |
|
| 24 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 25 | - |
|
| 26 | - $this->assertSame(array( |
|
| 27 | - 'type' => 'object', |
|
| 28 | - ), $object->toArray()); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 33 | - */ |
|
| 34 | - public function testConstructorType() |
|
| 35 | - { |
|
| 36 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 37 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 38 | - |
|
| 39 | - $this->assertSame(array( |
|
| 40 | - 'type' => 'integer', |
|
| 41 | - 'format' => 'int32', |
|
| 42 | - ), $object->toArray()); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 47 | - */ |
|
| 48 | - public function testConstructorReference() |
|
| 49 | - { |
|
| 50 | - $this->parent->handleCommand('model', 'User'); |
|
| 51 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'User'); |
|
| 52 | - |
|
| 53 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 54 | - |
|
| 55 | - $this->assertSame(array( |
|
| 56 | - '$ref' => '#/definitions/User', |
|
| 57 | - ), $object->toArray()); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 62 | - */ |
|
| 63 | - public function testConstructorEmptyDescription() |
|
| 64 | - { |
|
| 65 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', ''); |
|
| 66 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 67 | - |
|
| 68 | - $this->assertSame(array( |
|
| 69 | - 'type' => 'integer', |
|
| 70 | - 'format' => 'int32', |
|
| 71 | - ), $object->toArray()); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 76 | - */ |
|
| 77 | - public function testConstructorDescription() |
|
| 78 | - { |
|
| 79 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', 'Some more words'); |
|
| 80 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 81 | - |
|
| 82 | - $this->assertSame(array( |
|
| 83 | - 'type' => 'integer', |
|
| 84 | - 'format' => 'int32', |
|
| 85 | - 'description' => 'Some more words', |
|
| 86 | - ), $object->toArray()); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 91 | - */ |
|
| 92 | - public function testCommandPassing() |
|
| 93 | - { |
|
| 94 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 95 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 96 | - |
|
| 97 | - $object->handleCommand('default', '123'); |
|
| 98 | - |
|
| 99 | - $this->assertSame(array( |
|
| 100 | - 'type' => 'integer', |
|
| 101 | - 'format' => 'int32', |
|
| 102 | - 'default' => 123, |
|
| 103 | - ), $object->toArray()); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 108 | - */ |
|
| 109 | - public function testCommand_Description() |
|
| 110 | - { |
|
| 111 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 112 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 113 | - |
|
| 114 | - $object->handleCommand('description', 'Some words'); |
|
| 115 | - |
|
| 116 | - $this->assertSame(array( |
|
| 117 | - 'type' => 'integer', |
|
| 118 | - 'format' => 'int32', |
|
| 119 | - 'description' => 'Some words', |
|
| 120 | - ), $object->toArray()); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 125 | - */ |
|
| 126 | - public function testCommand_Title() |
|
| 127 | - { |
|
| 128 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 129 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 130 | - |
|
| 131 | - $object->handleCommand('title', 'Title words'); |
|
| 132 | - |
|
| 133 | - $this->assertSame(array( |
|
| 134 | - 'type' => 'integer', |
|
| 135 | - 'format' => 'int32', |
|
| 136 | - 'title' => 'Title words', |
|
| 137 | - ), $object->toArray()); |
|
| 138 | - } |
|
| 6 | + protected $parent; |
|
| 7 | + |
|
| 8 | + protected function setUp(): void |
|
| 9 | + { |
|
| 10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + protected function assertPreConditions(): void |
|
| 14 | + { |
|
| 15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 20 | + */ |
|
| 21 | + public function testConstructorEmpty() |
|
| 22 | + { |
|
| 23 | + $object = new \SwaggerGen\Swagger\Schema($this->parent); |
|
| 24 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 25 | + |
|
| 26 | + $this->assertSame(array( |
|
| 27 | + 'type' => 'object', |
|
| 28 | + ), $object->toArray()); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 33 | + */ |
|
| 34 | + public function testConstructorType() |
|
| 35 | + { |
|
| 36 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 37 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 38 | + |
|
| 39 | + $this->assertSame(array( |
|
| 40 | + 'type' => 'integer', |
|
| 41 | + 'format' => 'int32', |
|
| 42 | + ), $object->toArray()); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 47 | + */ |
|
| 48 | + public function testConstructorReference() |
|
| 49 | + { |
|
| 50 | + $this->parent->handleCommand('model', 'User'); |
|
| 51 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'User'); |
|
| 52 | + |
|
| 53 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 54 | + |
|
| 55 | + $this->assertSame(array( |
|
| 56 | + '$ref' => '#/definitions/User', |
|
| 57 | + ), $object->toArray()); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 62 | + */ |
|
| 63 | + public function testConstructorEmptyDescription() |
|
| 64 | + { |
|
| 65 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', ''); |
|
| 66 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 67 | + |
|
| 68 | + $this->assertSame(array( |
|
| 69 | + 'type' => 'integer', |
|
| 70 | + 'format' => 'int32', |
|
| 71 | + ), $object->toArray()); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 76 | + */ |
|
| 77 | + public function testConstructorDescription() |
|
| 78 | + { |
|
| 79 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', 'Some more words'); |
|
| 80 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 81 | + |
|
| 82 | + $this->assertSame(array( |
|
| 83 | + 'type' => 'integer', |
|
| 84 | + 'format' => 'int32', |
|
| 85 | + 'description' => 'Some more words', |
|
| 86 | + ), $object->toArray()); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 91 | + */ |
|
| 92 | + public function testCommandPassing() |
|
| 93 | + { |
|
| 94 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 95 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 96 | + |
|
| 97 | + $object->handleCommand('default', '123'); |
|
| 98 | + |
|
| 99 | + $this->assertSame(array( |
|
| 100 | + 'type' => 'integer', |
|
| 101 | + 'format' => 'int32', |
|
| 102 | + 'default' => 123, |
|
| 103 | + ), $object->toArray()); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 108 | + */ |
|
| 109 | + public function testCommand_Description() |
|
| 110 | + { |
|
| 111 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 112 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 113 | + |
|
| 114 | + $object->handleCommand('description', 'Some words'); |
|
| 115 | + |
|
| 116 | + $this->assertSame(array( |
|
| 117 | + 'type' => 'integer', |
|
| 118 | + 'format' => 'int32', |
|
| 119 | + 'description' => 'Some words', |
|
| 120 | + ), $object->toArray()); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 125 | + */ |
|
| 126 | + public function testCommand_Title() |
|
| 127 | + { |
|
| 128 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 129 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 130 | + |
|
| 131 | + $object->handleCommand('title', 'Title words'); |
|
| 132 | + |
|
| 133 | + $this->assertSame(array( |
|
| 134 | + 'type' => 'integer', |
|
| 135 | + 'format' => 'int32', |
|
| 136 | + 'title' => 'Title words', |
|
| 137 | + ), $object->toArray()); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | } |
@@ -3,108 +3,108 @@ |
||
| 3 | 3 | class TagTest extends SwaggerGen_TestCase |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - protected $parent; |
|
| 7 | - |
|
| 8 | - protected function setUp(): void |
|
| 9 | - { |
|
| 10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - protected function assertPreConditions(): void |
|
| 14 | - { |
|
| 15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 20 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 21 | - */ |
|
| 22 | - public function testConstructor2() |
|
| 23 | - { |
|
| 24 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 25 | - |
|
| 26 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 27 | - |
|
| 28 | - $this->assertSame(array( |
|
| 29 | - 'name' => 'Name', |
|
| 30 | - ), $object->toArray()); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 35 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 36 | - */ |
|
| 37 | - public function testConstructor_Description_Empty() |
|
| 38 | - { |
|
| 39 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', ''); |
|
| 40 | - |
|
| 41 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 42 | - |
|
| 43 | - $this->assertSame(array( |
|
| 44 | - 'name' => 'Name', |
|
| 45 | - ), $object->toArray()); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 50 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 51 | - */ |
|
| 52 | - public function testConstructor3() |
|
| 53 | - { |
|
| 54 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 55 | - |
|
| 56 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 57 | - |
|
| 58 | - $this->assertSame(array( |
|
| 59 | - 'name' => 'Name', |
|
| 60 | - 'description' => 'Description', |
|
| 61 | - ), $object->toArray()); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @covers \SwaggerGen\Swagger\Tag::getName |
|
| 66 | - */ |
|
| 67 | - public function testGetName() |
|
| 68 | - { |
|
| 69 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 70 | - |
|
| 71 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 72 | - |
|
| 73 | - $this->assertSame('Name', $object->getName()); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 78 | - */ |
|
| 79 | - public function testCommandDescription() |
|
| 80 | - { |
|
| 81 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 82 | - |
|
| 83 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 84 | - |
|
| 85 | - $object->handleCommand('description', 'Command Description'); |
|
| 86 | - |
|
| 87 | - $this->assertSame(array( |
|
| 88 | - 'name' => 'Name', |
|
| 89 | - 'description' => 'Command Description', |
|
| 90 | - ), $object->toArray()); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 95 | - */ |
|
| 96 | - public function testCommandDescriptionOverwrite() |
|
| 97 | - { |
|
| 98 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 99 | - |
|
| 100 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 101 | - |
|
| 102 | - $object->handleCommand('description', 'Command Description'); |
|
| 103 | - |
|
| 104 | - $this->assertSame(array( |
|
| 105 | - 'name' => 'Name', |
|
| 106 | - 'description' => 'Command Description', |
|
| 107 | - ), $object->toArray()); |
|
| 108 | - } |
|
| 6 | + protected $parent; |
|
| 7 | + |
|
| 8 | + protected function setUp(): void |
|
| 9 | + { |
|
| 10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + protected function assertPreConditions(): void |
|
| 14 | + { |
|
| 15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 20 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 21 | + */ |
|
| 22 | + public function testConstructor2() |
|
| 23 | + { |
|
| 24 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 25 | + |
|
| 26 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 27 | + |
|
| 28 | + $this->assertSame(array( |
|
| 29 | + 'name' => 'Name', |
|
| 30 | + ), $object->toArray()); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 35 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 36 | + */ |
|
| 37 | + public function testConstructor_Description_Empty() |
|
| 38 | + { |
|
| 39 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', ''); |
|
| 40 | + |
|
| 41 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 42 | + |
|
| 43 | + $this->assertSame(array( |
|
| 44 | + 'name' => 'Name', |
|
| 45 | + ), $object->toArray()); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 50 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 51 | + */ |
|
| 52 | + public function testConstructor3() |
|
| 53 | + { |
|
| 54 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 55 | + |
|
| 56 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 57 | + |
|
| 58 | + $this->assertSame(array( |
|
| 59 | + 'name' => 'Name', |
|
| 60 | + 'description' => 'Description', |
|
| 61 | + ), $object->toArray()); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @covers \SwaggerGen\Swagger\Tag::getName |
|
| 66 | + */ |
|
| 67 | + public function testGetName() |
|
| 68 | + { |
|
| 69 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 70 | + |
|
| 71 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 72 | + |
|
| 73 | + $this->assertSame('Name', $object->getName()); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 78 | + */ |
|
| 79 | + public function testCommandDescription() |
|
| 80 | + { |
|
| 81 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 82 | + |
|
| 83 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 84 | + |
|
| 85 | + $object->handleCommand('description', 'Command Description'); |
|
| 86 | + |
|
| 87 | + $this->assertSame(array( |
|
| 88 | + 'name' => 'Name', |
|
| 89 | + 'description' => 'Command Description', |
|
| 90 | + ), $object->toArray()); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 95 | + */ |
|
| 96 | + public function testCommandDescriptionOverwrite() |
|
| 97 | + { |
|
| 98 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 99 | + |
|
| 100 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 101 | + |
|
| 102 | + $object->handleCommand('description', 'Command Description'); |
|
| 103 | + |
|
| 104 | + $this->assertSame(array( |
|
| 105 | + 'name' => 'Name', |
|
| 106 | + 'description' => 'Command Description', |
|
| 107 | + ), $object->toArray()); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | } |