@@ -6,138 +6,138 @@ |
||
| 6 | 6 | class SchemaTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructorEmpty() |
|
| 15 | - { |
|
| 16 | - $object = new \SwaggerGen\Swagger\Schema($this->parent); |
|
| 17 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 18 | - |
|
| 19 | - $this->assertSame(array( |
|
| 20 | - 'type' => 'object', |
|
| 21 | - ), $object->toArray()); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 26 | - */ |
|
| 27 | - public function testConstructorType() |
|
| 28 | - { |
|
| 29 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 30 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 31 | - |
|
| 32 | - $this->assertSame(array( |
|
| 33 | - 'type' => 'integer', |
|
| 34 | - 'format' => 'int32', |
|
| 35 | - ), $object->toArray()); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 40 | - */ |
|
| 41 | - public function testConstructorReference() |
|
| 42 | - { |
|
| 43 | - $this->parent->handleCommand('model', 'User'); |
|
| 44 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'User'); |
|
| 45 | - |
|
| 46 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 47 | - |
|
| 48 | - $this->assertSame(array( |
|
| 49 | - '$ref' => '#/definitions/User', |
|
| 50 | - ), $object->toArray()); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 55 | - */ |
|
| 56 | - public function testConstructorEmptyDescription() |
|
| 57 | - { |
|
| 58 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', ''); |
|
| 59 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 60 | - |
|
| 61 | - $this->assertSame(array( |
|
| 62 | - 'type' => 'integer', |
|
| 63 | - 'format' => 'int32', |
|
| 64 | - ), $object->toArray()); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 69 | - */ |
|
| 70 | - public function testConstructorDescription() |
|
| 71 | - { |
|
| 72 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', 'Some more words'); |
|
| 73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 74 | - |
|
| 75 | - $this->assertSame(array( |
|
| 76 | - 'type' => 'integer', |
|
| 77 | - 'format' => 'int32', |
|
| 78 | - 'description' => 'Some more words', |
|
| 79 | - ), $object->toArray()); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 84 | - */ |
|
| 85 | - public function testCommandPassing() |
|
| 86 | - { |
|
| 87 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 88 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 89 | - |
|
| 90 | - $object->handleCommand('default', '123'); |
|
| 91 | - |
|
| 92 | - $this->assertSame(array( |
|
| 93 | - 'type' => 'integer', |
|
| 94 | - 'format' => 'int32', |
|
| 95 | - 'default' => 123, |
|
| 96 | - ), $object->toArray()); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 101 | - */ |
|
| 102 | - public function testCommand_Description() |
|
| 103 | - { |
|
| 104 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 105 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 106 | - |
|
| 107 | - $object->handleCommand('description', 'Some words'); |
|
| 108 | - |
|
| 109 | - $this->assertSame(array( |
|
| 110 | - 'type' => 'integer', |
|
| 111 | - 'format' => 'int32', |
|
| 112 | - 'description' => 'Some words', |
|
| 113 | - ), $object->toArray()); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 118 | - */ |
|
| 119 | - public function testCommand_Title() |
|
| 120 | - { |
|
| 121 | - $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 122 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 123 | - |
|
| 124 | - $object->handleCommand('title', 'Title words'); |
|
| 125 | - |
|
| 126 | - $this->assertSame(array( |
|
| 127 | - 'type' => 'integer', |
|
| 128 | - 'format' => 'int32', |
|
| 129 | - 'title' => 'Title words', |
|
| 130 | - ), $object->toArray()); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - protected function setUp(): void |
|
| 134 | - { |
|
| 135 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - protected function assertPreConditions(): void |
|
| 139 | - { |
|
| 140 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 141 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructorEmpty() |
|
| 15 | + { |
|
| 16 | + $object = new \SwaggerGen\Swagger\Schema($this->parent); |
|
| 17 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 18 | + |
|
| 19 | + $this->assertSame(array( |
|
| 20 | + 'type' => 'object', |
|
| 21 | + ), $object->toArray()); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 26 | + */ |
|
| 27 | + public function testConstructorType() |
|
| 28 | + { |
|
| 29 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 30 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 31 | + |
|
| 32 | + $this->assertSame(array( |
|
| 33 | + 'type' => 'integer', |
|
| 34 | + 'format' => 'int32', |
|
| 35 | + ), $object->toArray()); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 40 | + */ |
|
| 41 | + public function testConstructorReference() |
|
| 42 | + { |
|
| 43 | + $this->parent->handleCommand('model', 'User'); |
|
| 44 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'User'); |
|
| 45 | + |
|
| 46 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 47 | + |
|
| 48 | + $this->assertSame(array( |
|
| 49 | + '$ref' => '#/definitions/User', |
|
| 50 | + ), $object->toArray()); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 55 | + */ |
|
| 56 | + public function testConstructorEmptyDescription() |
|
| 57 | + { |
|
| 58 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', ''); |
|
| 59 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 60 | + |
|
| 61 | + $this->assertSame(array( |
|
| 62 | + 'type' => 'integer', |
|
| 63 | + 'format' => 'int32', |
|
| 64 | + ), $object->toArray()); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @covers \SwaggerGen\Swagger\Schema::__construct |
|
| 69 | + */ |
|
| 70 | + public function testConstructorDescription() |
|
| 71 | + { |
|
| 72 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int', 'Some more words'); |
|
| 73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 74 | + |
|
| 75 | + $this->assertSame(array( |
|
| 76 | + 'type' => 'integer', |
|
| 77 | + 'format' => 'int32', |
|
| 78 | + 'description' => 'Some more words', |
|
| 79 | + ), $object->toArray()); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 84 | + */ |
|
| 85 | + public function testCommandPassing() |
|
| 86 | + { |
|
| 87 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 88 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 89 | + |
|
| 90 | + $object->handleCommand('default', '123'); |
|
| 91 | + |
|
| 92 | + $this->assertSame(array( |
|
| 93 | + 'type' => 'integer', |
|
| 94 | + 'format' => 'int32', |
|
| 95 | + 'default' => 123, |
|
| 96 | + ), $object->toArray()); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 101 | + */ |
|
| 102 | + public function testCommand_Description() |
|
| 103 | + { |
|
| 104 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 105 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 106 | + |
|
| 107 | + $object->handleCommand('description', 'Some words'); |
|
| 108 | + |
|
| 109 | + $this->assertSame(array( |
|
| 110 | + 'type' => 'integer', |
|
| 111 | + 'format' => 'int32', |
|
| 112 | + 'description' => 'Some words', |
|
| 113 | + ), $object->toArray()); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @covers \SwaggerGen\Swagger\Type\Schema->handleCommand |
|
| 118 | + */ |
|
| 119 | + public function testCommand_Title() |
|
| 120 | + { |
|
| 121 | + $object = new \SwaggerGen\Swagger\Schema($this->parent, 'int'); |
|
| 122 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $object); |
|
| 123 | + |
|
| 124 | + $object->handleCommand('title', 'Title words'); |
|
| 125 | + |
|
| 126 | + $this->assertSame(array( |
|
| 127 | + 'type' => 'integer', |
|
| 128 | + 'format' => 'int32', |
|
| 129 | + 'title' => 'Title words', |
|
| 130 | + ), $object->toArray()); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + protected function setUp(): void |
|
| 134 | + { |
|
| 135 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + protected function assertPreConditions(): void |
|
| 139 | + { |
|
| 140 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | } |
@@ -7,99 +7,99 @@ |
||
| 7 | 7 | class HeaderTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $parent; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 14 | - */ |
|
| 15 | - public function testConstructorType(): void |
|
| 16 | - { |
|
| 17 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 18 | - |
|
| 19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 20 | - |
|
| 21 | - $this->assertSame(array( |
|
| 22 | - 'type' => 'integer', |
|
| 23 | - ), $object->toArray()); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 28 | - */ |
|
| 29 | - public function testConstructorInvalidType() |
|
| 30 | - { |
|
| 31 | - $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'BadType'"); |
|
| 32 | - |
|
| 33 | - new \SwaggerGen\Swagger\Header($this->parent, 'BadType'); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 38 | - */ |
|
| 39 | - public function testConstructorNoDescription() |
|
| 40 | - { |
|
| 41 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 42 | - |
|
| 43 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 44 | - |
|
| 45 | - $this->assertSame(array( |
|
| 46 | - 'type' => 'integer', |
|
| 47 | - ), $object->toArray()); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 52 | - */ |
|
| 53 | - public function testConstructorBlankDescription() |
|
| 54 | - { |
|
| 55 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', ''); |
|
| 56 | - |
|
| 57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 58 | - |
|
| 59 | - $this->assertSame(array( |
|
| 60 | - 'type' => 'integer', |
|
| 61 | - ), $object->toArray()); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 66 | - */ |
|
| 67 | - public function testConstructorFull() |
|
| 68 | - { |
|
| 69 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 70 | - |
|
| 71 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 72 | - |
|
| 73 | - $this->assertSame(array( |
|
| 74 | - 'type' => 'integer', |
|
| 75 | - 'description' => 'descriptive text', |
|
| 76 | - ), $object->toArray()); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @covers \SwaggerGen\Swagger\Header->handleCommand |
|
| 81 | - */ |
|
| 82 | - public function testCommandDescription() |
|
| 83 | - { |
|
| 84 | - $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 85 | - |
|
| 86 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 87 | - |
|
| 88 | - $object->handleCommand('description', 'Some other lines'); |
|
| 89 | - |
|
| 90 | - $this->assertSame(array( |
|
| 91 | - 'type' => 'integer', |
|
| 92 | - 'description' => 'Some other lines', |
|
| 93 | - ), $object->toArray()); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - protected function setUp(): void |
|
| 97 | - { |
|
| 98 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - protected function assertPreConditions(): void |
|
| 102 | - { |
|
| 103 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 104 | - } |
|
| 10 | + protected $parent; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 14 | + */ |
|
| 15 | + public function testConstructorType(): void |
|
| 16 | + { |
|
| 17 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 18 | + |
|
| 19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 20 | + |
|
| 21 | + $this->assertSame(array( |
|
| 22 | + 'type' => 'integer', |
|
| 23 | + ), $object->toArray()); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 28 | + */ |
|
| 29 | + public function testConstructorInvalidType() |
|
| 30 | + { |
|
| 31 | + $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'BadType'"); |
|
| 32 | + |
|
| 33 | + new \SwaggerGen\Swagger\Header($this->parent, 'BadType'); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 38 | + */ |
|
| 39 | + public function testConstructorNoDescription() |
|
| 40 | + { |
|
| 41 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer'); |
|
| 42 | + |
|
| 43 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 44 | + |
|
| 45 | + $this->assertSame(array( |
|
| 46 | + 'type' => 'integer', |
|
| 47 | + ), $object->toArray()); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 52 | + */ |
|
| 53 | + public function testConstructorBlankDescription() |
|
| 54 | + { |
|
| 55 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', ''); |
|
| 56 | + |
|
| 57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 58 | + |
|
| 59 | + $this->assertSame(array( |
|
| 60 | + 'type' => 'integer', |
|
| 61 | + ), $object->toArray()); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @covers \SwaggerGen\Swagger\Header::__construct |
|
| 66 | + */ |
|
| 67 | + public function testConstructorFull() |
|
| 68 | + { |
|
| 69 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 70 | + |
|
| 71 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 72 | + |
|
| 73 | + $this->assertSame(array( |
|
| 74 | + 'type' => 'integer', |
|
| 75 | + 'description' => 'descriptive text', |
|
| 76 | + ), $object->toArray()); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @covers \SwaggerGen\Swagger\Header->handleCommand |
|
| 81 | + */ |
|
| 82 | + public function testCommandDescription() |
|
| 83 | + { |
|
| 84 | + $object = new \SwaggerGen\Swagger\Header($this->parent, 'integer', 'descriptive text'); |
|
| 85 | + |
|
| 86 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Header', $object); |
|
| 87 | + |
|
| 88 | + $object->handleCommand('description', 'Some other lines'); |
|
| 89 | + |
|
| 90 | + $this->assertSame(array( |
|
| 91 | + 'type' => 'integer', |
|
| 92 | + 'description' => 'Some other lines', |
|
| 93 | + ), $object->toArray()); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + protected function setUp(): void |
|
| 97 | + { |
|
| 98 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + protected function assertPreConditions(): void |
|
| 102 | + { |
|
| 103 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -6,108 +6,108 @@ |
||
| 6 | 6 | class TagTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 13 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 14 | - */ |
|
| 15 | - public function testConstructor2() |
|
| 16 | - { |
|
| 17 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 18 | - |
|
| 19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 20 | - |
|
| 21 | - $this->assertSame(array( |
|
| 22 | - 'name' => 'Name', |
|
| 23 | - ), $object->toArray()); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 28 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 29 | - */ |
|
| 30 | - public function testConstructor_Description_Empty() |
|
| 31 | - { |
|
| 32 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', ''); |
|
| 33 | - |
|
| 34 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 35 | - |
|
| 36 | - $this->assertSame(array( |
|
| 37 | - 'name' => 'Name', |
|
| 38 | - ), $object->toArray()); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 43 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 44 | - */ |
|
| 45 | - public function testConstructor3() |
|
| 46 | - { |
|
| 47 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 48 | - |
|
| 49 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 50 | - |
|
| 51 | - $this->assertSame(array( |
|
| 52 | - 'name' => 'Name', |
|
| 53 | - 'description' => 'Description', |
|
| 54 | - ), $object->toArray()); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @covers \SwaggerGen\Swagger\Tag::getName |
|
| 59 | - */ |
|
| 60 | - public function testGetName() |
|
| 61 | - { |
|
| 62 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 63 | - |
|
| 64 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 65 | - |
|
| 66 | - $this->assertSame('Name', $object->getName()); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 71 | - */ |
|
| 72 | - public function testCommandDescription() |
|
| 73 | - { |
|
| 74 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 75 | - |
|
| 76 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 77 | - |
|
| 78 | - $object->handleCommand('description', 'Command Description'); |
|
| 79 | - |
|
| 80 | - $this->assertSame(array( |
|
| 81 | - 'name' => 'Name', |
|
| 82 | - 'description' => 'Command Description', |
|
| 83 | - ), $object->toArray()); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 88 | - */ |
|
| 89 | - public function testCommandDescriptionOverwrite() |
|
| 90 | - { |
|
| 91 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 92 | - |
|
| 93 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 94 | - |
|
| 95 | - $object->handleCommand('description', 'Command Description'); |
|
| 96 | - |
|
| 97 | - $this->assertSame(array( |
|
| 98 | - 'name' => 'Name', |
|
| 99 | - 'description' => 'Command Description', |
|
| 100 | - ), $object->toArray()); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - protected function setUp(): void |
|
| 104 | - { |
|
| 105 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - protected function assertPreConditions(): void |
|
| 109 | - { |
|
| 110 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 111 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 13 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 14 | + */ |
|
| 15 | + public function testConstructor2() |
|
| 16 | + { |
|
| 17 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 18 | + |
|
| 19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 20 | + |
|
| 21 | + $this->assertSame(array( |
|
| 22 | + 'name' => 'Name', |
|
| 23 | + ), $object->toArray()); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 28 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 29 | + */ |
|
| 30 | + public function testConstructor_Description_Empty() |
|
| 31 | + { |
|
| 32 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', ''); |
|
| 33 | + |
|
| 34 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 35 | + |
|
| 36 | + $this->assertSame(array( |
|
| 37 | + 'name' => 'Name', |
|
| 38 | + ), $object->toArray()); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 43 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 44 | + */ |
|
| 45 | + public function testConstructor3() |
|
| 46 | + { |
|
| 47 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 48 | + |
|
| 49 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 50 | + |
|
| 51 | + $this->assertSame(array( |
|
| 52 | + 'name' => 'Name', |
|
| 53 | + 'description' => 'Description', |
|
| 54 | + ), $object->toArray()); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @covers \SwaggerGen\Swagger\Tag::getName |
|
| 59 | + */ |
|
| 60 | + public function testGetName() |
|
| 61 | + { |
|
| 62 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 63 | + |
|
| 64 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 65 | + |
|
| 66 | + $this->assertSame('Name', $object->getName()); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 71 | + */ |
|
| 72 | + public function testCommandDescription() |
|
| 73 | + { |
|
| 74 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 75 | + |
|
| 76 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 77 | + |
|
| 78 | + $object->handleCommand('description', 'Command Description'); |
|
| 79 | + |
|
| 80 | + $this->assertSame(array( |
|
| 81 | + 'name' => 'Name', |
|
| 82 | + 'description' => 'Command Description', |
|
| 83 | + ), $object->toArray()); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 88 | + */ |
|
| 89 | + public function testCommandDescriptionOverwrite() |
|
| 90 | + { |
|
| 91 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name', 'Description'); |
|
| 92 | + |
|
| 93 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 94 | + |
|
| 95 | + $object->handleCommand('description', 'Command Description'); |
|
| 96 | + |
|
| 97 | + $this->assertSame(array( |
|
| 98 | + 'name' => 'Name', |
|
| 99 | + 'description' => 'Command Description', |
|
| 100 | + ), $object->toArray()); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + protected function setUp(): void |
|
| 104 | + { |
|
| 105 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + protected function assertPreConditions(): void |
|
| 109 | + { |
|
| 110 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | } |
@@ -7,247 +7,247 @@ |
||
| 7 | 7 | class InfoTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $parent; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * @covers \SwaggerGen\Swagger\Info |
|
| 14 | - */ |
|
| 15 | - public function testNoConstructor(): void |
|
| 16 | - { |
|
| 17 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 18 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 19 | - |
|
| 20 | - $this->assertSame(array( |
|
| 21 | - 'title' => 'undefined', |
|
| 22 | - 'version' => '0', |
|
| 23 | - ), $object->toArray()); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 28 | - */ |
|
| 29 | - public function testCommandTitle() |
|
| 30 | - { |
|
| 31 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 32 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 33 | - |
|
| 34 | - $object->handleCommand('title', 'This is the title'); |
|
| 35 | - |
|
| 36 | - $this->assertSame(array( |
|
| 37 | - 'title' => 'This is the title', |
|
| 38 | - 'version' => '0', |
|
| 39 | - ), $object->toArray()); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 44 | - */ |
|
| 45 | - public function testCommandDescription() |
|
| 46 | - { |
|
| 47 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 48 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 49 | - |
|
| 50 | - $object->handleCommand('description', 'This is the description'); |
|
| 51 | - |
|
| 52 | - $this->assertSame(array( |
|
| 53 | - 'title' => 'undefined', |
|
| 54 | - 'description' => 'This is the description', |
|
| 55 | - 'version' => '0', |
|
| 56 | - ), $object->toArray()); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 61 | - */ |
|
| 62 | - public function testCommandVersion() |
|
| 63 | - { |
|
| 64 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 65 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 66 | - |
|
| 67 | - $object->handleCommand('version', '1.2.3a'); |
|
| 68 | - |
|
| 69 | - $this->assertSame(array( |
|
| 70 | - 'title' => 'undefined', |
|
| 71 | - 'version' => '1.2.3a', |
|
| 72 | - ), $object->toArray()); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 77 | - */ |
|
| 78 | - public function testCommandTermsofservice() |
|
| 79 | - { |
|
| 80 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 81 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 82 | - |
|
| 83 | - $object->handleCommand('termsofservice', 'These are the terms'); |
|
| 84 | - |
|
| 85 | - $this->assertSame(array( |
|
| 86 | - 'title' => 'undefined', |
|
| 87 | - 'termsOfService' => 'These are the terms', |
|
| 88 | - 'version' => '0', |
|
| 89 | - ), $object->toArray()); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 94 | - */ |
|
| 95 | - public function testCommandTerms() |
|
| 96 | - { |
|
| 97 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 98 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 99 | - |
|
| 100 | - $object->handleCommand('terms', 'These are the terms'); |
|
| 101 | - |
|
| 102 | - $this->assertSame(array( |
|
| 103 | - 'title' => 'undefined', |
|
| 104 | - 'termsOfService' => 'These are the terms', |
|
| 105 | - 'version' => '0', |
|
| 106 | - ), $object->toArray()); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 111 | - */ |
|
| 112 | - public function testCommandContactNameUrlEmail() |
|
| 113 | - { |
|
| 114 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 115 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 116 | - |
|
| 117 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
| 118 | - |
|
| 119 | - $this->assertSame(array( |
|
| 120 | - 'title' => 'undefined', |
|
| 121 | - 'contact' => array( |
|
| 122 | - 'name' => 'Arthur D. Author', |
|
| 123 | - 'url' => 'http://example.test', |
|
| 124 | - 'email' => '[email protected]', |
|
| 125 | - ), |
|
| 126 | - 'version' => '0', |
|
| 127 | - ), $object->toArray()); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 132 | - */ |
|
| 133 | - public function testCommandContactNameEmailNameUrlName() |
|
| 134 | - { |
|
| 135 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 136 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 137 | - |
|
| 138 | - $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
| 139 | - |
|
| 140 | - $this->assertSame(array( |
|
| 141 | - 'title' => 'undefined', |
|
| 142 | - 'contact' => array( |
|
| 143 | - 'name' => 'Arthur D. Author', |
|
| 144 | - 'url' => 'http://example.test', |
|
| 145 | - 'email' => '[email protected]', |
|
| 146 | - ), |
|
| 147 | - 'version' => '0', |
|
| 148 | - ), $object->toArray()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 153 | - */ |
|
| 154 | - public function testCommandLicenseNameUrl() |
|
| 155 | - { |
|
| 156 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 157 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 158 | - |
|
| 159 | - $object->handleCommand('license', 'NAME http://example.test'); |
|
| 160 | - |
|
| 161 | - $this->assertSame(array( |
|
| 162 | - 'title' => 'undefined', |
|
| 163 | - 'license' => array( |
|
| 164 | - 'name' => 'NAME', |
|
| 165 | - 'url' => 'http://example.test', |
|
| 166 | - ), |
|
| 167 | - 'version' => '0', |
|
| 168 | - ), $object->toArray()); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 173 | - */ |
|
| 174 | - public function testCommandLicenseUrlName() |
|
| 175 | - { |
|
| 176 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 177 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 178 | - |
|
| 179 | - $object->handleCommand('license', 'http://example.test NAME'); |
|
| 180 | - |
|
| 181 | - $this->assertSame(array( |
|
| 182 | - 'title' => 'undefined', |
|
| 183 | - 'license' => array( |
|
| 184 | - 'name' => 'NAME', |
|
| 185 | - 'url' => 'http://example.test', |
|
| 186 | - ), |
|
| 187 | - 'version' => '0', |
|
| 188 | - ), $object->toArray()); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 193 | - */ |
|
| 194 | - public function testCommandLicenseShorthand() |
|
| 195 | - { |
|
| 196 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 197 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 198 | - |
|
| 199 | - $object->handleCommand('license', 'BSD'); |
|
| 200 | - |
|
| 201 | - $this->assertSame(array( |
|
| 202 | - 'title' => 'undefined', |
|
| 203 | - 'license' => array( |
|
| 204 | - 'name' => 'BSD', |
|
| 205 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
| 206 | - ), |
|
| 207 | - 'version' => '0', |
|
| 208 | - ), $object->toArray()); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 213 | - */ |
|
| 214 | - public function testCommandAll() |
|
| 215 | - { |
|
| 216 | - $object = new \SwaggerGen\Swagger\Info; |
|
| 217 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 218 | - |
|
| 219 | - $object->handleCommand('description', 'This is the description'); |
|
| 220 | - $object->handleCommand('license', 'BSD'); |
|
| 221 | - $object->handleCommand('terms', 'These are the terms'); |
|
| 222 | - $object->handleCommand('version', '1.2.3a'); |
|
| 223 | - $object->handleCommand('title', 'This is the title'); |
|
| 224 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
| 225 | - |
|
| 226 | - $this->assertSame(array( |
|
| 227 | - 'title' => 'This is the title', |
|
| 228 | - 'description' => 'This is the description', |
|
| 229 | - 'termsOfService' => 'These are the terms', |
|
| 230 | - 'contact' => array( |
|
| 231 | - 'name' => 'Arthur D. Author', |
|
| 232 | - 'url' => 'http://example.test', |
|
| 233 | - 'email' => '[email protected]', |
|
| 234 | - ), |
|
| 235 | - 'license' => array( |
|
| 236 | - 'name' => 'BSD', |
|
| 237 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
| 238 | - ), |
|
| 239 | - 'version' => '1.2.3a', |
|
| 240 | - ), $object->toArray()); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - protected function setUp(): void |
|
| 244 | - { |
|
| 245 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - protected function assertPreConditions(): void |
|
| 249 | - { |
|
| 250 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 251 | - } |
|
| 10 | + protected $parent; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @covers \SwaggerGen\Swagger\Info |
|
| 14 | + */ |
|
| 15 | + public function testNoConstructor(): void |
|
| 16 | + { |
|
| 17 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 18 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 19 | + |
|
| 20 | + $this->assertSame(array( |
|
| 21 | + 'title' => 'undefined', |
|
| 22 | + 'version' => '0', |
|
| 23 | + ), $object->toArray()); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 28 | + */ |
|
| 29 | + public function testCommandTitle() |
|
| 30 | + { |
|
| 31 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 32 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 33 | + |
|
| 34 | + $object->handleCommand('title', 'This is the title'); |
|
| 35 | + |
|
| 36 | + $this->assertSame(array( |
|
| 37 | + 'title' => 'This is the title', |
|
| 38 | + 'version' => '0', |
|
| 39 | + ), $object->toArray()); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 44 | + */ |
|
| 45 | + public function testCommandDescription() |
|
| 46 | + { |
|
| 47 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 48 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 49 | + |
|
| 50 | + $object->handleCommand('description', 'This is the description'); |
|
| 51 | + |
|
| 52 | + $this->assertSame(array( |
|
| 53 | + 'title' => 'undefined', |
|
| 54 | + 'description' => 'This is the description', |
|
| 55 | + 'version' => '0', |
|
| 56 | + ), $object->toArray()); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 61 | + */ |
|
| 62 | + public function testCommandVersion() |
|
| 63 | + { |
|
| 64 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 65 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 66 | + |
|
| 67 | + $object->handleCommand('version', '1.2.3a'); |
|
| 68 | + |
|
| 69 | + $this->assertSame(array( |
|
| 70 | + 'title' => 'undefined', |
|
| 71 | + 'version' => '1.2.3a', |
|
| 72 | + ), $object->toArray()); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 77 | + */ |
|
| 78 | + public function testCommandTermsofservice() |
|
| 79 | + { |
|
| 80 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 81 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 82 | + |
|
| 83 | + $object->handleCommand('termsofservice', 'These are the terms'); |
|
| 84 | + |
|
| 85 | + $this->assertSame(array( |
|
| 86 | + 'title' => 'undefined', |
|
| 87 | + 'termsOfService' => 'These are the terms', |
|
| 88 | + 'version' => '0', |
|
| 89 | + ), $object->toArray()); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 94 | + */ |
|
| 95 | + public function testCommandTerms() |
|
| 96 | + { |
|
| 97 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 98 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 99 | + |
|
| 100 | + $object->handleCommand('terms', 'These are the terms'); |
|
| 101 | + |
|
| 102 | + $this->assertSame(array( |
|
| 103 | + 'title' => 'undefined', |
|
| 104 | + 'termsOfService' => 'These are the terms', |
|
| 105 | + 'version' => '0', |
|
| 106 | + ), $object->toArray()); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 111 | + */ |
|
| 112 | + public function testCommandContactNameUrlEmail() |
|
| 113 | + { |
|
| 114 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 115 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 116 | + |
|
| 117 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
| 118 | + |
|
| 119 | + $this->assertSame(array( |
|
| 120 | + 'title' => 'undefined', |
|
| 121 | + 'contact' => array( |
|
| 122 | + 'name' => 'Arthur D. Author', |
|
| 123 | + 'url' => 'http://example.test', |
|
| 124 | + 'email' => '[email protected]', |
|
| 125 | + ), |
|
| 126 | + 'version' => '0', |
|
| 127 | + ), $object->toArray()); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 132 | + */ |
|
| 133 | + public function testCommandContactNameEmailNameUrlName() |
|
| 134 | + { |
|
| 135 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 136 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 137 | + |
|
| 138 | + $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
| 139 | + |
|
| 140 | + $this->assertSame(array( |
|
| 141 | + 'title' => 'undefined', |
|
| 142 | + 'contact' => array( |
|
| 143 | + 'name' => 'Arthur D. Author', |
|
| 144 | + 'url' => 'http://example.test', |
|
| 145 | + 'email' => '[email protected]', |
|
| 146 | + ), |
|
| 147 | + 'version' => '0', |
|
| 148 | + ), $object->toArray()); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 153 | + */ |
|
| 154 | + public function testCommandLicenseNameUrl() |
|
| 155 | + { |
|
| 156 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 157 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 158 | + |
|
| 159 | + $object->handleCommand('license', 'NAME http://example.test'); |
|
| 160 | + |
|
| 161 | + $this->assertSame(array( |
|
| 162 | + 'title' => 'undefined', |
|
| 163 | + 'license' => array( |
|
| 164 | + 'name' => 'NAME', |
|
| 165 | + 'url' => 'http://example.test', |
|
| 166 | + ), |
|
| 167 | + 'version' => '0', |
|
| 168 | + ), $object->toArray()); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 173 | + */ |
|
| 174 | + public function testCommandLicenseUrlName() |
|
| 175 | + { |
|
| 176 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 177 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 178 | + |
|
| 179 | + $object->handleCommand('license', 'http://example.test NAME'); |
|
| 180 | + |
|
| 181 | + $this->assertSame(array( |
|
| 182 | + 'title' => 'undefined', |
|
| 183 | + 'license' => array( |
|
| 184 | + 'name' => 'NAME', |
|
| 185 | + 'url' => 'http://example.test', |
|
| 186 | + ), |
|
| 187 | + 'version' => '0', |
|
| 188 | + ), $object->toArray()); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 193 | + */ |
|
| 194 | + public function testCommandLicenseShorthand() |
|
| 195 | + { |
|
| 196 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 197 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 198 | + |
|
| 199 | + $object->handleCommand('license', 'BSD'); |
|
| 200 | + |
|
| 201 | + $this->assertSame(array( |
|
| 202 | + 'title' => 'undefined', |
|
| 203 | + 'license' => array( |
|
| 204 | + 'name' => 'BSD', |
|
| 205 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
| 206 | + ), |
|
| 207 | + 'version' => '0', |
|
| 208 | + ), $object->toArray()); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
| 213 | + */ |
|
| 214 | + public function testCommandAll() |
|
| 215 | + { |
|
| 216 | + $object = new \SwaggerGen\Swagger\Info; |
|
| 217 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
| 218 | + |
|
| 219 | + $object->handleCommand('description', 'This is the description'); |
|
| 220 | + $object->handleCommand('license', 'BSD'); |
|
| 221 | + $object->handleCommand('terms', 'These are the terms'); |
|
| 222 | + $object->handleCommand('version', '1.2.3a'); |
|
| 223 | + $object->handleCommand('title', 'This is the title'); |
|
| 224 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
| 225 | + |
|
| 226 | + $this->assertSame(array( |
|
| 227 | + 'title' => 'This is the title', |
|
| 228 | + 'description' => 'This is the description', |
|
| 229 | + 'termsOfService' => 'These are the terms', |
|
| 230 | + 'contact' => array( |
|
| 231 | + 'name' => 'Arthur D. Author', |
|
| 232 | + 'url' => 'http://example.test', |
|
| 233 | + 'email' => '[email protected]', |
|
| 234 | + ), |
|
| 235 | + 'license' => array( |
|
| 236 | + 'name' => 'BSD', |
|
| 237 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
| 238 | + ), |
|
| 239 | + 'version' => '1.2.3a', |
|
| 240 | + ), $object->toArray()); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + protected function setUp(): void |
|
| 244 | + { |
|
| 245 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + protected function assertPreConditions(): void |
|
| 249 | + { |
|
| 250 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | } |
@@ -6,403 +6,403 @@ |
||
| 6 | 6 | class ResponseTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructor_200() |
|
| 15 | - { |
|
| 16 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 17 | - |
|
| 18 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 19 | - |
|
| 20 | - $this->assertSame(array( |
|
| 21 | - 'description' => 'OK', |
|
| 22 | - ), $object->toArray()); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 27 | - */ |
|
| 28 | - public function testConstructor_404Type() |
|
| 29 | - { |
|
| 30 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 404); |
|
| 31 | - |
|
| 32 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 33 | - |
|
| 34 | - $this->assertSame(array( |
|
| 35 | - 'description' => 'Not Found', |
|
| 36 | - ), $object->toArray()); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 41 | - */ |
|
| 42 | - public function testConstructor_Type() |
|
| 43 | - { |
|
| 44 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'int'); |
|
| 45 | - |
|
| 46 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 47 | - |
|
| 48 | - $this->assertSame(array( |
|
| 49 | - 'description' => 'OK', |
|
| 50 | - 'schema' => array( |
|
| 51 | - 'type' => 'integer', |
|
| 52 | - 'format' => 'int32', |
|
| 53 | - ), |
|
| 54 | - ), $object->toArray()); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 59 | - */ |
|
| 60 | - public function testConstructor_Reference() |
|
| 61 | - { |
|
| 62 | - $this->parent->handleCommand('model', 'User'); |
|
| 63 | - |
|
| 64 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'User'); |
|
| 65 | - |
|
| 66 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 67 | - |
|
| 68 | - $this->assertSame(array( |
|
| 69 | - 'description' => 'OK', |
|
| 70 | - 'schema' => array( |
|
| 71 | - '$ref' => '#/definitions/User', |
|
| 72 | - ), |
|
| 73 | - ), $object->toArray()); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 78 | - */ |
|
| 79 | - public function testConstructor_Description() |
|
| 80 | - { |
|
| 81 | - $object = new \SwaggerGen\Swagger\Response($this->parent, '200', null, 'Fine And Dandy'); |
|
| 82 | - |
|
| 83 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 84 | - |
|
| 85 | - $this->assertSame(array( |
|
| 86 | - 'description' => 'Fine And Dandy', |
|
| 87 | - ), $object->toArray()); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 92 | - */ |
|
| 93 | - public function testCommand_Header_NoType() |
|
| 94 | - { |
|
| 95 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 96 | - |
|
| 97 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 98 | - |
|
| 99 | - $this->expectException('\SwaggerGen\Exception', "Missing type for header"); |
|
| 100 | - |
|
| 101 | - $object->handleCommand('header', ''); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 106 | - */ |
|
| 107 | - public function testCommand_Header_NoName() |
|
| 108 | - { |
|
| 109 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 110 | - |
|
| 111 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 112 | - |
|
| 113 | - $this->expectException('\SwaggerGen\Exception', "Missing name for header type 'int'"); |
|
| 114 | - |
|
| 115 | - $object->handleCommand('header', 'int'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 120 | - */ |
|
| 121 | - public function testCommand_Header_InvalidType() |
|
| 122 | - { |
|
| 123 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 124 | - |
|
| 125 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 126 | - |
|
| 127 | - $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'foo'"); |
|
| 128 | - |
|
| 129 | - $object->handleCommand('header', 'foo bar'); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 134 | - */ |
|
| 135 | - public function testCommand_Header() |
|
| 136 | - { |
|
| 137 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 138 | - |
|
| 139 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 140 | - |
|
| 141 | - $object->handleCommand('header', 'integer bar'); |
|
| 142 | - |
|
| 143 | - $this->assertSame(array( |
|
| 144 | - 'description' => 'OK', |
|
| 145 | - 'headers' => array( |
|
| 146 | - 'bar' => array( |
|
| 147 | - 'type' => 'integer', |
|
| 148 | - ), |
|
| 149 | - ), |
|
| 150 | - ), $object->toArray()); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 155 | - */ |
|
| 156 | - public function testCommand_Header_Description() |
|
| 157 | - { |
|
| 158 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 159 | - |
|
| 160 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 161 | - |
|
| 162 | - $object->handleCommand('header', 'integer bar Some text'); |
|
| 163 | - |
|
| 164 | - $this->assertSame(array( |
|
| 165 | - 'description' => 'OK', |
|
| 166 | - 'headers' => array( |
|
| 167 | - 'bar' => array( |
|
| 168 | - 'type' => 'integer', |
|
| 169 | - 'description' => 'Some text', |
|
| 170 | - ), |
|
| 171 | - ), |
|
| 172 | - ), $object->toArray()); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 177 | - */ |
|
| 178 | - public function testCommand_Header_Multiple() |
|
| 179 | - { |
|
| 180 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 181 | - |
|
| 182 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 183 | - |
|
| 184 | - $object->handleCommand('header', 'integer bar'); |
|
| 185 | - $object->handleCommand('header', 'string X-Whatever'); |
|
| 186 | - |
|
| 187 | - $this->assertSame(array( |
|
| 188 | - 'description' => 'OK', |
|
| 189 | - 'headers' => array( |
|
| 190 | - 'bar' => array( |
|
| 191 | - 'type' => 'integer', |
|
| 192 | - ), |
|
| 193 | - 'X-Whatever' => array( |
|
| 194 | - 'type' => 'string', |
|
| 195 | - ), |
|
| 196 | - ), |
|
| 197 | - ), $object->toArray()); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 202 | - */ |
|
| 203 | - public function testCommand_Example_NoName() |
|
| 204 | - { |
|
| 205 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 206 | - |
|
| 207 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 208 | - |
|
| 209 | - $this->expectException('\SwaggerGen\Exception', "Missing name for example"); |
|
| 210 | - |
|
| 211 | - $object->handleCommand('example', ''); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 216 | - */ |
|
| 217 | - public function testCommand_Example_NoData() |
|
| 218 | - { |
|
| 219 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 220 | - |
|
| 221 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 222 | - |
|
| 223 | - $this->expectException('\SwaggerGen\Exception', "Missing content for example `Foo`"); |
|
| 224 | - |
|
| 225 | - $object->handleCommand('example', 'Foo'); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 230 | - */ |
|
| 231 | - public function testCommand_Example_Text() |
|
| 232 | - { |
|
| 233 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 234 | - |
|
| 235 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 236 | - |
|
| 237 | - $object->handleCommand('example', 'Foo bar'); |
|
| 238 | - |
|
| 239 | - $this->assertSame(array( |
|
| 240 | - 'description' => 'OK', |
|
| 241 | - 'examples' => array( |
|
| 242 | - 'Foo' => 'bar', |
|
| 243 | - ), |
|
| 244 | - ), $object->toArray()); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 249 | - */ |
|
| 250 | - public function testCommand_Example_Number() |
|
| 251 | - { |
|
| 252 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 253 | - |
|
| 254 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 255 | - |
|
| 256 | - $object->handleCommand('example', 'Foo 123.45'); |
|
| 257 | - |
|
| 258 | - $this->assertSame(array( |
|
| 259 | - 'description' => 'OK', |
|
| 260 | - 'examples' => array( |
|
| 261 | - 'Foo' => 123.45, |
|
| 262 | - ), |
|
| 263 | - ), $object->toArray()); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 268 | - */ |
|
| 269 | - public function testCommand_Example_Json() |
|
| 270 | - { |
|
| 271 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 272 | - |
|
| 273 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 274 | - |
|
| 275 | - $object->handleCommand('example', 'Foo {"bar":"baz"}'); |
|
| 276 | - |
|
| 277 | - $this->assertSame(array( |
|
| 278 | - 'description' => 'OK', |
|
| 279 | - 'examples' => array( |
|
| 280 | - 'Foo' => array( |
|
| 281 | - 'bar' => 'baz', |
|
| 282 | - ), |
|
| 283 | - ), |
|
| 284 | - ), $object->toArray()); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 289 | - */ |
|
| 290 | - public function testCommand_Example_Json_Unquoted() |
|
| 291 | - { |
|
| 292 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 293 | - |
|
| 294 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 295 | - |
|
| 296 | - $object->handleCommand('example', 'Foo {bar:baz}'); |
|
| 297 | - |
|
| 298 | - $this->assertSame(array( |
|
| 299 | - 'description' => 'OK', |
|
| 300 | - 'examples' => array( |
|
| 301 | - 'Foo' => array( |
|
| 302 | - 'bar' => 'baz', |
|
| 303 | - ), |
|
| 304 | - ), |
|
| 305 | - ), $object->toArray()); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 310 | - */ |
|
| 311 | - public function testCommand_Example_Json_Whitespace() |
|
| 312 | - { |
|
| 313 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 314 | - |
|
| 315 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 316 | - |
|
| 317 | - $object->handleCommand('example', 'Foo { "bar" : "baz" } '); |
|
| 318 | - |
|
| 319 | - $this->assertSame(array( |
|
| 320 | - 'description' => 'OK', |
|
| 321 | - 'examples' => array( |
|
| 322 | - 'Foo' => array( |
|
| 323 | - 'bar' => 'baz', |
|
| 324 | - ), |
|
| 325 | - ), |
|
| 326 | - ), $object->toArray()); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 331 | - */ |
|
| 332 | - public function testCommand_Example_Json_Multiple() |
|
| 333 | - { |
|
| 334 | - $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 335 | - |
|
| 336 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 337 | - |
|
| 338 | - $object->handleCommand('example', 'Foo "Bar" '); |
|
| 339 | - $object->handleCommand('example', 'Baz false'); |
|
| 340 | - |
|
| 341 | - $this->assertSame(array( |
|
| 342 | - 'description' => 'OK', |
|
| 343 | - 'examples' => array( |
|
| 344 | - 'Foo' => 'Bar', |
|
| 345 | - 'Baz' => false, |
|
| 346 | - ), |
|
| 347 | - ), $object->toArray()); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 352 | - */ |
|
| 353 | - public function testGetCode_Numeric() |
|
| 354 | - { |
|
| 355 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode(200)); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 360 | - */ |
|
| 361 | - public function testGetCode_CaseSensitive() |
|
| 362 | - { |
|
| 363 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('OK')); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 368 | - */ |
|
| 369 | - public function testGetCode_CaseInsensitive() |
|
| 370 | - { |
|
| 371 | - $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('ok')); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 376 | - */ |
|
| 377 | - public function testGetCode_Space() |
|
| 378 | - { |
|
| 379 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('not Found')); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 384 | - */ |
|
| 385 | - public function testGetCode_Crap() |
|
| 386 | - { |
|
| 387 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode(' not___F-ou/nd ')); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 392 | - */ |
|
| 393 | - public function testGetCode_Smashed() |
|
| 394 | - { |
|
| 395 | - $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('nOtfOund')); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - protected function setUp(): void |
|
| 399 | - { |
|
| 400 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - protected function assertPreConditions(): void |
|
| 404 | - { |
|
| 405 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 406 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructor_200() |
|
| 15 | + { |
|
| 16 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 17 | + |
|
| 18 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 19 | + |
|
| 20 | + $this->assertSame(array( |
|
| 21 | + 'description' => 'OK', |
|
| 22 | + ), $object->toArray()); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 27 | + */ |
|
| 28 | + public function testConstructor_404Type() |
|
| 29 | + { |
|
| 30 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 404); |
|
| 31 | + |
|
| 32 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 33 | + |
|
| 34 | + $this->assertSame(array( |
|
| 35 | + 'description' => 'Not Found', |
|
| 36 | + ), $object->toArray()); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 41 | + */ |
|
| 42 | + public function testConstructor_Type() |
|
| 43 | + { |
|
| 44 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'int'); |
|
| 45 | + |
|
| 46 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 47 | + |
|
| 48 | + $this->assertSame(array( |
|
| 49 | + 'description' => 'OK', |
|
| 50 | + 'schema' => array( |
|
| 51 | + 'type' => 'integer', |
|
| 52 | + 'format' => 'int32', |
|
| 53 | + ), |
|
| 54 | + ), $object->toArray()); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 59 | + */ |
|
| 60 | + public function testConstructor_Reference() |
|
| 61 | + { |
|
| 62 | + $this->parent->handleCommand('model', 'User'); |
|
| 63 | + |
|
| 64 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200, 'User'); |
|
| 65 | + |
|
| 66 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 67 | + |
|
| 68 | + $this->assertSame(array( |
|
| 69 | + 'description' => 'OK', |
|
| 70 | + 'schema' => array( |
|
| 71 | + '$ref' => '#/definitions/User', |
|
| 72 | + ), |
|
| 73 | + ), $object->toArray()); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @covers \SwaggerGen\Swagger\Response::__construct |
|
| 78 | + */ |
|
| 79 | + public function testConstructor_Description() |
|
| 80 | + { |
|
| 81 | + $object = new \SwaggerGen\Swagger\Response($this->parent, '200', null, 'Fine And Dandy'); |
|
| 82 | + |
|
| 83 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 84 | + |
|
| 85 | + $this->assertSame(array( |
|
| 86 | + 'description' => 'Fine And Dandy', |
|
| 87 | + ), $object->toArray()); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 92 | + */ |
|
| 93 | + public function testCommand_Header_NoType() |
|
| 94 | + { |
|
| 95 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 96 | + |
|
| 97 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 98 | + |
|
| 99 | + $this->expectException('\SwaggerGen\Exception', "Missing type for header"); |
|
| 100 | + |
|
| 101 | + $object->handleCommand('header', ''); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 106 | + */ |
|
| 107 | + public function testCommand_Header_NoName() |
|
| 108 | + { |
|
| 109 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 110 | + |
|
| 111 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 112 | + |
|
| 113 | + $this->expectException('\SwaggerGen\Exception', "Missing name for header type 'int'"); |
|
| 114 | + |
|
| 115 | + $object->handleCommand('header', 'int'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 120 | + */ |
|
| 121 | + public function testCommand_Header_InvalidType() |
|
| 122 | + { |
|
| 123 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 124 | + |
|
| 125 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 126 | + |
|
| 127 | + $this->expectException('\SwaggerGen\Exception', "Header type not valid: 'foo'"); |
|
| 128 | + |
|
| 129 | + $object->handleCommand('header', 'foo bar'); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 134 | + */ |
|
| 135 | + public function testCommand_Header() |
|
| 136 | + { |
|
| 137 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 138 | + |
|
| 139 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 140 | + |
|
| 141 | + $object->handleCommand('header', 'integer bar'); |
|
| 142 | + |
|
| 143 | + $this->assertSame(array( |
|
| 144 | + 'description' => 'OK', |
|
| 145 | + 'headers' => array( |
|
| 146 | + 'bar' => array( |
|
| 147 | + 'type' => 'integer', |
|
| 148 | + ), |
|
| 149 | + ), |
|
| 150 | + ), $object->toArray()); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 155 | + */ |
|
| 156 | + public function testCommand_Header_Description() |
|
| 157 | + { |
|
| 158 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 159 | + |
|
| 160 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 161 | + |
|
| 162 | + $object->handleCommand('header', 'integer bar Some text'); |
|
| 163 | + |
|
| 164 | + $this->assertSame(array( |
|
| 165 | + 'description' => 'OK', |
|
| 166 | + 'headers' => array( |
|
| 167 | + 'bar' => array( |
|
| 168 | + 'type' => 'integer', |
|
| 169 | + 'description' => 'Some text', |
|
| 170 | + ), |
|
| 171 | + ), |
|
| 172 | + ), $object->toArray()); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 177 | + */ |
|
| 178 | + public function testCommand_Header_Multiple() |
|
| 179 | + { |
|
| 180 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 181 | + |
|
| 182 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 183 | + |
|
| 184 | + $object->handleCommand('header', 'integer bar'); |
|
| 185 | + $object->handleCommand('header', 'string X-Whatever'); |
|
| 186 | + |
|
| 187 | + $this->assertSame(array( |
|
| 188 | + 'description' => 'OK', |
|
| 189 | + 'headers' => array( |
|
| 190 | + 'bar' => array( |
|
| 191 | + 'type' => 'integer', |
|
| 192 | + ), |
|
| 193 | + 'X-Whatever' => array( |
|
| 194 | + 'type' => 'string', |
|
| 195 | + ), |
|
| 196 | + ), |
|
| 197 | + ), $object->toArray()); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 202 | + */ |
|
| 203 | + public function testCommand_Example_NoName() |
|
| 204 | + { |
|
| 205 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 206 | + |
|
| 207 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 208 | + |
|
| 209 | + $this->expectException('\SwaggerGen\Exception', "Missing name for example"); |
|
| 210 | + |
|
| 211 | + $object->handleCommand('example', ''); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 216 | + */ |
|
| 217 | + public function testCommand_Example_NoData() |
|
| 218 | + { |
|
| 219 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 220 | + |
|
| 221 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 222 | + |
|
| 223 | + $this->expectException('\SwaggerGen\Exception', "Missing content for example `Foo`"); |
|
| 224 | + |
|
| 225 | + $object->handleCommand('example', 'Foo'); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 230 | + */ |
|
| 231 | + public function testCommand_Example_Text() |
|
| 232 | + { |
|
| 233 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 234 | + |
|
| 235 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 236 | + |
|
| 237 | + $object->handleCommand('example', 'Foo bar'); |
|
| 238 | + |
|
| 239 | + $this->assertSame(array( |
|
| 240 | + 'description' => 'OK', |
|
| 241 | + 'examples' => array( |
|
| 242 | + 'Foo' => 'bar', |
|
| 243 | + ), |
|
| 244 | + ), $object->toArray()); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 249 | + */ |
|
| 250 | + public function testCommand_Example_Number() |
|
| 251 | + { |
|
| 252 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 253 | + |
|
| 254 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 255 | + |
|
| 256 | + $object->handleCommand('example', 'Foo 123.45'); |
|
| 257 | + |
|
| 258 | + $this->assertSame(array( |
|
| 259 | + 'description' => 'OK', |
|
| 260 | + 'examples' => array( |
|
| 261 | + 'Foo' => 123.45, |
|
| 262 | + ), |
|
| 263 | + ), $object->toArray()); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 268 | + */ |
|
| 269 | + public function testCommand_Example_Json() |
|
| 270 | + { |
|
| 271 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 272 | + |
|
| 273 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 274 | + |
|
| 275 | + $object->handleCommand('example', 'Foo {"bar":"baz"}'); |
|
| 276 | + |
|
| 277 | + $this->assertSame(array( |
|
| 278 | + 'description' => 'OK', |
|
| 279 | + 'examples' => array( |
|
| 280 | + 'Foo' => array( |
|
| 281 | + 'bar' => 'baz', |
|
| 282 | + ), |
|
| 283 | + ), |
|
| 284 | + ), $object->toArray()); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 289 | + */ |
|
| 290 | + public function testCommand_Example_Json_Unquoted() |
|
| 291 | + { |
|
| 292 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 293 | + |
|
| 294 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 295 | + |
|
| 296 | + $object->handleCommand('example', 'Foo {bar:baz}'); |
|
| 297 | + |
|
| 298 | + $this->assertSame(array( |
|
| 299 | + 'description' => 'OK', |
|
| 300 | + 'examples' => array( |
|
| 301 | + 'Foo' => array( |
|
| 302 | + 'bar' => 'baz', |
|
| 303 | + ), |
|
| 304 | + ), |
|
| 305 | + ), $object->toArray()); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 310 | + */ |
|
| 311 | + public function testCommand_Example_Json_Whitespace() |
|
| 312 | + { |
|
| 313 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 314 | + |
|
| 315 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 316 | + |
|
| 317 | + $object->handleCommand('example', 'Foo { "bar" : "baz" } '); |
|
| 318 | + |
|
| 319 | + $this->assertSame(array( |
|
| 320 | + 'description' => 'OK', |
|
| 321 | + 'examples' => array( |
|
| 322 | + 'Foo' => array( |
|
| 323 | + 'bar' => 'baz', |
|
| 324 | + ), |
|
| 325 | + ), |
|
| 326 | + ), $object->toArray()); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * @covers \SwaggerGen\Swagger\Type\Response->handleCommand |
|
| 331 | + */ |
|
| 332 | + public function testCommand_Example_Json_Multiple() |
|
| 333 | + { |
|
| 334 | + $object = new \SwaggerGen\Swagger\Response($this->parent, 200); |
|
| 335 | + |
|
| 336 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $object); |
|
| 337 | + |
|
| 338 | + $object->handleCommand('example', 'Foo "Bar" '); |
|
| 339 | + $object->handleCommand('example', 'Baz false'); |
|
| 340 | + |
|
| 341 | + $this->assertSame(array( |
|
| 342 | + 'description' => 'OK', |
|
| 343 | + 'examples' => array( |
|
| 344 | + 'Foo' => 'Bar', |
|
| 345 | + 'Baz' => false, |
|
| 346 | + ), |
|
| 347 | + ), $object->toArray()); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 352 | + */ |
|
| 353 | + public function testGetCode_Numeric() |
|
| 354 | + { |
|
| 355 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode(200)); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 360 | + */ |
|
| 361 | + public function testGetCode_CaseSensitive() |
|
| 362 | + { |
|
| 363 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('OK')); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 368 | + */ |
|
| 369 | + public function testGetCode_CaseInsensitive() |
|
| 370 | + { |
|
| 371 | + $this->assertSame(200, \SwaggerGen\Swagger\Response::getCode('ok')); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 376 | + */ |
|
| 377 | + public function testGetCode_Space() |
|
| 378 | + { |
|
| 379 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('not Found')); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 384 | + */ |
|
| 385 | + public function testGetCode_Crap() |
|
| 386 | + { |
|
| 387 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode(' not___F-ou/nd ')); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * @covers \SwaggerGen\Swagger\Type\Response->getCode |
|
| 392 | + */ |
|
| 393 | + public function testGetCode_Smashed() |
|
| 394 | + { |
|
| 395 | + $this->assertSame(404, \SwaggerGen\Swagger\Response::getCode('nOtfOund')); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + protected function setUp(): void |
|
| 399 | + { |
|
| 400 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + protected function assertPreConditions(): void |
|
| 404 | + { |
|
| 405 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | 408 | } |
@@ -6,494 +6,494 @@ |
||
| 6 | 6 | class SecuritySchemeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructor_UnknownType() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'"); |
|
| 17 | - |
|
| 18 | - new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstructor_Basic() |
|
| 25 | - { |
|
| 26 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
| 27 | - |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array( |
|
| 31 | - 'type' => 'basic', |
|
| 32 | - ), $object->toArray()); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 37 | - */ |
|
| 38 | - public function testConstructor_BasicDescription() |
|
| 39 | - { |
|
| 40 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text'); |
|
| 41 | - |
|
| 42 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 43 | - |
|
| 44 | - $this->assertSame(array( |
|
| 45 | - 'type' => 'basic', |
|
| 46 | - 'description' => 'Some text', |
|
| 47 | - ), $object->toArray()); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 52 | - */ |
|
| 53 | - public function testConstructor_ApiKeyNoName() |
|
| 54 | - { |
|
| 55 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''" |
|
| 56 | - ); |
|
| 57 | - |
|
| 58 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 63 | - */ |
|
| 64 | - public function testConstructor_ApiKeyNoIn() |
|
| 65 | - { |
|
| 66 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"); |
|
| 67 | - |
|
| 68 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name'); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 73 | - */ |
|
| 74 | - public function testConstructor_ApiKeyWrongIn() |
|
| 75 | - { |
|
| 76 | - $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'"); |
|
| 77 | - |
|
| 78 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad'); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 83 | - */ |
|
| 84 | - public function testConstructor_ApiKey() |
|
| 85 | - { |
|
| 86 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query'); |
|
| 87 | - |
|
| 88 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 89 | - |
|
| 90 | - $this->assertSame(array( |
|
| 91 | - 'type' => 'apiKey', |
|
| 92 | - 'name' => 'Name', |
|
| 93 | - 'in' => 'query', |
|
| 94 | - ), $object->toArray()); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 99 | - */ |
|
| 100 | - public function testConstructor_ApiKeyDescription() |
|
| 101 | - { |
|
| 102 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words'); |
|
| 103 | - |
|
| 104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 105 | - |
|
| 106 | - $this->assertSame(array( |
|
| 107 | - 'type' => 'apiKey', |
|
| 108 | - 'description' => 'Some words', |
|
| 109 | - 'name' => 'Name', |
|
| 110 | - 'in' => 'query', |
|
| 111 | - ), $object->toArray()); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 116 | - */ |
|
| 117 | - public function testConstructor_Oauth2NoFlow() |
|
| 118 | - { |
|
| 119 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''"); |
|
| 120 | - |
|
| 121 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2'); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 126 | - */ |
|
| 127 | - public function testConstructor_Oauth2WrongFlow() |
|
| 128 | - { |
|
| 129 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'"); |
|
| 130 | - |
|
| 131 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow'); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 136 | - */ |
|
| 137 | - public function testConstructor_Oauth2ImplicitNoUrl() |
|
| 138 | - { |
|
| 139 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
| 140 | - |
|
| 141 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit'); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 146 | - */ |
|
| 147 | - public function testConstructor_Oauth2ImplicitBadUrl() |
|
| 148 | - { |
|
| 149 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
| 150 | - |
|
| 151 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad'); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 156 | - */ |
|
| 157 | - public function testConstructor_Oauth2ImplicitUrl() |
|
| 158 | - { |
|
| 159 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test'); |
|
| 160 | - |
|
| 161 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 162 | - |
|
| 163 | - $this->assertSame(array( |
|
| 164 | - 'type' => 'oauth2', |
|
| 165 | - 'flow' => 'implicit', |
|
| 166 | - 'authorizationUrl' => 'http://www.test', |
|
| 167 | - ), $object->toArray()); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 172 | - */ |
|
| 173 | - public function testConstructor_Oauth2ImplicitUrlDescription() |
|
| 174 | - { |
|
| 175 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words'); |
|
| 176 | - |
|
| 177 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 178 | - |
|
| 179 | - $this->assertSame(array( |
|
| 180 | - 'type' => 'oauth2', |
|
| 181 | - 'description' => 'Some words', |
|
| 182 | - 'flow' => 'implicit', |
|
| 183 | - 'authorizationUrl' => 'http://www.test', |
|
| 184 | - ), $object->toArray()); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 189 | - */ |
|
| 190 | - public function testConstructor_Oauth2PasswordNoUrl() |
|
| 191 | - { |
|
| 192 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 193 | - |
|
| 194 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password'); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 199 | - */ |
|
| 200 | - public function testConstructor_Oauth2PasswordBadUrl() |
|
| 201 | - { |
|
| 202 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 203 | - |
|
| 204 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad'); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 209 | - */ |
|
| 210 | - public function testConstructor_Oauth2Password() |
|
| 211 | - { |
|
| 212 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test'); |
|
| 213 | - |
|
| 214 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 215 | - |
|
| 216 | - $this->assertSame(array( |
|
| 217 | - 'type' => 'oauth2', |
|
| 218 | - 'flow' => 'password', |
|
| 219 | - 'tokenUrl' => 'http://token.test', |
|
| 220 | - ), $object->toArray()); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 225 | - */ |
|
| 226 | - public function testConstructor_Oauth2PasswordDescription() |
|
| 227 | - { |
|
| 228 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words'); |
|
| 229 | - |
|
| 230 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 231 | - |
|
| 232 | - $this->assertSame(array( |
|
| 233 | - 'type' => 'oauth2', |
|
| 234 | - 'description' => 'Some words', |
|
| 235 | - 'flow' => 'password', |
|
| 236 | - 'tokenUrl' => 'http://token.test', |
|
| 237 | - ), $object->toArray()); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 242 | - */ |
|
| 243 | - public function testConstructor_Oauth2ApplicationNoUrl() |
|
| 244 | - { |
|
| 245 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 246 | - |
|
| 247 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application'); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 252 | - */ |
|
| 253 | - public function testConstructor_Oauth2ApplicationBadUrl() |
|
| 254 | - { |
|
| 255 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 256 | - |
|
| 257 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad'); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 262 | - */ |
|
| 263 | - public function testConstructor_Oauth2Application() |
|
| 264 | - { |
|
| 265 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test'); |
|
| 266 | - |
|
| 267 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 268 | - |
|
| 269 | - $this->assertSame(array( |
|
| 270 | - 'type' => 'oauth2', |
|
| 271 | - 'flow' => 'application', |
|
| 272 | - 'tokenUrl' => 'http://token.test', |
|
| 273 | - ), $object->toArray()); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 278 | - */ |
|
| 279 | - public function testConstructor_Oauth2ApplicationDescription() |
|
| 280 | - { |
|
| 281 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words'); |
|
| 282 | - |
|
| 283 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 284 | - |
|
| 285 | - $this->assertSame(array( |
|
| 286 | - 'type' => 'oauth2', |
|
| 287 | - 'description' => 'Some words', |
|
| 288 | - 'flow' => 'application', |
|
| 289 | - 'tokenUrl' => 'http://token.test', |
|
| 290 | - ), $object->toArray()); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 295 | - */ |
|
| 296 | - public function testConstructor_Oauth2AccesscodeNoUrl1() |
|
| 297 | - { |
|
| 298 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
| 299 | - |
|
| 300 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode'); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 305 | - */ |
|
| 306 | - public function testConstructor_Oauth2AccesscodeBadUrl1() |
|
| 307 | - { |
|
| 308 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
| 309 | - |
|
| 310 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad'); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 315 | - */ |
|
| 316 | - public function testConstructor_Oauth2AccesscodeNoUrl2() |
|
| 317 | - { |
|
| 318 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 319 | - |
|
| 320 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test'); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 325 | - */ |
|
| 326 | - public function testConstructor_Oauth2AccesscodeBadUrl2() |
|
| 327 | - { |
|
| 328 | - $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 329 | - |
|
| 330 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad'); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 335 | - */ |
|
| 336 | - public function testConstructor_Oauth2Accesscode() |
|
| 337 | - { |
|
| 338 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 339 | - |
|
| 340 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 341 | - |
|
| 342 | - $this->assertSame(array( |
|
| 343 | - 'type' => 'oauth2', |
|
| 344 | - 'flow' => 'accessCode', |
|
| 345 | - 'authorizationUrl' => 'http://auth.test', |
|
| 346 | - 'tokenUrl' => 'http://token.test', |
|
| 347 | - ), $object->toArray()); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 352 | - */ |
|
| 353 | - public function testConstructor_Oauth2AccesscodeDescription() |
|
| 354 | - { |
|
| 355 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
| 356 | - |
|
| 357 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 358 | - |
|
| 359 | - $this->assertSame(array( |
|
| 360 | - 'type' => 'oauth2', |
|
| 361 | - 'description' => 'Some words', |
|
| 362 | - 'flow' => 'accessCode', |
|
| 363 | - 'authorizationUrl' => 'http://auth.test', |
|
| 364 | - 'tokenUrl' => 'http://token.test', |
|
| 365 | - ), $object->toArray()); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 370 | - */ |
|
| 371 | - public function testCommandDescription() |
|
| 372 | - { |
|
| 373 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 374 | - |
|
| 375 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 376 | - |
|
| 377 | - $object->handleCommand('description', 'Some words'); |
|
| 378 | - |
|
| 379 | - $this->assertSame(array( |
|
| 380 | - 'type' => 'oauth2', |
|
| 381 | - 'description' => 'Some words', |
|
| 382 | - 'flow' => 'accessCode', |
|
| 383 | - 'authorizationUrl' => 'http://auth.test', |
|
| 384 | - 'tokenUrl' => 'http://token.test', |
|
| 385 | - ), $object->toArray()); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 390 | - */ |
|
| 391 | - public function testCommandDescriptionEmpty() |
|
| 392 | - { |
|
| 393 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
| 394 | - |
|
| 395 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 396 | - |
|
| 397 | - $object->handleCommand('description', ''); |
|
| 398 | - |
|
| 399 | - $this->assertSame(array( |
|
| 400 | - 'type' => 'oauth2', |
|
| 401 | - 'flow' => 'accessCode', |
|
| 402 | - 'authorizationUrl' => 'http://auth.test', |
|
| 403 | - 'tokenUrl' => 'http://token.test', |
|
| 404 | - ), $object->toArray()); |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 409 | - */ |
|
| 410 | - public function testCommandScopeNotOauth() |
|
| 411 | - { |
|
| 412 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
| 413 | - |
|
| 414 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 415 | - |
|
| 416 | - $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'"); |
|
| 417 | - |
|
| 418 | - $object->handleCommand('scope', 'scope1'); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 423 | - */ |
|
| 424 | - public function testCommandScope() |
|
| 425 | - { |
|
| 426 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 427 | - |
|
| 428 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 429 | - |
|
| 430 | - $object->handleCommand('scope', 'scope1'); |
|
| 431 | - |
|
| 432 | - $this->assertSame(array( |
|
| 433 | - 'type' => 'oauth2', |
|
| 434 | - 'flow' => 'accessCode', |
|
| 435 | - 'authorizationUrl' => 'http://auth.test', |
|
| 436 | - 'tokenUrl' => 'http://token.test', |
|
| 437 | - 'scopes' => array( |
|
| 438 | - 'scope1' => '', |
|
| 439 | - ) |
|
| 440 | - ), $object->toArray()); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 445 | - */ |
|
| 446 | - public function testCommandScopeDescription() |
|
| 447 | - { |
|
| 448 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 449 | - |
|
| 450 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 451 | - |
|
| 452 | - $object->handleCommand('scope', 'scope1 Some text'); |
|
| 453 | - |
|
| 454 | - $this->assertSame(array( |
|
| 455 | - 'type' => 'oauth2', |
|
| 456 | - 'flow' => 'accessCode', |
|
| 457 | - 'authorizationUrl' => 'http://auth.test', |
|
| 458 | - 'tokenUrl' => 'http://token.test', |
|
| 459 | - 'scopes' => array( |
|
| 460 | - 'scope1' => 'Some text', |
|
| 461 | - ) |
|
| 462 | - ), $object->toArray()); |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 467 | - */ |
|
| 468 | - public function testCommandScopes() |
|
| 469 | - { |
|
| 470 | - $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 471 | - |
|
| 472 | - $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 473 | - |
|
| 474 | - $object->handleCommand('scope', 'scope2 Some text'); |
|
| 475 | - $object->handleCommand('scope', 'scope1 Some text'); |
|
| 476 | - |
|
| 477 | - $this->assertSame(array( |
|
| 478 | - 'type' => 'oauth2', |
|
| 479 | - 'flow' => 'accessCode', |
|
| 480 | - 'authorizationUrl' => 'http://auth.test', |
|
| 481 | - 'tokenUrl' => 'http://token.test', |
|
| 482 | - 'scopes' => array( |
|
| 483 | - 'scope2' => 'Some text', |
|
| 484 | - 'scope1' => 'Some text', |
|
| 485 | - ) |
|
| 486 | - ), $object->toArray()); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - protected function setUp(): void |
|
| 490 | - { |
|
| 491 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - protected function assertPreConditions(): void |
|
| 495 | - { |
|
| 496 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 497 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructor_UnknownType() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Security scheme type must be either 'basic', 'apiKey' or 'oauth2', not 'wrong'"); |
|
| 17 | + |
|
| 18 | + new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstructor_Basic() |
|
| 25 | + { |
|
| 26 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
| 27 | + |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array( |
|
| 31 | + 'type' => 'basic', |
|
| 32 | + ), $object->toArray()); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 37 | + */ |
|
| 38 | + public function testConstructor_BasicDescription() |
|
| 39 | + { |
|
| 40 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic', 'Some text'); |
|
| 41 | + |
|
| 42 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 43 | + |
|
| 44 | + $this->assertSame(array( |
|
| 45 | + 'type' => 'basic', |
|
| 46 | + 'description' => 'Some text', |
|
| 47 | + ), $object->toArray()); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 52 | + */ |
|
| 53 | + public function testConstructor_ApiKeyNoName() |
|
| 54 | + { |
|
| 55 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''" |
|
| 56 | + ); |
|
| 57 | + |
|
| 58 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 63 | + */ |
|
| 64 | + public function testConstructor_ApiKeyNoIn() |
|
| 65 | + { |
|
| 66 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not ''"); |
|
| 67 | + |
|
| 68 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name'); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 73 | + */ |
|
| 74 | + public function testConstructor_ApiKeyWrongIn() |
|
| 75 | + { |
|
| 76 | + $this->expectException('\SwaggerGen\Exception', "ApiKey in must be either 'query' or 'header', not 'bad'"); |
|
| 77 | + |
|
| 78 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name bad'); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 83 | + */ |
|
| 84 | + public function testConstructor_ApiKey() |
|
| 85 | + { |
|
| 86 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query'); |
|
| 87 | + |
|
| 88 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 89 | + |
|
| 90 | + $this->assertSame(array( |
|
| 91 | + 'type' => 'apiKey', |
|
| 92 | + 'name' => 'Name', |
|
| 93 | + 'in' => 'query', |
|
| 94 | + ), $object->toArray()); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 99 | + */ |
|
| 100 | + public function testConstructor_ApiKeyDescription() |
|
| 101 | + { |
|
| 102 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'apikey', 'Name query Some words'); |
|
| 103 | + |
|
| 104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 105 | + |
|
| 106 | + $this->assertSame(array( |
|
| 107 | + 'type' => 'apiKey', |
|
| 108 | + 'description' => 'Some words', |
|
| 109 | + 'name' => 'Name', |
|
| 110 | + 'in' => 'query', |
|
| 111 | + ), $object->toArray()); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 116 | + */ |
|
| 117 | + public function testConstructor_Oauth2NoFlow() |
|
| 118 | + { |
|
| 119 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not ''"); |
|
| 120 | + |
|
| 121 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2'); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 126 | + */ |
|
| 127 | + public function testConstructor_Oauth2WrongFlow() |
|
| 128 | + { |
|
| 129 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 flow must be either 'implicit', 'password', 'application' or 'accesscode', not 'flow'"); |
|
| 130 | + |
|
| 131 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'flow'); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 136 | + */ |
|
| 137 | + public function testConstructor_Oauth2ImplicitNoUrl() |
|
| 138 | + { |
|
| 139 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
| 140 | + |
|
| 141 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit'); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 146 | + */ |
|
| 147 | + public function testConstructor_Oauth2ImplicitBadUrl() |
|
| 148 | + { |
|
| 149 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
| 150 | + |
|
| 151 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit bad'); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 156 | + */ |
|
| 157 | + public function testConstructor_Oauth2ImplicitUrl() |
|
| 158 | + { |
|
| 159 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test'); |
|
| 160 | + |
|
| 161 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 162 | + |
|
| 163 | + $this->assertSame(array( |
|
| 164 | + 'type' => 'oauth2', |
|
| 165 | + 'flow' => 'implicit', |
|
| 166 | + 'authorizationUrl' => 'http://www.test', |
|
| 167 | + ), $object->toArray()); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 172 | + */ |
|
| 173 | + public function testConstructor_Oauth2ImplicitUrlDescription() |
|
| 174 | + { |
|
| 175 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'implicit http://www.test Some words'); |
|
| 176 | + |
|
| 177 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 178 | + |
|
| 179 | + $this->assertSame(array( |
|
| 180 | + 'type' => 'oauth2', |
|
| 181 | + 'description' => 'Some words', |
|
| 182 | + 'flow' => 'implicit', |
|
| 183 | + 'authorizationUrl' => 'http://www.test', |
|
| 184 | + ), $object->toArray()); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 189 | + */ |
|
| 190 | + public function testConstructor_Oauth2PasswordNoUrl() |
|
| 191 | + { |
|
| 192 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 193 | + |
|
| 194 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password'); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 199 | + */ |
|
| 200 | + public function testConstructor_Oauth2PasswordBadUrl() |
|
| 201 | + { |
|
| 202 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 203 | + |
|
| 204 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password bad'); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 209 | + */ |
|
| 210 | + public function testConstructor_Oauth2Password() |
|
| 211 | + { |
|
| 212 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test'); |
|
| 213 | + |
|
| 214 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 215 | + |
|
| 216 | + $this->assertSame(array( |
|
| 217 | + 'type' => 'oauth2', |
|
| 218 | + 'flow' => 'password', |
|
| 219 | + 'tokenUrl' => 'http://token.test', |
|
| 220 | + ), $object->toArray()); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 225 | + */ |
|
| 226 | + public function testConstructor_Oauth2PasswordDescription() |
|
| 227 | + { |
|
| 228 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'password http://token.test Some words'); |
|
| 229 | + |
|
| 230 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 231 | + |
|
| 232 | + $this->assertSame(array( |
|
| 233 | + 'type' => 'oauth2', |
|
| 234 | + 'description' => 'Some words', |
|
| 235 | + 'flow' => 'password', |
|
| 236 | + 'tokenUrl' => 'http://token.test', |
|
| 237 | + ), $object->toArray()); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 242 | + */ |
|
| 243 | + public function testConstructor_Oauth2ApplicationNoUrl() |
|
| 244 | + { |
|
| 245 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 246 | + |
|
| 247 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application'); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 252 | + */ |
|
| 253 | + public function testConstructor_Oauth2ApplicationBadUrl() |
|
| 254 | + { |
|
| 255 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 256 | + |
|
| 257 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application bad'); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 262 | + */ |
|
| 263 | + public function testConstructor_Oauth2Application() |
|
| 264 | + { |
|
| 265 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test'); |
|
| 266 | + |
|
| 267 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 268 | + |
|
| 269 | + $this->assertSame(array( |
|
| 270 | + 'type' => 'oauth2', |
|
| 271 | + 'flow' => 'application', |
|
| 272 | + 'tokenUrl' => 'http://token.test', |
|
| 273 | + ), $object->toArray()); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 278 | + */ |
|
| 279 | + public function testConstructor_Oauth2ApplicationDescription() |
|
| 280 | + { |
|
| 281 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'application http://token.test Some words'); |
|
| 282 | + |
|
| 283 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 284 | + |
|
| 285 | + $this->assertSame(array( |
|
| 286 | + 'type' => 'oauth2', |
|
| 287 | + 'description' => 'Some words', |
|
| 288 | + 'flow' => 'application', |
|
| 289 | + 'tokenUrl' => 'http://token.test', |
|
| 290 | + ), $object->toArray()); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 295 | + */ |
|
| 296 | + public function testConstructor_Oauth2AccesscodeNoUrl1() |
|
| 297 | + { |
|
| 298 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: ''"); |
|
| 299 | + |
|
| 300 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode'); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 305 | + */ |
|
| 306 | + public function testConstructor_Oauth2AccesscodeBadUrl1() |
|
| 307 | + { |
|
| 308 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 authorization URL invalid: 'bad'"); |
|
| 309 | + |
|
| 310 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode bad'); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 315 | + */ |
|
| 316 | + public function testConstructor_Oauth2AccesscodeNoUrl2() |
|
| 317 | + { |
|
| 318 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: ''"); |
|
| 319 | + |
|
| 320 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test'); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 325 | + */ |
|
| 326 | + public function testConstructor_Oauth2AccesscodeBadUrl2() |
|
| 327 | + { |
|
| 328 | + $this->expectException('\SwaggerGen\Exception', "OAuth2 token URL invalid: 'bad'"); |
|
| 329 | + |
|
| 330 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test bad'); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 335 | + */ |
|
| 336 | + public function testConstructor_Oauth2Accesscode() |
|
| 337 | + { |
|
| 338 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 339 | + |
|
| 340 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 341 | + |
|
| 342 | + $this->assertSame(array( |
|
| 343 | + 'type' => 'oauth2', |
|
| 344 | + 'flow' => 'accessCode', |
|
| 345 | + 'authorizationUrl' => 'http://auth.test', |
|
| 346 | + 'tokenUrl' => 'http://token.test', |
|
| 347 | + ), $object->toArray()); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * @covers \SwaggerGen\Swagger\SecurityScheme::__construct |
|
| 352 | + */ |
|
| 353 | + public function testConstructor_Oauth2AccesscodeDescription() |
|
| 354 | + { |
|
| 355 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
| 356 | + |
|
| 357 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 358 | + |
|
| 359 | + $this->assertSame(array( |
|
| 360 | + 'type' => 'oauth2', |
|
| 361 | + 'description' => 'Some words', |
|
| 362 | + 'flow' => 'accessCode', |
|
| 363 | + 'authorizationUrl' => 'http://auth.test', |
|
| 364 | + 'tokenUrl' => 'http://token.test', |
|
| 365 | + ), $object->toArray()); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 370 | + */ |
|
| 371 | + public function testCommandDescription() |
|
| 372 | + { |
|
| 373 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 374 | + |
|
| 375 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 376 | + |
|
| 377 | + $object->handleCommand('description', 'Some words'); |
|
| 378 | + |
|
| 379 | + $this->assertSame(array( |
|
| 380 | + 'type' => 'oauth2', |
|
| 381 | + 'description' => 'Some words', |
|
| 382 | + 'flow' => 'accessCode', |
|
| 383 | + 'authorizationUrl' => 'http://auth.test', |
|
| 384 | + 'tokenUrl' => 'http://token.test', |
|
| 385 | + ), $object->toArray()); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 390 | + */ |
|
| 391 | + public function testCommandDescriptionEmpty() |
|
| 392 | + { |
|
| 393 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test Some words'); |
|
| 394 | + |
|
| 395 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 396 | + |
|
| 397 | + $object->handleCommand('description', ''); |
|
| 398 | + |
|
| 399 | + $this->assertSame(array( |
|
| 400 | + 'type' => 'oauth2', |
|
| 401 | + 'flow' => 'accessCode', |
|
| 402 | + 'authorizationUrl' => 'http://auth.test', |
|
| 403 | + 'tokenUrl' => 'http://token.test', |
|
| 404 | + ), $object->toArray()); |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 409 | + */ |
|
| 410 | + public function testCommandScopeNotOauth() |
|
| 411 | + { |
|
| 412 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'basic'); |
|
| 413 | + |
|
| 414 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 415 | + |
|
| 416 | + $this->expectException('\SwaggerGen\Exception', "Cannot set scope on type 'basic'"); |
|
| 417 | + |
|
| 418 | + $object->handleCommand('scope', 'scope1'); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 423 | + */ |
|
| 424 | + public function testCommandScope() |
|
| 425 | + { |
|
| 426 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 427 | + |
|
| 428 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 429 | + |
|
| 430 | + $object->handleCommand('scope', 'scope1'); |
|
| 431 | + |
|
| 432 | + $this->assertSame(array( |
|
| 433 | + 'type' => 'oauth2', |
|
| 434 | + 'flow' => 'accessCode', |
|
| 435 | + 'authorizationUrl' => 'http://auth.test', |
|
| 436 | + 'tokenUrl' => 'http://token.test', |
|
| 437 | + 'scopes' => array( |
|
| 438 | + 'scope1' => '', |
|
| 439 | + ) |
|
| 440 | + ), $object->toArray()); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 445 | + */ |
|
| 446 | + public function testCommandScopeDescription() |
|
| 447 | + { |
|
| 448 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 449 | + |
|
| 450 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 451 | + |
|
| 452 | + $object->handleCommand('scope', 'scope1 Some text'); |
|
| 453 | + |
|
| 454 | + $this->assertSame(array( |
|
| 455 | + 'type' => 'oauth2', |
|
| 456 | + 'flow' => 'accessCode', |
|
| 457 | + 'authorizationUrl' => 'http://auth.test', |
|
| 458 | + 'tokenUrl' => 'http://token.test', |
|
| 459 | + 'scopes' => array( |
|
| 460 | + 'scope1' => 'Some text', |
|
| 461 | + ) |
|
| 462 | + ), $object->toArray()); |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * @covers \SwaggerGen\Swagger\SecurityScheme->handleCommand |
|
| 467 | + */ |
|
| 468 | + public function testCommandScopes() |
|
| 469 | + { |
|
| 470 | + $object = new \SwaggerGen\Swagger\SecurityScheme($this->parent, 'oauth2', 'accesscode http://auth.test http://token.test'); |
|
| 471 | + |
|
| 472 | + $this->assertInstanceOf('\SwaggerGen\Swagger\SecurityScheme', $object); |
|
| 473 | + |
|
| 474 | + $object->handleCommand('scope', 'scope2 Some text'); |
|
| 475 | + $object->handleCommand('scope', 'scope1 Some text'); |
|
| 476 | + |
|
| 477 | + $this->assertSame(array( |
|
| 478 | + 'type' => 'oauth2', |
|
| 479 | + 'flow' => 'accessCode', |
|
| 480 | + 'authorizationUrl' => 'http://auth.test', |
|
| 481 | + 'tokenUrl' => 'http://token.test', |
|
| 482 | + 'scopes' => array( |
|
| 483 | + 'scope2' => 'Some text', |
|
| 484 | + 'scope1' => 'Some text', |
|
| 485 | + ) |
|
| 486 | + ), $object->toArray()); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + protected function setUp(): void |
|
| 490 | + { |
|
| 491 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + protected function assertPreConditions(): void |
|
| 495 | + { |
|
| 496 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | 499 | } |
@@ -6,65 +6,65 @@ |
||
| 6 | 6 | class AbstractDocumentableObjectTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 13 | - * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand |
|
| 14 | - */ |
|
| 15 | - public function testCommandDocWithoutDescription() |
|
| 16 | - { |
|
| 17 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 18 | - |
|
| 19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 20 | - |
|
| 21 | - $this->assertSame(array( |
|
| 22 | - 'name' => 'Name', |
|
| 23 | - ), $object->toArray()); |
|
| 24 | - |
|
| 25 | - $object->handleCommand('doc', 'http://example.test'); |
|
| 26 | - |
|
| 27 | - $this->assertSame(array( |
|
| 28 | - 'name' => 'Name', |
|
| 29 | - 'externalDocs' => array( |
|
| 30 | - 'url' => 'http://example.test', |
|
| 31 | - ), |
|
| 32 | - ), $object->toArray()); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 37 | - * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand |
|
| 38 | - */ |
|
| 39 | - public function testCommandDocWithDescription() |
|
| 40 | - { |
|
| 41 | - $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 42 | - |
|
| 43 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 44 | - |
|
| 45 | - $this->assertSame(array( |
|
| 46 | - 'name' => 'Name', |
|
| 47 | - ), $object->toArray()); |
|
| 48 | - |
|
| 49 | - $object->handleCommand('doc', 'http://example.test Some words here'); |
|
| 50 | - |
|
| 51 | - $this->assertSame(array( |
|
| 52 | - 'name' => 'Name', |
|
| 53 | - 'externalDocs' => array( |
|
| 54 | - 'url' => 'http://example.test', |
|
| 55 | - 'description' => 'Some words here', |
|
| 56 | - ), |
|
| 57 | - ), $object->toArray()); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - protected function setUp(): void |
|
| 61 | - { |
|
| 62 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - protected function assertPreConditions(): void |
|
| 66 | - { |
|
| 67 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 68 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 13 | + * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand |
|
| 14 | + */ |
|
| 15 | + public function testCommandDocWithoutDescription() |
|
| 16 | + { |
|
| 17 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 18 | + |
|
| 19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 20 | + |
|
| 21 | + $this->assertSame(array( |
|
| 22 | + 'name' => 'Name', |
|
| 23 | + ), $object->toArray()); |
|
| 24 | + |
|
| 25 | + $object->handleCommand('doc', 'http://example.test'); |
|
| 26 | + |
|
| 27 | + $this->assertSame(array( |
|
| 28 | + 'name' => 'Name', |
|
| 29 | + 'externalDocs' => array( |
|
| 30 | + 'url' => 'http://example.test', |
|
| 31 | + ), |
|
| 32 | + ), $object->toArray()); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @covers \SwaggerGen\Swagger\Tag::__construct |
|
| 37 | + * @covers \SwaggerGen\Swagger\AbstractDocumentableObject->handleCommand |
|
| 38 | + */ |
|
| 39 | + public function testCommandDocWithDescription() |
|
| 40 | + { |
|
| 41 | + $object = new \SwaggerGen\Swagger\Tag($this->parent, 'Name'); |
|
| 42 | + |
|
| 43 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Tag', $object); |
|
| 44 | + |
|
| 45 | + $this->assertSame(array( |
|
| 46 | + 'name' => 'Name', |
|
| 47 | + ), $object->toArray()); |
|
| 48 | + |
|
| 49 | + $object->handleCommand('doc', 'http://example.test Some words here'); |
|
| 50 | + |
|
| 51 | + $this->assertSame(array( |
|
| 52 | + 'name' => 'Name', |
|
| 53 | + 'externalDocs' => array( |
|
| 54 | + 'url' => 'http://example.test', |
|
| 55 | + 'description' => 'Some words here', |
|
| 56 | + ), |
|
| 57 | + ), $object->toArray()); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + protected function setUp(): void |
|
| 61 | + { |
|
| 62 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + protected function assertPreConditions(): void |
|
| 66 | + { |
|
| 67 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | } |
@@ -6,232 +6,232 @@ |
||
| 6 | 6 | class PathTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructor_Empty() |
|
| 15 | - { |
|
| 16 | - $object = new \SwaggerGen\Swagger\Path($this->parent); |
|
| 17 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 18 | - |
|
| 19 | - $this->assertSame(array(), $object->toArray()); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 24 | - */ |
|
| 25 | - public function testConstructor_Tag() |
|
| 26 | - { |
|
| 27 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array(), $object->toArray()); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 35 | - */ |
|
| 36 | - public function testHandleCommand_Method_Empty() |
|
| 37 | - { |
|
| 38 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 39 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 40 | - |
|
| 41 | - $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''"); |
|
| 42 | - $return = $object->handleCommand('method'); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 47 | - */ |
|
| 48 | - public function testHandleCommand_Method_Unknown() |
|
| 49 | - { |
|
| 50 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 51 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 52 | - |
|
| 53 | - $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'"); |
|
| 54 | - $return = $object->handleCommand('method', 'foo'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 59 | - */ |
|
| 60 | - public function testHandleCommand_Method_Get() |
|
| 61 | - { |
|
| 62 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 64 | - |
|
| 65 | - $operation = $object->handleCommand('method', 'get'); |
|
| 66 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 67 | - $operation->handleCommand('response', 200); |
|
| 68 | - |
|
| 69 | - $this->assertSame(array( |
|
| 70 | - 'get' => array( |
|
| 71 | - 'tags' => array( |
|
| 72 | - 'Tag', |
|
| 73 | - ), |
|
| 74 | - 'responses' => array( |
|
| 75 | - 200 => array( |
|
| 76 | - 'description' => 'OK', |
|
| 77 | - ), |
|
| 78 | - ), |
|
| 79 | - ), |
|
| 80 | - ), $object->toArray()); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 85 | - */ |
|
| 86 | - public function testHandleCommand_Method_Description() |
|
| 87 | - { |
|
| 88 | - $this->markTestIncomplete('This test has not been implemented yet.'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 93 | - */ |
|
| 94 | - public function testHandleCommand_Operation_Get() |
|
| 95 | - { |
|
| 96 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 97 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 98 | - |
|
| 99 | - $operation = $object->handleCommand('operation', 'get'); |
|
| 100 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 101 | - $operation->handleCommand('response', 200); |
|
| 102 | - |
|
| 103 | - $this->assertSame(array( |
|
| 104 | - 'get' => array( |
|
| 105 | - 'tags' => array( |
|
| 106 | - 'Tag', |
|
| 107 | - ), |
|
| 108 | - 'responses' => array( |
|
| 109 | - 200 => array( |
|
| 110 | - 'description' => 'OK', |
|
| 111 | - ), |
|
| 112 | - ), |
|
| 113 | - ), |
|
| 114 | - ), $object->toArray()); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 119 | - */ |
|
| 120 | - public function testHandleCommand_MethodOrdering() |
|
| 121 | - { |
|
| 122 | - $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 123 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 124 | - |
|
| 125 | - $operation = $object->handleCommand('method', 'post'); |
|
| 126 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 127 | - $operation->handleCommand('response', 200); |
|
| 128 | - |
|
| 129 | - $operation = $object->handleCommand('method', 'delete'); |
|
| 130 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 131 | - $operation->handleCommand('response', 200); |
|
| 132 | - |
|
| 133 | - $operation = $object->handleCommand('method', 'patch'); |
|
| 134 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 135 | - $operation->handleCommand('response', 200); |
|
| 136 | - |
|
| 137 | - $operation = $object->handleCommand('method', 'put'); |
|
| 138 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 139 | - $operation->handleCommand('response', 200); |
|
| 140 | - |
|
| 141 | - $operation = $object->handleCommand('method', 'head'); |
|
| 142 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 143 | - $operation->handleCommand('response', 200); |
|
| 144 | - |
|
| 145 | - $operation = $object->handleCommand('method', 'get'); |
|
| 146 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 147 | - $operation->handleCommand('response', 200); |
|
| 148 | - |
|
| 149 | - $operation = $object->handleCommand('method', 'options'); |
|
| 150 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 151 | - $operation->handleCommand('response', 200); |
|
| 152 | - |
|
| 153 | - $this->assertSame(array( |
|
| 154 | - 'get' => array( |
|
| 155 | - 'tags' => array( |
|
| 156 | - 'Tag', |
|
| 157 | - ), |
|
| 158 | - 'responses' => array( |
|
| 159 | - 200 => array( |
|
| 160 | - 'description' => 'OK', |
|
| 161 | - ), |
|
| 162 | - ), |
|
| 163 | - ), |
|
| 164 | - 'put' => array( |
|
| 165 | - 'tags' => array( |
|
| 166 | - 'Tag', |
|
| 167 | - ), |
|
| 168 | - 'responses' => array( |
|
| 169 | - 200 => array( |
|
| 170 | - 'description' => 'OK', |
|
| 171 | - ), |
|
| 172 | - ), |
|
| 173 | - ), |
|
| 174 | - 'post' => array( |
|
| 175 | - 'tags' => array( |
|
| 176 | - 'Tag', |
|
| 177 | - ), |
|
| 178 | - 'responses' => array( |
|
| 179 | - 200 => array( |
|
| 180 | - 'description' => 'OK', |
|
| 181 | - ), |
|
| 182 | - ), |
|
| 183 | - ), |
|
| 184 | - 'delete' => array( |
|
| 185 | - 'tags' => array( |
|
| 186 | - 'Tag', |
|
| 187 | - ), |
|
| 188 | - 'responses' => array( |
|
| 189 | - 200 => array( |
|
| 190 | - 'description' => 'OK', |
|
| 191 | - ), |
|
| 192 | - ), |
|
| 193 | - ), |
|
| 194 | - 'options' => array( |
|
| 195 | - 'tags' => array( |
|
| 196 | - 'Tag', |
|
| 197 | - ), |
|
| 198 | - 'responses' => array( |
|
| 199 | - 200 => array( |
|
| 200 | - 'description' => 'OK', |
|
| 201 | - ), |
|
| 202 | - ), |
|
| 203 | - ), |
|
| 204 | - 'head' => array( |
|
| 205 | - 'tags' => array( |
|
| 206 | - 'Tag', |
|
| 207 | - ), |
|
| 208 | - 'responses' => array( |
|
| 209 | - 200 => array( |
|
| 210 | - 'description' => 'OK', |
|
| 211 | - ), |
|
| 212 | - ), |
|
| 213 | - ), |
|
| 214 | - 'patch' => array( |
|
| 215 | - 'tags' => array( |
|
| 216 | - 'Tag', |
|
| 217 | - ), |
|
| 218 | - 'responses' => array( |
|
| 219 | - 200 => array( |
|
| 220 | - 'description' => 'OK', |
|
| 221 | - ), |
|
| 222 | - ), |
|
| 223 | - ), |
|
| 224 | - ), $object->toArray()); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - protected function setUp(): void |
|
| 228 | - { |
|
| 229 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - protected function assertPreConditions(): void |
|
| 233 | - { |
|
| 234 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 235 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructor_Empty() |
|
| 15 | + { |
|
| 16 | + $object = new \SwaggerGen\Swagger\Path($this->parent); |
|
| 17 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 18 | + |
|
| 19 | + $this->assertSame(array(), $object->toArray()); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @covers \SwaggerGen\Swagger\Path::__construct |
|
| 24 | + */ |
|
| 25 | + public function testConstructor_Tag() |
|
| 26 | + { |
|
| 27 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array(), $object->toArray()); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 35 | + */ |
|
| 36 | + public function testHandleCommand_Method_Empty() |
|
| 37 | + { |
|
| 38 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 39 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 40 | + |
|
| 41 | + $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method ''"); |
|
| 42 | + $return = $object->handleCommand('method'); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 47 | + */ |
|
| 48 | + public function testHandleCommand_Method_Unknown() |
|
| 49 | + { |
|
| 50 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 51 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 52 | + |
|
| 53 | + $this->expectException('\SwaggerGen\Exception', "Unrecognized operation method 'foo'"); |
|
| 54 | + $return = $object->handleCommand('method', 'foo'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 59 | + */ |
|
| 60 | + public function testHandleCommand_Method_Get() |
|
| 61 | + { |
|
| 62 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 64 | + |
|
| 65 | + $operation = $object->handleCommand('method', 'get'); |
|
| 66 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 67 | + $operation->handleCommand('response', 200); |
|
| 68 | + |
|
| 69 | + $this->assertSame(array( |
|
| 70 | + 'get' => array( |
|
| 71 | + 'tags' => array( |
|
| 72 | + 'Tag', |
|
| 73 | + ), |
|
| 74 | + 'responses' => array( |
|
| 75 | + 200 => array( |
|
| 76 | + 'description' => 'OK', |
|
| 77 | + ), |
|
| 78 | + ), |
|
| 79 | + ), |
|
| 80 | + ), $object->toArray()); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 85 | + */ |
|
| 86 | + public function testHandleCommand_Method_Description() |
|
| 87 | + { |
|
| 88 | + $this->markTestIncomplete('This test has not been implemented yet.'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 93 | + */ |
|
| 94 | + public function testHandleCommand_Operation_Get() |
|
| 95 | + { |
|
| 96 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 97 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 98 | + |
|
| 99 | + $operation = $object->handleCommand('operation', 'get'); |
|
| 100 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 101 | + $operation->handleCommand('response', 200); |
|
| 102 | + |
|
| 103 | + $this->assertSame(array( |
|
| 104 | + 'get' => array( |
|
| 105 | + 'tags' => array( |
|
| 106 | + 'Tag', |
|
| 107 | + ), |
|
| 108 | + 'responses' => array( |
|
| 109 | + 200 => array( |
|
| 110 | + 'description' => 'OK', |
|
| 111 | + ), |
|
| 112 | + ), |
|
| 113 | + ), |
|
| 114 | + ), $object->toArray()); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @covers \SwaggerGen\Swagger\Path::handleCommand |
|
| 119 | + */ |
|
| 120 | + public function testHandleCommand_MethodOrdering() |
|
| 121 | + { |
|
| 122 | + $object = new \SwaggerGen\Swagger\Path($this->parent, new SwaggerGen\Swagger\Tag($this->parent, 'Tag')); |
|
| 123 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $object); |
|
| 124 | + |
|
| 125 | + $operation = $object->handleCommand('method', 'post'); |
|
| 126 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 127 | + $operation->handleCommand('response', 200); |
|
| 128 | + |
|
| 129 | + $operation = $object->handleCommand('method', 'delete'); |
|
| 130 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 131 | + $operation->handleCommand('response', 200); |
|
| 132 | + |
|
| 133 | + $operation = $object->handleCommand('method', 'patch'); |
|
| 134 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 135 | + $operation->handleCommand('response', 200); |
|
| 136 | + |
|
| 137 | + $operation = $object->handleCommand('method', 'put'); |
|
| 138 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 139 | + $operation->handleCommand('response', 200); |
|
| 140 | + |
|
| 141 | + $operation = $object->handleCommand('method', 'head'); |
|
| 142 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 143 | + $operation->handleCommand('response', 200); |
|
| 144 | + |
|
| 145 | + $operation = $object->handleCommand('method', 'get'); |
|
| 146 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 147 | + $operation->handleCommand('response', 200); |
|
| 148 | + |
|
| 149 | + $operation = $object->handleCommand('method', 'options'); |
|
| 150 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
| 151 | + $operation->handleCommand('response', 200); |
|
| 152 | + |
|
| 153 | + $this->assertSame(array( |
|
| 154 | + 'get' => array( |
|
| 155 | + 'tags' => array( |
|
| 156 | + 'Tag', |
|
| 157 | + ), |
|
| 158 | + 'responses' => array( |
|
| 159 | + 200 => array( |
|
| 160 | + 'description' => 'OK', |
|
| 161 | + ), |
|
| 162 | + ), |
|
| 163 | + ), |
|
| 164 | + 'put' => array( |
|
| 165 | + 'tags' => array( |
|
| 166 | + 'Tag', |
|
| 167 | + ), |
|
| 168 | + 'responses' => array( |
|
| 169 | + 200 => array( |
|
| 170 | + 'description' => 'OK', |
|
| 171 | + ), |
|
| 172 | + ), |
|
| 173 | + ), |
|
| 174 | + 'post' => array( |
|
| 175 | + 'tags' => array( |
|
| 176 | + 'Tag', |
|
| 177 | + ), |
|
| 178 | + 'responses' => array( |
|
| 179 | + 200 => array( |
|
| 180 | + 'description' => 'OK', |
|
| 181 | + ), |
|
| 182 | + ), |
|
| 183 | + ), |
|
| 184 | + 'delete' => array( |
|
| 185 | + 'tags' => array( |
|
| 186 | + 'Tag', |
|
| 187 | + ), |
|
| 188 | + 'responses' => array( |
|
| 189 | + 200 => array( |
|
| 190 | + 'description' => 'OK', |
|
| 191 | + ), |
|
| 192 | + ), |
|
| 193 | + ), |
|
| 194 | + 'options' => array( |
|
| 195 | + 'tags' => array( |
|
| 196 | + 'Tag', |
|
| 197 | + ), |
|
| 198 | + 'responses' => array( |
|
| 199 | + 200 => array( |
|
| 200 | + 'description' => 'OK', |
|
| 201 | + ), |
|
| 202 | + ), |
|
| 203 | + ), |
|
| 204 | + 'head' => array( |
|
| 205 | + 'tags' => array( |
|
| 206 | + 'Tag', |
|
| 207 | + ), |
|
| 208 | + 'responses' => array( |
|
| 209 | + 200 => array( |
|
| 210 | + 'description' => 'OK', |
|
| 211 | + ), |
|
| 212 | + ), |
|
| 213 | + ), |
|
| 214 | + 'patch' => array( |
|
| 215 | + 'tags' => array( |
|
| 216 | + 'Tag', |
|
| 217 | + ), |
|
| 218 | + 'responses' => array( |
|
| 219 | + 200 => array( |
|
| 220 | + 'description' => 'OK', |
|
| 221 | + ), |
|
| 222 | + ), |
|
| 223 | + ), |
|
| 224 | + ), $object->toArray()); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + protected function setUp(): void |
|
| 228 | + { |
|
| 229 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + protected function assertPreConditions(): void |
|
| 233 | + { |
|
| 234 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | } |
@@ -6,193 +6,193 @@ |
||
| 6 | 6 | class ParameterTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructor_InEmpty(): void |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''"); |
|
| 17 | - |
|
| 18 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, '', ''); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstructor_InNotValid(): void |
|
| 25 | - { |
|
| 26 | - $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'"); |
|
| 27 | - |
|
| 28 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', ''); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 33 | - */ |
|
| 34 | - public function testConstructor_DefinitionEmpty(): void |
|
| 35 | - { |
|
| 36 | - $this->expectException('\SwaggerGen\Exception', "No type definition for parameter"); |
|
| 37 | - |
|
| 38 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', ''); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 43 | - */ |
|
| 44 | - public function testConstructor_NameEmpty(): void |
|
| 45 | - { |
|
| 46 | - $this->expectException('\SwaggerGen\Exception', "No name for parameter"); |
|
| 47 | - |
|
| 48 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int'); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 53 | - */ |
|
| 54 | - public function testConstructor_DefinitionUnknownType() |
|
| 55 | - { |
|
| 56 | - $this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'"); |
|
| 57 | - |
|
| 58 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 63 | - */ |
|
| 64 | - public function testConstructor() |
|
| 65 | - { |
|
| 66 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo'); |
|
| 67 | - |
|
| 68 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 69 | - |
|
| 70 | - $this->assertSame(array( |
|
| 71 | - 'name' => 'foo', |
|
| 72 | - 'in' => 'path', |
|
| 73 | - 'required' => true, |
|
| 74 | - 'type' => 'integer', |
|
| 75 | - 'format' => 'int32', |
|
| 76 | - ), $object->toArray()); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 81 | - */ |
|
| 82 | - public function testConstructor_PathAlwaysRequired() |
|
| 83 | - { |
|
| 84 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
| 85 | - |
|
| 86 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 87 | - |
|
| 88 | - $this->assertSame(array( |
|
| 89 | - 'name' => 'foo', |
|
| 90 | - 'in' => 'path', |
|
| 91 | - 'required' => true, |
|
| 92 | - 'type' => 'integer', |
|
| 93 | - 'format' => 'int32', |
|
| 94 | - ), $object->toArray()); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 99 | - */ |
|
| 100 | - public function testConstructor_Optional() |
|
| 101 | - { |
|
| 102 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false); |
|
| 103 | - |
|
| 104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 105 | - |
|
| 106 | - $this->assertSame(array( |
|
| 107 | - 'name' => 'foo', |
|
| 108 | - 'in' => 'query', |
|
| 109 | - 'type' => 'integer', |
|
| 110 | - 'format' => 'int32', |
|
| 111 | - ), $object->toArray()); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 116 | - */ |
|
| 117 | - public function testConstructor_Description() |
|
| 118 | - { |
|
| 119 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words'); |
|
| 120 | - |
|
| 121 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 122 | - |
|
| 123 | - $this->assertSame(array( |
|
| 124 | - 'name' => 'foo', |
|
| 125 | - 'in' => 'path', |
|
| 126 | - 'description' => 'Some words', |
|
| 127 | - 'required' => true, |
|
| 128 | - 'type' => 'integer', |
|
| 129 | - 'format' => 'int32', |
|
| 130 | - ), $object->toArray()); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 135 | - */ |
|
| 136 | - public function testConstructor_Form() |
|
| 137 | - { |
|
| 138 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false); |
|
| 139 | - |
|
| 140 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 141 | - |
|
| 142 | - $this->assertSame(array( |
|
| 143 | - 'name' => 'foo', |
|
| 144 | - 'in' => 'formData', |
|
| 145 | - 'type' => 'integer', |
|
| 146 | - 'format' => 'int32', |
|
| 147 | - ), $object->toArray()); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 152 | - */ |
|
| 153 | - public function testConstructor_Header() |
|
| 154 | - { |
|
| 155 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false); |
|
| 156 | - |
|
| 157 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 158 | - |
|
| 159 | - $this->assertSame(array( |
|
| 160 | - 'name' => 'foo', |
|
| 161 | - 'in' => 'header', |
|
| 162 | - 'type' => 'integer', |
|
| 163 | - 'format' => 'int32', |
|
| 164 | - ), $object->toArray()); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand |
|
| 169 | - */ |
|
| 170 | - public function testHandleCommand_Passing() |
|
| 171 | - { |
|
| 172 | - $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
| 173 | - |
|
| 174 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 175 | - |
|
| 176 | - $object->handleCommand('default', '123'); |
|
| 177 | - |
|
| 178 | - $this->assertSame(array( |
|
| 179 | - 'name' => 'foo', |
|
| 180 | - 'in' => 'path', |
|
| 181 | - 'required' => true, |
|
| 182 | - 'type' => 'integer', |
|
| 183 | - 'format' => 'int32', |
|
| 184 | - 'default' => 123, |
|
| 185 | - ), $object->toArray()); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - protected function setUp(): void |
|
| 189 | - { |
|
| 190 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - protected function assertPreConditions(): void |
|
| 194 | - { |
|
| 195 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 196 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructor_InEmpty(): void |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: ''"); |
|
| 17 | + |
|
| 18 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, '', ''); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstructor_InNotValid(): void |
|
| 25 | + { |
|
| 26 | + $this->expectException('\SwaggerGen\Exception', "Invalid in for parameter: 'foo'"); |
|
| 27 | + |
|
| 28 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'foo', ''); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 33 | + */ |
|
| 34 | + public function testConstructor_DefinitionEmpty(): void |
|
| 35 | + { |
|
| 36 | + $this->expectException('\SwaggerGen\Exception', "No type definition for parameter"); |
|
| 37 | + |
|
| 38 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', ''); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 43 | + */ |
|
| 44 | + public function testConstructor_NameEmpty(): void |
|
| 45 | + { |
|
| 46 | + $this->expectException('\SwaggerGen\Exception', "No name for parameter"); |
|
| 47 | + |
|
| 48 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int'); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 53 | + */ |
|
| 54 | + public function testConstructor_DefinitionUnknownType() |
|
| 55 | + { |
|
| 56 | + $this->expectException('\SwaggerGen\Exception', "Type format not recognized: 'foo'"); |
|
| 57 | + |
|
| 58 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'foo bar'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 63 | + */ |
|
| 64 | + public function testConstructor() |
|
| 65 | + { |
|
| 66 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo'); |
|
| 67 | + |
|
| 68 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 69 | + |
|
| 70 | + $this->assertSame(array( |
|
| 71 | + 'name' => 'foo', |
|
| 72 | + 'in' => 'path', |
|
| 73 | + 'required' => true, |
|
| 74 | + 'type' => 'integer', |
|
| 75 | + 'format' => 'int32', |
|
| 76 | + ), $object->toArray()); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 81 | + */ |
|
| 82 | + public function testConstructor_PathAlwaysRequired() |
|
| 83 | + { |
|
| 84 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
| 85 | + |
|
| 86 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 87 | + |
|
| 88 | + $this->assertSame(array( |
|
| 89 | + 'name' => 'foo', |
|
| 90 | + 'in' => 'path', |
|
| 91 | + 'required' => true, |
|
| 92 | + 'type' => 'integer', |
|
| 93 | + 'format' => 'int32', |
|
| 94 | + ), $object->toArray()); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 99 | + */ |
|
| 100 | + public function testConstructor_Optional() |
|
| 101 | + { |
|
| 102 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'query', 'int foo', false); |
|
| 103 | + |
|
| 104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 105 | + |
|
| 106 | + $this->assertSame(array( |
|
| 107 | + 'name' => 'foo', |
|
| 108 | + 'in' => 'query', |
|
| 109 | + 'type' => 'integer', |
|
| 110 | + 'format' => 'int32', |
|
| 111 | + ), $object->toArray()); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 116 | + */ |
|
| 117 | + public function testConstructor_Description() |
|
| 118 | + { |
|
| 119 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo Some words'); |
|
| 120 | + |
|
| 121 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 122 | + |
|
| 123 | + $this->assertSame(array( |
|
| 124 | + 'name' => 'foo', |
|
| 125 | + 'in' => 'path', |
|
| 126 | + 'description' => 'Some words', |
|
| 127 | + 'required' => true, |
|
| 128 | + 'type' => 'integer', |
|
| 129 | + 'format' => 'int32', |
|
| 130 | + ), $object->toArray()); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 135 | + */ |
|
| 136 | + public function testConstructor_Form() |
|
| 137 | + { |
|
| 138 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'form', 'int foo', false); |
|
| 139 | + |
|
| 140 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 141 | + |
|
| 142 | + $this->assertSame(array( |
|
| 143 | + 'name' => 'foo', |
|
| 144 | + 'in' => 'formData', |
|
| 145 | + 'type' => 'integer', |
|
| 146 | + 'format' => 'int32', |
|
| 147 | + ), $object->toArray()); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @covers \SwaggerGen\Swagger\Parameter::__construct |
|
| 152 | + */ |
|
| 153 | + public function testConstructor_Header() |
|
| 154 | + { |
|
| 155 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'header', 'int foo', false); |
|
| 156 | + |
|
| 157 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 158 | + |
|
| 159 | + $this->assertSame(array( |
|
| 160 | + 'name' => 'foo', |
|
| 161 | + 'in' => 'header', |
|
| 162 | + 'type' => 'integer', |
|
| 163 | + 'format' => 'int32', |
|
| 164 | + ), $object->toArray()); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @covers \SwaggerGen\Swagger\Type\Parameter->handleCommand |
|
| 169 | + */ |
|
| 170 | + public function testHandleCommand_Passing() |
|
| 171 | + { |
|
| 172 | + $object = new \SwaggerGen\Swagger\Parameter($this->parent, 'path', 'int foo', false); |
|
| 173 | + |
|
| 174 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $object); |
|
| 175 | + |
|
| 176 | + $object->handleCommand('default', '123'); |
|
| 177 | + |
|
| 178 | + $this->assertSame(array( |
|
| 179 | + 'name' => 'foo', |
|
| 180 | + 'in' => 'path', |
|
| 181 | + 'required' => true, |
|
| 182 | + 'type' => 'integer', |
|
| 183 | + 'format' => 'int32', |
|
| 184 | + 'default' => 123, |
|
| 185 | + ), $object->toArray()); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + protected function setUp(): void |
|
| 189 | + { |
|
| 190 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + protected function assertPreConditions(): void |
|
| 194 | + { |
|
| 195 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | } |