@@ -6,148 +6,148 @@ |
||
| 6 | 6 | class BodyParameterTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructorNoType() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "No type definition for body parameter"); |
|
| 17 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, ''); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 22 | - */ |
|
| 23 | - public function testConstructorNoName() |
|
| 24 | - { |
|
| 25 | - $this->expectException('\SwaggerGen\Exception', "No name for body parameter"); |
|
| 26 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'wrong'); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 31 | - */ |
|
| 32 | - public function testConstructorType() |
|
| 33 | - { |
|
| 34 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo'); |
|
| 35 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 36 | - |
|
| 37 | - $this->assertSame(array( |
|
| 38 | - 'name' => 'foo', |
|
| 39 | - 'in' => 'body', |
|
| 40 | - 'schema' => array( |
|
| 41 | - 'type' => 'integer', |
|
| 42 | - 'format' => 'int32', |
|
| 43 | - ), |
|
| 44 | - ), $object->toArray()); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 49 | - */ |
|
| 50 | - public function testConstructorReference() |
|
| 51 | - { |
|
| 52 | - $this->parent->handleCommand('model', 'User'); |
|
| 53 | - |
|
| 54 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'User foo'); |
|
| 55 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 56 | - |
|
| 57 | - $this->assertSame(array( |
|
| 58 | - 'name' => 'foo', |
|
| 59 | - 'in' => 'body', |
|
| 60 | - 'schema' => array( |
|
| 61 | - '$ref' => '#/definitions/User', |
|
| 62 | - ), |
|
| 63 | - ), $object->toArray()); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 68 | - */ |
|
| 69 | - public function testConstructorDescription() |
|
| 70 | - { |
|
| 71 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo Some more words'); |
|
| 72 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 73 | - |
|
| 74 | - $this->assertSame(array( |
|
| 75 | - 'name' => 'foo', |
|
| 76 | - 'in' => 'body', |
|
| 77 | - 'description' => 'Some more words', |
|
| 78 | - 'schema' => array( |
|
| 79 | - 'type' => 'integer', |
|
| 80 | - 'format' => 'int32', |
|
| 81 | - ), |
|
| 82 | - ), $object->toArray()); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 87 | - */ |
|
| 88 | - public function testConstructorRequired() |
|
| 89 | - { |
|
| 90 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', true); |
|
| 91 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 92 | - |
|
| 93 | - $this->assertSame(array( |
|
| 94 | - 'name' => 'foo', |
|
| 95 | - 'in' => 'body', |
|
| 96 | - 'required' => true, |
|
| 97 | - 'schema' => array( |
|
| 98 | - 'type' => 'integer', |
|
| 99 | - 'format' => 'int32', |
|
| 100 | - ), |
|
| 101 | - ), $object->toArray()); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 106 | - */ |
|
| 107 | - public function testConstructorNotRequired() |
|
| 108 | - { |
|
| 109 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false); |
|
| 110 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 111 | - |
|
| 112 | - $this->assertSame(array( |
|
| 113 | - 'name' => 'foo', |
|
| 114 | - 'in' => 'body', |
|
| 115 | - 'schema' => array( |
|
| 116 | - 'type' => 'integer', |
|
| 117 | - 'format' => 'int32', |
|
| 118 | - ), |
|
| 119 | - ), $object->toArray()); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @covers \SwaggerGen\Swagger\Type\BodyParameter->handleCommand |
|
| 124 | - */ |
|
| 125 | - public function testCommandPassing() |
|
| 126 | - { |
|
| 127 | - $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false); |
|
| 128 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 129 | - |
|
| 130 | - $object->handleCommand('default', '123'); |
|
| 131 | - |
|
| 132 | - $this->assertSame(array( |
|
| 133 | - 'name' => 'foo', |
|
| 134 | - 'in' => 'body', |
|
| 135 | - 'schema' => array( |
|
| 136 | - 'type' => 'integer', |
|
| 137 | - 'format' => 'int32', |
|
| 138 | - 'default' => 123, |
|
| 139 | - ), |
|
| 140 | - ), $object->toArray()); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - protected function setUp(): void |
|
| 144 | - { |
|
| 145 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - protected function assertPreConditions(): void |
|
| 149 | - { |
|
| 150 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 151 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructorNoType() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "No type definition for body parameter"); |
|
| 17 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, ''); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 22 | + */ |
|
| 23 | + public function testConstructorNoName() |
|
| 24 | + { |
|
| 25 | + $this->expectException('\SwaggerGen\Exception', "No name for body parameter"); |
|
| 26 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'wrong'); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 31 | + */ |
|
| 32 | + public function testConstructorType() |
|
| 33 | + { |
|
| 34 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo'); |
|
| 35 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 36 | + |
|
| 37 | + $this->assertSame(array( |
|
| 38 | + 'name' => 'foo', |
|
| 39 | + 'in' => 'body', |
|
| 40 | + 'schema' => array( |
|
| 41 | + 'type' => 'integer', |
|
| 42 | + 'format' => 'int32', |
|
| 43 | + ), |
|
| 44 | + ), $object->toArray()); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 49 | + */ |
|
| 50 | + public function testConstructorReference() |
|
| 51 | + { |
|
| 52 | + $this->parent->handleCommand('model', 'User'); |
|
| 53 | + |
|
| 54 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'User foo'); |
|
| 55 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 56 | + |
|
| 57 | + $this->assertSame(array( |
|
| 58 | + 'name' => 'foo', |
|
| 59 | + 'in' => 'body', |
|
| 60 | + 'schema' => array( |
|
| 61 | + '$ref' => '#/definitions/User', |
|
| 62 | + ), |
|
| 63 | + ), $object->toArray()); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 68 | + */ |
|
| 69 | + public function testConstructorDescription() |
|
| 70 | + { |
|
| 71 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo Some more words'); |
|
| 72 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 73 | + |
|
| 74 | + $this->assertSame(array( |
|
| 75 | + 'name' => 'foo', |
|
| 76 | + 'in' => 'body', |
|
| 77 | + 'description' => 'Some more words', |
|
| 78 | + 'schema' => array( |
|
| 79 | + 'type' => 'integer', |
|
| 80 | + 'format' => 'int32', |
|
| 81 | + ), |
|
| 82 | + ), $object->toArray()); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 87 | + */ |
|
| 88 | + public function testConstructorRequired() |
|
| 89 | + { |
|
| 90 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', true); |
|
| 91 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 92 | + |
|
| 93 | + $this->assertSame(array( |
|
| 94 | + 'name' => 'foo', |
|
| 95 | + 'in' => 'body', |
|
| 96 | + 'required' => true, |
|
| 97 | + 'schema' => array( |
|
| 98 | + 'type' => 'integer', |
|
| 99 | + 'format' => 'int32', |
|
| 100 | + ), |
|
| 101 | + ), $object->toArray()); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @covers \SwaggerGen\Swagger\BodyParameter::__construct |
|
| 106 | + */ |
|
| 107 | + public function testConstructorNotRequired() |
|
| 108 | + { |
|
| 109 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false); |
|
| 110 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 111 | + |
|
| 112 | + $this->assertSame(array( |
|
| 113 | + 'name' => 'foo', |
|
| 114 | + 'in' => 'body', |
|
| 115 | + 'schema' => array( |
|
| 116 | + 'type' => 'integer', |
|
| 117 | + 'format' => 'int32', |
|
| 118 | + ), |
|
| 119 | + ), $object->toArray()); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @covers \SwaggerGen\Swagger\Type\BodyParameter->handleCommand |
|
| 124 | + */ |
|
| 125 | + public function testCommandPassing() |
|
| 126 | + { |
|
| 127 | + $object = new \SwaggerGen\Swagger\BodyParameter($this->parent, 'int foo', false); |
|
| 128 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $object); |
|
| 129 | + |
|
| 130 | + $object->handleCommand('default', '123'); |
|
| 131 | + |
|
| 132 | + $this->assertSame(array( |
|
| 133 | + 'name' => 'foo', |
|
| 134 | + 'in' => 'body', |
|
| 135 | + 'schema' => array( |
|
| 136 | + 'type' => 'integer', |
|
| 137 | + 'format' => 'int32', |
|
| 138 | + 'default' => 123, |
|
| 139 | + ), |
|
| 140 | + ), $object->toArray()); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + protected function setUp(): void |
|
| 144 | + { |
|
| 145 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + protected function assertPreConditions(): void |
|
| 149 | + { |
|
| 150 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | } |
@@ -7,113 +7,113 @@ |
||
| 7 | 7 | class LicenseTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $parent; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
| 14 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 15 | - */ |
|
| 16 | - public function testConstructor2Unknown(): void |
|
| 17 | - { |
|
| 18 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
| 19 | - |
|
| 20 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 21 | - |
|
| 22 | - $this->assertSame(array( |
|
| 23 | - 'name' => 'Name', |
|
| 24 | - ), $object->toArray()); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
| 29 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 30 | - */ |
|
| 31 | - public function testConstructor2Known() |
|
| 32 | - { |
|
| 33 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 34 | - |
|
| 35 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 36 | - |
|
| 37 | - $this->assertSame(array( |
|
| 38 | - 'name' => 'MIT', |
|
| 39 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
| 40 | - ), $object->toArray()); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
| 45 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 46 | - */ |
|
| 47 | - public function testConstructor3Unknown() |
|
| 48 | - { |
|
| 49 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
| 50 | - |
|
| 51 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 52 | - |
|
| 53 | - $this->assertSame(array( |
|
| 54 | - 'name' => 'Name', |
|
| 55 | - 'url' => 'http://example', |
|
| 56 | - ), $object->toArray()); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
| 61 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
| 62 | - */ |
|
| 63 | - public function testConstructor3Known() |
|
| 64 | - { |
|
| 65 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
| 66 | - |
|
| 67 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 68 | - |
|
| 69 | - $this->assertSame(array( |
|
| 70 | - 'name' => 'MIT', |
|
| 71 | - 'url' => 'http://example', |
|
| 72 | - ), $object->toArray()); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 77 | - */ |
|
| 78 | - public function testCommandName() |
|
| 79 | - { |
|
| 80 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 81 | - |
|
| 82 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 83 | - |
|
| 84 | - $object->handleCommand('name', 'GPL-3'); |
|
| 85 | - |
|
| 86 | - $this->assertSame(array( |
|
| 87 | - 'name' => 'GPL-3', |
|
| 88 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
| 89 | - ), $object->toArray()); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 94 | - */ |
|
| 95 | - public function testCommandUrl() |
|
| 96 | - { |
|
| 97 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 98 | - |
|
| 99 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 100 | - |
|
| 101 | - $object->handleCommand('url', 'http://example'); |
|
| 102 | - |
|
| 103 | - $this->assertSame(array( |
|
| 104 | - 'name' => 'MIT', |
|
| 105 | - 'url' => 'http://example', |
|
| 106 | - ), $object->toArray()); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - protected function setUp(): void |
|
| 110 | - { |
|
| 111 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - protected function assertPreConditions(): void |
|
| 115 | - { |
|
| 116 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 117 | - } |
|
| 10 | + protected $parent; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
| 14 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 15 | + */ |
|
| 16 | + public function testConstructor2Unknown(): void |
|
| 17 | + { |
|
| 18 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
| 19 | + |
|
| 20 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 21 | + |
|
| 22 | + $this->assertSame(array( |
|
| 23 | + 'name' => 'Name', |
|
| 24 | + ), $object->toArray()); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
| 29 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 30 | + */ |
|
| 31 | + public function testConstructor2Known() |
|
| 32 | + { |
|
| 33 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 34 | + |
|
| 35 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 36 | + |
|
| 37 | + $this->assertSame(array( |
|
| 38 | + 'name' => 'MIT', |
|
| 39 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
| 40 | + ), $object->toArray()); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
| 45 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 46 | + */ |
|
| 47 | + public function testConstructor3Unknown() |
|
| 48 | + { |
|
| 49 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
| 50 | + |
|
| 51 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 52 | + |
|
| 53 | + $this->assertSame(array( |
|
| 54 | + 'name' => 'Name', |
|
| 55 | + 'url' => 'http://example', |
|
| 56 | + ), $object->toArray()); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
| 61 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
| 62 | + */ |
|
| 63 | + public function testConstructor3Known() |
|
| 64 | + { |
|
| 65 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
| 66 | + |
|
| 67 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 68 | + |
|
| 69 | + $this->assertSame(array( |
|
| 70 | + 'name' => 'MIT', |
|
| 71 | + 'url' => 'http://example', |
|
| 72 | + ), $object->toArray()); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 77 | + */ |
|
| 78 | + public function testCommandName() |
|
| 79 | + { |
|
| 80 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 81 | + |
|
| 82 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 83 | + |
|
| 84 | + $object->handleCommand('name', 'GPL-3'); |
|
| 85 | + |
|
| 86 | + $this->assertSame(array( |
|
| 87 | + 'name' => 'GPL-3', |
|
| 88 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
| 89 | + ), $object->toArray()); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
| 94 | + */ |
|
| 95 | + public function testCommandUrl() |
|
| 96 | + { |
|
| 97 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
| 98 | + |
|
| 99 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
| 100 | + |
|
| 101 | + $object->handleCommand('url', 'http://example'); |
|
| 102 | + |
|
| 103 | + $this->assertSame(array( |
|
| 104 | + 'name' => 'MIT', |
|
| 105 | + 'url' => 'http://example', |
|
| 106 | + ), $object->toArray()); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + protected function setUp(): void |
|
| 110 | + { |
|
| 111 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + protected function assertPreConditions(): void |
|
| 115 | + { |
|
| 116 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | } |
@@ -7,79 +7,79 @@ |
||
| 7 | 7 | class ExternalDocumentationTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $parent; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct |
|
| 14 | - */ |
|
| 15 | - public function testConstructorUrl(): void |
|
| 16 | - { |
|
| 17 | - $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test'); |
|
| 18 | - |
|
| 19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 20 | - |
|
| 21 | - $this->assertSame(array( |
|
| 22 | - 'url' => 'http://example.test', |
|
| 23 | - ), $object->toArray()); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct |
|
| 28 | - */ |
|
| 29 | - public function testConstructorFull() |
|
| 30 | - { |
|
| 31 | - $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 32 | - |
|
| 33 | - $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 34 | - |
|
| 35 | - $this->assertSame(array( |
|
| 36 | - 'url' => 'http://example.test', |
|
| 37 | - 'description' => 'Descriptive text', |
|
| 38 | - ), $object->toArray()); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand |
|
| 43 | - */ |
|
| 44 | - public function testCommandUrl() |
|
| 45 | - { |
|
| 46 | - $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 47 | - |
|
| 48 | - $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 49 | - |
|
| 50 | - $object->handleCommand('url', 'http://other.test'); |
|
| 51 | - |
|
| 52 | - $this->assertSame(array( |
|
| 53 | - 'url' => 'http://other.test', |
|
| 54 | - 'description' => 'Descriptive text', |
|
| 55 | - ), $object->toArray()); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand |
|
| 60 | - */ |
|
| 61 | - public function testCommandDescription() |
|
| 62 | - { |
|
| 63 | - $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 64 | - |
|
| 65 | - $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 66 | - |
|
| 67 | - $object->handleCommand('description', 'Some other words'); |
|
| 68 | - |
|
| 69 | - $this->assertSame(array( |
|
| 70 | - 'url' => 'http://example.test', |
|
| 71 | - 'description' => 'Some other words', |
|
| 72 | - ), $object->toArray()); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - protected function setUp(): void |
|
| 76 | - { |
|
| 77 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - protected function assertPreConditions(): void |
|
| 81 | - { |
|
| 82 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 83 | - } |
|
| 10 | + protected $parent; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct |
|
| 14 | + */ |
|
| 15 | + public function testConstructorUrl(): void |
|
| 16 | + { |
|
| 17 | + $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test'); |
|
| 18 | + |
|
| 19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 20 | + |
|
| 21 | + $this->assertSame(array( |
|
| 22 | + 'url' => 'http://example.test', |
|
| 23 | + ), $object->toArray()); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @covers \SwaggerGen\Swagger\ExternalDocumentation::__construct |
|
| 28 | + */ |
|
| 29 | + public function testConstructorFull() |
|
| 30 | + { |
|
| 31 | + $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 32 | + |
|
| 33 | + $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 34 | + |
|
| 35 | + $this->assertSame(array( |
|
| 36 | + 'url' => 'http://example.test', |
|
| 37 | + 'description' => 'Descriptive text', |
|
| 38 | + ), $object->toArray()); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand |
|
| 43 | + */ |
|
| 44 | + public function testCommandUrl() |
|
| 45 | + { |
|
| 46 | + $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 47 | + |
|
| 48 | + $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 49 | + |
|
| 50 | + $object->handleCommand('url', 'http://other.test'); |
|
| 51 | + |
|
| 52 | + $this->assertSame(array( |
|
| 53 | + 'url' => 'http://other.test', |
|
| 54 | + 'description' => 'Descriptive text', |
|
| 55 | + ), $object->toArray()); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @covers \SwaggerGen\Swagger\ExternalDocumentation::handleCommand |
|
| 60 | + */ |
|
| 61 | + public function testCommandDescription() |
|
| 62 | + { |
|
| 63 | + $object = new \SwaggerGen\Swagger\ExternalDocumentation($this->parent, 'http://example.test', 'Descriptive text'); |
|
| 64 | + |
|
| 65 | + $this->assertInstanceOf('\SwaggerGen\Swagger\ExternalDocumentation', $object); |
|
| 66 | + |
|
| 67 | + $object->handleCommand('description', 'Some other words'); |
|
| 68 | + |
|
| 69 | + $this->assertSame(array( |
|
| 70 | + 'url' => 'http://example.test', |
|
| 71 | + 'description' => 'Some other words', |
|
| 72 | + ), $object->toArray()); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + protected function setUp(): void |
|
| 76 | + { |
|
| 77 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + protected function assertPreConditions(): void |
|
| 81 | + { |
|
| 82 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
@@ -6,84 +6,84 @@ |
||
| 6 | 6 | class AbstractObjectTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @covers \SwaggerGen\Swagger\AbstractObject::words_shift |
|
| 11 | - */ |
|
| 12 | - public function testWords_shift() |
|
| 13 | - { |
|
| 14 | - $text = 'quite a few words'; |
|
| 15 | - |
|
| 16 | - $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 17 | - $this->assertSame('a few words', $text); |
|
| 18 | - |
|
| 19 | - $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 20 | - $this->assertSame('few words', $text); |
|
| 21 | - |
|
| 22 | - $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 23 | - $this->assertSame('words', $text); |
|
| 24 | - |
|
| 25 | - $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 26 | - $this->assertSame('', $text); |
|
| 27 | - |
|
| 28 | - $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 29 | - $this->assertSame('', $text); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @covers \SwaggerGen\Swagger\AbstractObject::words_shift |
|
| 34 | - */ |
|
| 35 | - public function testWords_shift_whitespace() |
|
| 36 | - { |
|
| 37 | - $text = " quite a\nfew \r \n\r words \t"; |
|
| 38 | - |
|
| 39 | - $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 40 | - $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 41 | - $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 42 | - $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 43 | - $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 44 | - $this->assertSame('', $text); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @covers \SwaggerGen\Swagger\AbstractObject::mb_trim |
|
| 49 | - */ |
|
| 50 | - public function testMb_trim() |
|
| 51 | - { |
|
| 52 | - $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed")); |
|
| 53 | - $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed ")); |
|
| 54 | - $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed")); |
|
| 55 | - $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed ")); |
|
| 56 | - $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("\n \t trimmed \f \r")); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @covers \SwaggerGen\Swagger\AbstractObject::toArray |
|
| 61 | - */ |
|
| 62 | - public function testToArray() |
|
| 63 | - { |
|
| 64 | - $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 65 | - |
|
| 66 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object); |
|
| 67 | - |
|
| 68 | - $this->assertSame(array(), $object->toArray()); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @covers \SwaggerGen\Swagger\AbstractObject::handleCommand |
|
| 73 | - */ |
|
| 74 | - public function testCommandExtensions() |
|
| 75 | - { |
|
| 76 | - $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 77 | - |
|
| 78 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object); |
|
| 79 | - |
|
| 80 | - $object->handleCommand('x-someTag', 'some value'); |
|
| 81 | - $object->handleCommand('x-anyTag', 'any value'); |
|
| 82 | - |
|
| 83 | - $this->assertSame(array( |
|
| 84 | - 'x-someTag' => 'some value', |
|
| 85 | - 'x-anyTag' => 'any value', |
|
| 86 | - ), $object->toArray()); |
|
| 87 | - } |
|
| 9 | + /** |
|
| 10 | + * @covers \SwaggerGen\Swagger\AbstractObject::words_shift |
|
| 11 | + */ |
|
| 12 | + public function testWords_shift() |
|
| 13 | + { |
|
| 14 | + $text = 'quite a few words'; |
|
| 15 | + |
|
| 16 | + $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 17 | + $this->assertSame('a few words', $text); |
|
| 18 | + |
|
| 19 | + $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 20 | + $this->assertSame('few words', $text); |
|
| 21 | + |
|
| 22 | + $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 23 | + $this->assertSame('words', $text); |
|
| 24 | + |
|
| 25 | + $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 26 | + $this->assertSame('', $text); |
|
| 27 | + |
|
| 28 | + $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 29 | + $this->assertSame('', $text); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @covers \SwaggerGen\Swagger\AbstractObject::words_shift |
|
| 34 | + */ |
|
| 35 | + public function testWords_shift_whitespace() |
|
| 36 | + { |
|
| 37 | + $text = " quite a\nfew \r \n\r words \t"; |
|
| 38 | + |
|
| 39 | + $this->assertSame('quite', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 40 | + $this->assertSame('a', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 41 | + $this->assertSame('few', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 42 | + $this->assertSame('words', \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 43 | + $this->assertSame(false, \SwaggerGen\Swagger\AbstractObject::wordShift($text)); |
|
| 44 | + $this->assertSame('', $text); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @covers \SwaggerGen\Swagger\AbstractObject::mb_trim |
|
| 49 | + */ |
|
| 50 | + public function testMb_trim() |
|
| 51 | + { |
|
| 52 | + $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed")); |
|
| 53 | + $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("trimmed ")); |
|
| 54 | + $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed")); |
|
| 55 | + $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim(" trimmed ")); |
|
| 56 | + $this->assertSame('trimmed', \SwaggerGen\Swagger\AbstractObject::trim("\n \t trimmed \f \r")); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @covers \SwaggerGen\Swagger\AbstractObject::toArray |
|
| 61 | + */ |
|
| 62 | + public function testToArray() |
|
| 63 | + { |
|
| 64 | + $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 65 | + |
|
| 66 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object); |
|
| 67 | + |
|
| 68 | + $this->assertSame(array(), $object->toArray()); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @covers \SwaggerGen\Swagger\AbstractObject::handleCommand |
|
| 73 | + */ |
|
| 74 | + public function testCommandExtensions() |
|
| 75 | + { |
|
| 76 | + $object = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 77 | + |
|
| 78 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $object); |
|
| 79 | + |
|
| 80 | + $object->handleCommand('x-someTag', 'some value'); |
|
| 81 | + $object->handleCommand('x-anyTag', 'any value'); |
|
| 82 | + |
|
| 83 | + $this->assertSame(array( |
|
| 84 | + 'x-someTag' => 'some value', |
|
| 85 | + 'x-anyTag' => 'any value', |
|
| 86 | + ), $object->toArray()); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | } |
@@ -6,138 +6,138 @@ |
||
| 6 | 6 | class Ipv4TypeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructNotAnIpv4() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'"); |
|
| 17 | - |
|
| 18 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstruct() |
|
| 25 | - { |
|
| 26 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 27 | - |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array( |
|
| 31 | - 'type' => 'string', |
|
| 32 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 33 | - ), $object->toArray()); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 38 | - */ |
|
| 39 | - public function testConstructEmptyDefault() |
|
| 40 | - { |
|
| 41 | - $this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='"); |
|
| 42 | - |
|
| 43 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= '); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructDefaultRange() |
|
| 50 | - { |
|
| 51 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'"); |
|
| 52 | - |
|
| 53 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 58 | - */ |
|
| 59 | - public function testConstructDefault3Numbers() |
|
| 60 | - { |
|
| 61 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'"); |
|
| 62 | - |
|
| 63 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0'); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 68 | - */ |
|
| 69 | - public function testConstructDefault5Numbers() |
|
| 70 | - { |
|
| 71 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'"); |
|
| 72 | - |
|
| 73 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 78 | - */ |
|
| 79 | - public function testConstructDefaultUntrimmed() |
|
| 80 | - { |
|
| 81 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'"); |
|
| 82 | - |
|
| 83 | - new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 88 | - */ |
|
| 89 | - public function testConstructDefault() |
|
| 90 | - { |
|
| 91 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89'); |
|
| 92 | - |
|
| 93 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 94 | - |
|
| 95 | - $this->assertSame(array( |
|
| 96 | - 'type' => 'string', |
|
| 97 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 98 | - 'default' => '123.45.67.89', |
|
| 99 | - ), $object->toArray()); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand |
|
| 104 | - */ |
|
| 105 | - public function testCommandDefaultNoValue() |
|
| 106 | - { |
|
| 107 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 108 | - |
|
| 109 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 110 | - |
|
| 111 | - $this->expectException('\SwaggerGen\Exception', "Empty IPv4 default"); |
|
| 112 | - $object->handleCommand('default', ''); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand |
|
| 117 | - */ |
|
| 118 | - public function testCommandDefault() |
|
| 119 | - { |
|
| 120 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 121 | - |
|
| 122 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 123 | - |
|
| 124 | - $object->handleCommand('default', '123.45.67.89'); |
|
| 125 | - |
|
| 126 | - $this->assertSame(array( |
|
| 127 | - 'type' => 'string', |
|
| 128 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 129 | - 'default' => '123.45.67.89', |
|
| 130 | - ), $object->toArray()); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - protected function setUp(): void |
|
| 134 | - { |
|
| 135 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - protected function assertPreConditions(): void |
|
| 139 | - { |
|
| 140 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 141 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructNotAnIpv4() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Not an IPv4: 'wrong'"); |
|
| 17 | + |
|
| 18 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstruct() |
|
| 25 | + { |
|
| 26 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 27 | + |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array( |
|
| 31 | + 'type' => 'string', |
|
| 32 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 33 | + ), $object->toArray()); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 38 | + */ |
|
| 39 | + public function testConstructEmptyDefault() |
|
| 40 | + { |
|
| 41 | + $this->expectException('\SwaggerGen\Exception', "Unparseable IPv4 definition: 'ipv4='"); |
|
| 42 | + |
|
| 43 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= '); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructDefaultRange() |
|
| 50 | + { |
|
| 51 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '127.0.256.0'"); |
|
| 52 | + |
|
| 53 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=127.0.256.0'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 58 | + */ |
|
| 59 | + public function testConstructDefault3Numbers() |
|
| 60 | + { |
|
| 61 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0'"); |
|
| 62 | + |
|
| 63 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0'); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 68 | + */ |
|
| 69 | + public function testConstructDefault5Numbers() |
|
| 70 | + { |
|
| 71 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: '0.0.0.0.0'"); |
|
| 72 | + |
|
| 73 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=0.0.0.0.0'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 78 | + */ |
|
| 79 | + public function testConstructDefaultUntrimmed() |
|
| 80 | + { |
|
| 81 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv4 default value: ' 0.0.0.0.0'"); |
|
| 82 | + |
|
| 83 | + new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4= 0.0.0.0.0'); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type::__construct |
|
| 88 | + */ |
|
| 89 | + public function testConstructDefault() |
|
| 90 | + { |
|
| 91 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4=123.45.67.89'); |
|
| 92 | + |
|
| 93 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 94 | + |
|
| 95 | + $this->assertSame(array( |
|
| 96 | + 'type' => 'string', |
|
| 97 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 98 | + 'default' => '123.45.67.89', |
|
| 99 | + ), $object->toArray()); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand |
|
| 104 | + */ |
|
| 105 | + public function testCommandDefaultNoValue() |
|
| 106 | + { |
|
| 107 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 108 | + |
|
| 109 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 110 | + |
|
| 111 | + $this->expectException('\SwaggerGen\Exception', "Empty IPv4 default"); |
|
| 112 | + $object->handleCommand('default', ''); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv4Type->handleCommand |
|
| 117 | + */ |
|
| 118 | + public function testCommandDefault() |
|
| 119 | + { |
|
| 120 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv4Type($this->parent, 'ipv4'); |
|
| 121 | + |
|
| 122 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv4Type', $object); |
|
| 123 | + |
|
| 124 | + $object->handleCommand('default', '123.45.67.89'); |
|
| 125 | + |
|
| 126 | + $this->assertSame(array( |
|
| 127 | + 'type' => 'string', |
|
| 128 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv4Type::PATTERN, |
|
| 129 | + 'default' => '123.45.67.89', |
|
| 130 | + ), $object->toArray()); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + protected function setUp(): void |
|
| 134 | + { |
|
| 135 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + protected function assertPreConditions(): void |
|
| 139 | + { |
|
| 140 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | } |
@@ -6,154 +6,154 @@ |
||
| 6 | 6 | class Ipv6TypeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructNotAnIpv6() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'"); |
|
| 17 | - |
|
| 18 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstruct() |
|
| 25 | - { |
|
| 26 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 27 | - |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array( |
|
| 31 | - 'type' => 'string', |
|
| 32 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 33 | - ), $object->toArray()); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 38 | - */ |
|
| 39 | - public function testConstructEmptyDefault() |
|
| 40 | - { |
|
| 41 | - $this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='"); |
|
| 42 | - |
|
| 43 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= '); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructDefaultTooManyDigits() |
|
| 50 | - { |
|
| 51 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 52 | - |
|
| 53 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 58 | - */ |
|
| 59 | - public function testConstructDefaultTooFewParts() |
|
| 60 | - { |
|
| 61 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 62 | - |
|
| 63 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 68 | - */ |
|
| 69 | - public function testConstructDefaultTooManyParts() |
|
| 70 | - { |
|
| 71 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 72 | - |
|
| 73 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 78 | - */ |
|
| 79 | - public function testConstructDefaultUntrimmed() |
|
| 80 | - { |
|
| 81 | - $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 82 | - |
|
| 83 | - new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 88 | - */ |
|
| 89 | - public function testConstructDefault() |
|
| 90 | - { |
|
| 91 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 92 | - |
|
| 93 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 94 | - |
|
| 95 | - $this->assertSame(array( |
|
| 96 | - 'type' => 'string', |
|
| 97 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 98 | - 'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344', |
|
| 99 | - ), $object->toArray()); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 104 | - */ |
|
| 105 | - public function testConstructDefaultNoZeroes() |
|
| 106 | - { |
|
| 107 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344'); |
|
| 108 | - |
|
| 109 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 110 | - |
|
| 111 | - $this->assertSame(array( |
|
| 112 | - 'type' => 'string', |
|
| 113 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 114 | - 'default' => '2001:0db8:85a3::1319:8a2e:0370:7344', |
|
| 115 | - ), $object->toArray()); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand |
|
| 120 | - */ |
|
| 121 | - public function testCommandDefaultNoValue() |
|
| 122 | - { |
|
| 123 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 124 | - |
|
| 125 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 126 | - |
|
| 127 | - $this->expectException('\SwaggerGen\Exception', "Empty IPv6 default"); |
|
| 128 | - $object->handleCommand('default', ''); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand |
|
| 133 | - */ |
|
| 134 | - public function testCommandDefault() |
|
| 135 | - { |
|
| 136 | - $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 137 | - |
|
| 138 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 139 | - |
|
| 140 | - $object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 141 | - |
|
| 142 | - $this->assertSame(array( |
|
| 143 | - 'type' => 'string', |
|
| 144 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 145 | - 'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344', |
|
| 146 | - ), $object->toArray()); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - protected function setUp(): void |
|
| 150 | - { |
|
| 151 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - protected function assertPreConditions(): void |
|
| 155 | - { |
|
| 156 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 157 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructNotAnIpv6() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Not an IPv6: 'wrong'"); |
|
| 17 | + |
|
| 18 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstruct() |
|
| 25 | + { |
|
| 26 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 27 | + |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array( |
|
| 31 | + 'type' => 'string', |
|
| 32 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 33 | + ), $object->toArray()); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 38 | + */ |
|
| 39 | + public function testConstructEmptyDefault() |
|
| 40 | + { |
|
| 41 | + $this->expectException('\SwaggerGen\Exception', "Unparseable IPv6 definition: 'ipv6='"); |
|
| 42 | + |
|
| 43 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= '); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructDefaultTooManyDigits() |
|
| 50 | + { |
|
| 51 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '12001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 52 | + |
|
| 53 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=12001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 58 | + */ |
|
| 59 | + public function testConstructDefaultTooFewParts() |
|
| 60 | + { |
|
| 61 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 62 | + |
|
| 63 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 68 | + */ |
|
| 69 | + public function testConstructDefaultTooManyParts() |
|
| 70 | + { |
|
| 71 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: '2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 72 | + |
|
| 73 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 78 | + */ |
|
| 79 | + public function testConstructDefaultUntrimmed() |
|
| 80 | + { |
|
| 81 | + $this->expectException('\SwaggerGen\Exception', "Invalid IPv6 default value: ' 2001:0db8:85a3:0000:1319:8a2e:0370:7344'"); |
|
| 82 | + |
|
| 83 | + new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6= 2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 88 | + */ |
|
| 89 | + public function testConstructDefault() |
|
| 90 | + { |
|
| 91 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 92 | + |
|
| 93 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 94 | + |
|
| 95 | + $this->assertSame(array( |
|
| 96 | + 'type' => 'string', |
|
| 97 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 98 | + 'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344', |
|
| 99 | + ), $object->toArray()); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type::__construct |
|
| 104 | + */ |
|
| 105 | + public function testConstructDefaultNoZeroes() |
|
| 106 | + { |
|
| 107 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6=2001:0db8:85a3::1319:8a2e:0370:7344'); |
|
| 108 | + |
|
| 109 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 110 | + |
|
| 111 | + $this->assertSame(array( |
|
| 112 | + 'type' => 'string', |
|
| 113 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 114 | + 'default' => '2001:0db8:85a3::1319:8a2e:0370:7344', |
|
| 115 | + ), $object->toArray()); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand |
|
| 120 | + */ |
|
| 121 | + public function testCommandDefaultNoValue() |
|
| 122 | + { |
|
| 123 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 124 | + |
|
| 125 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 126 | + |
|
| 127 | + $this->expectException('\SwaggerGen\Exception', "Empty IPv6 default"); |
|
| 128 | + $object->handleCommand('default', ''); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @covers \SwaggerGen\Swagger\Type\Custom\Ipv6Type->handleCommand |
|
| 133 | + */ |
|
| 134 | + public function testCommandDefault() |
|
| 135 | + { |
|
| 136 | + $object = new SwaggerGen\Swagger\Type\Custom\Ipv6Type($this->parent, 'ipv6'); |
|
| 137 | + |
|
| 138 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\Ipv6Type', $object); |
|
| 139 | + |
|
| 140 | + $object->handleCommand('default', '2001:0db8:85a3:0000:1319:8a2e:0370:7344'); |
|
| 141 | + |
|
| 142 | + $this->assertSame(array( |
|
| 143 | + 'type' => 'string', |
|
| 144 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\Ipv6Type::PATTERN, |
|
| 145 | + 'default' => '2001:0db8:85a3:0000:1319:8a2e:0370:7344', |
|
| 146 | + ), $object->toArray()); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + protected function setUp(): void |
|
| 150 | + { |
|
| 151 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + protected function assertPreConditions(): void |
|
| 155 | + { |
|
| 156 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | } |
@@ -6,148 +6,148 @@ |
||
| 6 | 6 | class MacTypeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructNotAnMac() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'"); |
|
| 17 | - |
|
| 18 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstruct() |
|
| 25 | - { |
|
| 26 | - $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 27 | - |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array( |
|
| 31 | - 'type' => 'string', |
|
| 32 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 33 | - ), $object->toArray()); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 38 | - */ |
|
| 39 | - public function testConstructEmptyDefault() |
|
| 40 | - { |
|
| 41 | - $this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='"); |
|
| 42 | - |
|
| 43 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= '); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructDefaultTooFewBytes() |
|
| 50 | - { |
|
| 51 | - $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'"); |
|
| 52 | - |
|
| 53 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 58 | - */ |
|
| 59 | - public function testConstructDefaultTooManyBytes() |
|
| 60 | - { |
|
| 61 | - $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'"); |
|
| 62 | - |
|
| 63 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF'); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 68 | - */ |
|
| 69 | - public function testConstructDefaultTooFewDigits() |
|
| 70 | - { |
|
| 71 | - $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'"); |
|
| 72 | - |
|
| 73 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 78 | - */ |
|
| 79 | - public function testConstructDefaultTooManyDigits() |
|
| 80 | - { |
|
| 81 | - $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'"); |
|
| 82 | - |
|
| 83 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 88 | - */ |
|
| 89 | - public function testConstructDefaultUntrimmed() |
|
| 90 | - { |
|
| 91 | - $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'"); |
|
| 92 | - |
|
| 93 | - new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 98 | - */ |
|
| 99 | - public function testConstructDefault() |
|
| 100 | - { |
|
| 101 | - $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF'); |
|
| 102 | - |
|
| 103 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 104 | - |
|
| 105 | - $this->assertSame(array( |
|
| 106 | - 'type' => 'string', |
|
| 107 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 108 | - 'default' => 'FF:FF:FF:FF:FF:FF', |
|
| 109 | - ), $object->toArray()); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand |
|
| 114 | - */ |
|
| 115 | - public function testCommandDefaultNoValue() |
|
| 116 | - { |
|
| 117 | - $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 118 | - |
|
| 119 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 120 | - |
|
| 121 | - $this->expectException('\SwaggerGen\Exception', "Empty MAC default"); |
|
| 122 | - $object->handleCommand('default', ''); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand |
|
| 127 | - */ |
|
| 128 | - public function testCommandDefault() |
|
| 129 | - { |
|
| 130 | - $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 131 | - |
|
| 132 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 133 | - |
|
| 134 | - $object->handleCommand('default', 'FF:FF:FF:FF:FF:FF'); |
|
| 135 | - |
|
| 136 | - $this->assertSame(array( |
|
| 137 | - 'type' => 'string', |
|
| 138 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 139 | - 'default' => 'FF:FF:FF:FF:FF:FF', |
|
| 140 | - ), $object->toArray()); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - protected function setUp(): void |
|
| 144 | - { |
|
| 145 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - protected function assertPreConditions(): void |
|
| 149 | - { |
|
| 150 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 151 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructNotAnMac() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Not a MAC: 'wrong'"); |
|
| 17 | + |
|
| 18 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstruct() |
|
| 25 | + { |
|
| 26 | + $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 27 | + |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array( |
|
| 31 | + 'type' => 'string', |
|
| 32 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 33 | + ), $object->toArray()); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 38 | + */ |
|
| 39 | + public function testConstructEmptyDefault() |
|
| 40 | + { |
|
| 41 | + $this->expectException('\SwaggerGen\Exception', "Unparseable MAC definition: 'mac='"); |
|
| 42 | + |
|
| 43 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= '); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructDefaultTooFewBytes() |
|
| 50 | + { |
|
| 51 | + $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF'"); |
|
| 52 | + |
|
| 53 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 58 | + */ |
|
| 59 | + public function testConstructDefaultTooManyBytes() |
|
| 60 | + { |
|
| 61 | + $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FF:FF:FF:FF:FF:FF:FF'"); |
|
| 62 | + |
|
| 63 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF:FF'); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 68 | + */ |
|
| 69 | + public function testConstructDefaultTooFewDigits() |
|
| 70 | + { |
|
| 71 | + $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'F:FF:FF:FF:FF:FF'"); |
|
| 72 | + |
|
| 73 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=F:FF:FF:FF:FF:FF'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 78 | + */ |
|
| 79 | + public function testConstructDefaultTooManyDigits() |
|
| 80 | + { |
|
| 81 | + $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: 'FFF:FF:FF:FF:FF:FF'"); |
|
| 82 | + |
|
| 83 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FFF:FF:FF:FF:FF:FF'); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 88 | + */ |
|
| 89 | + public function testConstructDefaultUntrimmed() |
|
| 90 | + { |
|
| 91 | + $this->expectException('\SwaggerGen\Exception', "Invalid MAC default value: ' FF:FF:FF:FF:FF:FF'"); |
|
| 92 | + |
|
| 93 | + new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac= FF:FF:FF:FF:FF:FF'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType::__construct |
|
| 98 | + */ |
|
| 99 | + public function testConstructDefault() |
|
| 100 | + { |
|
| 101 | + $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac=FF:FF:FF:FF:FF:FF'); |
|
| 102 | + |
|
| 103 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 104 | + |
|
| 105 | + $this->assertSame(array( |
|
| 106 | + 'type' => 'string', |
|
| 107 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 108 | + 'default' => 'FF:FF:FF:FF:FF:FF', |
|
| 109 | + ), $object->toArray()); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand |
|
| 114 | + */ |
|
| 115 | + public function testCommandDefaultNoValue() |
|
| 116 | + { |
|
| 117 | + $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 118 | + |
|
| 119 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 120 | + |
|
| 121 | + $this->expectException('\SwaggerGen\Exception', "Empty MAC default"); |
|
| 122 | + $object->handleCommand('default', ''); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @covers \SwaggerGen\Swagger\Type\Custom\MacType->handleCommand |
|
| 127 | + */ |
|
| 128 | + public function testCommandDefault() |
|
| 129 | + { |
|
| 130 | + $object = new SwaggerGen\Swagger\Type\Custom\MacType($this->parent, 'mac'); |
|
| 131 | + |
|
| 132 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\MacType', $object); |
|
| 133 | + |
|
| 134 | + $object->handleCommand('default', 'FF:FF:FF:FF:FF:FF'); |
|
| 135 | + |
|
| 136 | + $this->assertSame(array( |
|
| 137 | + 'type' => 'string', |
|
| 138 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\MacType::PATTERN, |
|
| 139 | + 'default' => 'FF:FF:FF:FF:FF:FF', |
|
| 140 | + ), $object->toArray()); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + protected function setUp(): void |
|
| 144 | + { |
|
| 145 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + protected function assertPreConditions(): void |
|
| 149 | + { |
|
| 150 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | } |
@@ -6,118 +6,118 @@ |
||
| 6 | 6 | class EmailTypeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructNotAnEmail() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'"); |
|
| 17 | - |
|
| 18 | - new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstruct() |
|
| 25 | - { |
|
| 26 | - $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 27 | - |
|
| 28 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 29 | - |
|
| 30 | - $this->assertSame(array( |
|
| 31 | - 'type' => 'string', |
|
| 32 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 33 | - ), $object->toArray()); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 38 | - */ |
|
| 39 | - public function testConstructEmptyDefault() |
|
| 40 | - { |
|
| 41 | - $this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='"); |
|
| 42 | - |
|
| 43 | - new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= '); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 48 | - */ |
|
| 49 | - public function testConstructDefaultDoubleAt() |
|
| 50 | - { |
|
| 51 | - $this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'"); |
|
| 52 | - |
|
| 53 | - new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]'); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 58 | - */ |
|
| 59 | - public function testConstructDefaultUntrimmed() |
|
| 60 | - { |
|
| 61 | - $this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'"); |
|
| 62 | - |
|
| 63 | - new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]'); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 68 | - */ |
|
| 69 | - public function testConstructDefault() |
|
| 70 | - { |
|
| 71 | - $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]'); |
|
| 72 | - |
|
| 73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 74 | - |
|
| 75 | - $this->assertSame(array( |
|
| 76 | - 'type' => 'string', |
|
| 77 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 78 | - 'default' => '[email protected]', |
|
| 79 | - ), $object->toArray()); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand |
|
| 84 | - */ |
|
| 85 | - public function testCommandDefaultNoValue() |
|
| 86 | - { |
|
| 87 | - $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 88 | - |
|
| 89 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 90 | - |
|
| 91 | - $this->expectException('\SwaggerGen\Exception', "Empty email default"); |
|
| 92 | - $object->handleCommand('default', ''); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand |
|
| 97 | - */ |
|
| 98 | - public function testCommandDefault() |
|
| 99 | - { |
|
| 100 | - $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 101 | - |
|
| 102 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 103 | - |
|
| 104 | - $object->handleCommand('default', '[email protected]'); |
|
| 105 | - |
|
| 106 | - $this->assertSame(array( |
|
| 107 | - 'type' => 'string', |
|
| 108 | - 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 109 | - 'default' => '[email protected]', |
|
| 110 | - ), $object->toArray()); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - protected function setUp(): void |
|
| 114 | - { |
|
| 115 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - protected function assertPreConditions(): void |
|
| 119 | - { |
|
| 120 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 121 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructNotAnEmail() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Not an email: 'wrong'"); |
|
| 17 | + |
|
| 18 | + new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstruct() |
|
| 25 | + { |
|
| 26 | + $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 27 | + |
|
| 28 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 29 | + |
|
| 30 | + $this->assertSame(array( |
|
| 31 | + 'type' => 'string', |
|
| 32 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 33 | + ), $object->toArray()); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 38 | + */ |
|
| 39 | + public function testConstructEmptyDefault() |
|
| 40 | + { |
|
| 41 | + $this->expectException('\SwaggerGen\Exception', "Unparseable email definition: 'email='"); |
|
| 42 | + |
|
| 43 | + new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= '); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 48 | + */ |
|
| 49 | + public function testConstructDefaultDoubleAt() |
|
| 50 | + { |
|
| 51 | + $this->expectException('\SwaggerGen\Exception', "Invalid email default value: 'test@[email protected]'"); |
|
| 52 | + |
|
| 53 | + new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email=test@[email protected]'); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 58 | + */ |
|
| 59 | + public function testConstructDefaultUntrimmed() |
|
| 60 | + { |
|
| 61 | + $this->expectException('\SwaggerGen\Exception', "Invalid email default value: ' [email protected]'"); |
|
| 62 | + |
|
| 63 | + new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email= [email protected]'); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType::__construct |
|
| 68 | + */ |
|
| 69 | + public function testConstructDefault() |
|
| 70 | + { |
|
| 71 | + $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, '[email protected]'); |
|
| 72 | + |
|
| 73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 74 | + |
|
| 75 | + $this->assertSame(array( |
|
| 76 | + 'type' => 'string', |
|
| 77 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 78 | + 'default' => '[email protected]', |
|
| 79 | + ), $object->toArray()); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand |
|
| 84 | + */ |
|
| 85 | + public function testCommandDefaultNoValue() |
|
| 86 | + { |
|
| 87 | + $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 88 | + |
|
| 89 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 90 | + |
|
| 91 | + $this->expectException('\SwaggerGen\Exception', "Empty email default"); |
|
| 92 | + $object->handleCommand('default', ''); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @covers \SwaggerGen\Swagger\Type\Custom\EmailType->handleCommand |
|
| 97 | + */ |
|
| 98 | + public function testCommandDefault() |
|
| 99 | + { |
|
| 100 | + $object = new SwaggerGen\Swagger\Type\Custom\EmailType($this->parent, 'email'); |
|
| 101 | + |
|
| 102 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Custom\EmailType', $object); |
|
| 103 | + |
|
| 104 | + $object->handleCommand('default', '[email protected]'); |
|
| 105 | + |
|
| 106 | + $this->assertSame(array( |
|
| 107 | + 'type' => 'string', |
|
| 108 | + 'pattern' => \SwaggerGen\Swagger\Type\Custom\EmailType::PATTERN, |
|
| 109 | + 'default' => '[email protected]', |
|
| 110 | + ), $object->toArray()); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + protected function setUp(): void |
|
| 114 | + { |
|
| 115 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + protected function assertPreConditions(): void |
|
| 119 | + { |
|
| 120 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | } |
@@ -6,112 +6,112 @@ |
||
| 6 | 6 | class FileTypeTest extends TestCase |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $parent; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 13 | - */ |
|
| 14 | - public function testConstructNotAFile() |
|
| 15 | - { |
|
| 16 | - $this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'"); |
|
| 17 | - |
|
| 18 | - $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 23 | - */ |
|
| 24 | - public function testConstructNotParameter() |
|
| 25 | - { |
|
| 26 | - $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter"); |
|
| 27 | - |
|
| 28 | - $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file'); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 33 | - */ |
|
| 34 | - public function testConstructNotFormParameter() |
|
| 35 | - { |
|
| 36 | - $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter"); |
|
| 37 | - |
|
| 38 | - $parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever'); |
|
| 39 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 44 | - */ |
|
| 45 | - public function testConstructNoFormConsumes() |
|
| 46 | - { |
|
| 47 | - $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume"); |
|
| 48 | - |
|
| 49 | - $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 50 | - $operation->handleCommand('consumes', 'text'); |
|
| 51 | - $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 52 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 57 | - */ |
|
| 58 | - public function testConstructNotExclusiveFormConsumes() |
|
| 59 | - { |
|
| 60 | - $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume"); |
|
| 61 | - |
|
| 62 | - $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 63 | - $operation->handleCommand('consumes', 'text file'); |
|
| 64 | - $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 65 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 70 | - */ |
|
| 71 | - public function testConstructFormConsumes() |
|
| 72 | - { |
|
| 73 | - $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 74 | - $operation->handleCommand('consumes', 'form'); |
|
| 75 | - $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 76 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 81 | - */ |
|
| 82 | - public function testConstructFileformConsumes() |
|
| 83 | - { |
|
| 84 | - $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 85 | - $operation->handleCommand('consumes', 'fileform'); |
|
| 86 | - $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 87 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 92 | - */ |
|
| 93 | - public function testConstructBothConsumes() |
|
| 94 | - { |
|
| 95 | - $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 96 | - $operation->handleCommand('consumes', 'fileform form'); |
|
| 97 | - $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 98 | - $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 99 | - |
|
| 100 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object); |
|
| 101 | - |
|
| 102 | - $this->assertSame(array( |
|
| 103 | - 'type' => 'file', |
|
| 104 | - ), $object->toArray()); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - protected function setUp(): void |
|
| 108 | - { |
|
| 109 | - $this->parent = new \SwaggerGen\Swagger\Swagger; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - protected function assertPreConditions(): void |
|
| 113 | - { |
|
| 114 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 115 | - } |
|
| 9 | + protected $parent; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 13 | + */ |
|
| 14 | + public function testConstructNotAFile() |
|
| 15 | + { |
|
| 16 | + $this->expectException('\SwaggerGen\Exception', "Not a file: 'wrong'"); |
|
| 17 | + |
|
| 18 | + $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'wrong'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 23 | + */ |
|
| 24 | + public function testConstructNotParameter() |
|
| 25 | + { |
|
| 26 | + $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter"); |
|
| 27 | + |
|
| 28 | + $object = new SwaggerGen\Swagger\Type\FileType($this->parent, 'file'); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 33 | + */ |
|
| 34 | + public function testConstructNotFormParameter() |
|
| 35 | + { |
|
| 36 | + $this->expectException('\SwaggerGen\Exception', "File type 'file' only allowed on form parameter"); |
|
| 37 | + |
|
| 38 | + $parameter = new SwaggerGen\Swagger\Parameter($this->parent, 'query', 'long whatever'); |
|
| 39 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 44 | + */ |
|
| 45 | + public function testConstructNoFormConsumes() |
|
| 46 | + { |
|
| 47 | + $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume"); |
|
| 48 | + |
|
| 49 | + $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 50 | + $operation->handleCommand('consumes', 'text'); |
|
| 51 | + $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 52 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 57 | + */ |
|
| 58 | + public function testConstructNotExclusiveFormConsumes() |
|
| 59 | + { |
|
| 60 | + $this->expectException('\SwaggerGen\Exception', "File type 'file' without valid consume"); |
|
| 61 | + |
|
| 62 | + $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 63 | + $operation->handleCommand('consumes', 'text file'); |
|
| 64 | + $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 65 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 70 | + */ |
|
| 71 | + public function testConstructFormConsumes() |
|
| 72 | + { |
|
| 73 | + $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 74 | + $operation->handleCommand('consumes', 'form'); |
|
| 75 | + $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 76 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 81 | + */ |
|
| 82 | + public function testConstructFileformConsumes() |
|
| 83 | + { |
|
| 84 | + $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 85 | + $operation->handleCommand('consumes', 'fileform'); |
|
| 86 | + $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 87 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @covers \SwaggerGen\Swagger\Type\FileType::__construct |
|
| 92 | + */ |
|
| 93 | + public function testConstructBothConsumes() |
|
| 94 | + { |
|
| 95 | + $operation = new SwaggerGen\Swagger\Operation($this->parent); |
|
| 96 | + $operation->handleCommand('consumes', 'fileform form'); |
|
| 97 | + $parameter = new SwaggerGen\Swagger\Parameter($operation, 'form', 'long whatever'); |
|
| 98 | + $object = new SwaggerGen\Swagger\Type\FileType($parameter, 'file'); |
|
| 99 | + |
|
| 100 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\FileType', $object); |
|
| 101 | + |
|
| 102 | + $this->assertSame(array( |
|
| 103 | + 'type' => 'file', |
|
| 104 | + ), $object->toArray()); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + protected function setUp(): void |
|
| 108 | + { |
|
| 109 | + $this->parent = new \SwaggerGen\Swagger\Swagger; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + protected function assertPreConditions(): void |
|
| 113 | + { |
|
| 114 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | } |