@@ -6,187 +6,187 @@ |
||
6 | 6 | class DateTypeTest extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - protected $parent; |
|
10 | - |
|
11 | - /** |
|
12 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
13 | - */ |
|
14 | - public function testConstructNotADate() |
|
15 | - { |
|
16 | - $this->expectException('\SwaggerGen\Exception', "Not a date: 'wrong'"); |
|
17 | - |
|
18 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'wrong'); |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
23 | - */ |
|
24 | - public function testConstructRange() |
|
25 | - { |
|
26 | - $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date[1,]'"); |
|
27 | - |
|
28 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date[1,]'); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
33 | - */ |
|
34 | - public function testConstructParentheses() |
|
35 | - { |
|
36 | - $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date()'"); |
|
37 | - |
|
38 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date()'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
43 | - */ |
|
44 | - public function testConstructDate() |
|
45 | - { |
|
46 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
47 | - |
|
48 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
49 | - |
|
50 | - $this->assertSame(array( |
|
51 | - 'type' => 'string', |
|
52 | - 'format' => 'date', |
|
53 | - ), $object->toArray()); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
58 | - */ |
|
59 | - public function testConstructDateTime() |
|
60 | - { |
|
61 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'datetime'); |
|
62 | - |
|
63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
64 | - |
|
65 | - $this->assertSame(array( |
|
66 | - 'type' => 'string', |
|
67 | - 'format' => 'date-time', |
|
68 | - ), $object->toArray()); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
73 | - */ |
|
74 | - public function testConstructDateDefaultEmpty() |
|
75 | - { |
|
76 | - $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date='"); |
|
77 | - |
|
78 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date='); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
83 | - */ |
|
84 | - public function testConstructDateDefaultBlank() |
|
85 | - { |
|
86 | - $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date= '"); |
|
87 | - |
|
88 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date= '); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
93 | - */ |
|
94 | - public function testConstructDateDefaultWrong() |
|
95 | - { |
|
96 | - $this->expectException('\SwaggerGen\Exception', "Invalid 'date' default: 'wrong'"); |
|
97 | - |
|
98 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date=wrong'); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
103 | - */ |
|
104 | - public function testConstructDateDefault() |
|
105 | - { |
|
106 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date=1999-12-31'); |
|
107 | - |
|
108 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
109 | - |
|
110 | - $this->assertSame(array( |
|
111 | - 'type' => 'string', |
|
112 | - 'format' => 'date', |
|
113 | - 'default' => '1999-12-31', |
|
114 | - ), $object->toArray()); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
119 | - */ |
|
120 | - public function testConstructDateTimeDefault() |
|
121 | - { |
|
122 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'datetime=1999-12-31T23:59:59+11:00'); |
|
123 | - |
|
124 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
125 | - |
|
126 | - $this->assertSame(array( |
|
127 | - 'type' => 'string', |
|
128 | - 'format' => 'date-time', |
|
129 | - 'default' => '1999-12-31T23:59:59+11:00', |
|
130 | - ), $object->toArray()); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
135 | - */ |
|
136 | - public function testCommandDefaultNoValue() |
|
137 | - { |
|
138 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
139 | - |
|
140 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
141 | - |
|
142 | - $this->expectException('\SwaggerGen\Exception', "Empty date default"); |
|
143 | - $object->handleCommand('default', ''); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
148 | - */ |
|
149 | - public function testCommandDefaultWrong() |
|
150 | - { |
|
151 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
152 | - |
|
153 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
154 | - |
|
155 | - $this->expectException('\SwaggerGen\Exception', "Invalid 'date' default: 'wrong'"); |
|
156 | - $object->handleCommand('default', 'wrong'); |
|
157 | - |
|
158 | - $this->assertSame(array( |
|
159 | - 'type' => 'string', |
|
160 | - 'default' => 'date', |
|
161 | - ), $object->toArray()); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
166 | - */ |
|
167 | - public function testCommandDefault() |
|
168 | - { |
|
169 | - $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
170 | - |
|
171 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
172 | - |
|
173 | - $object->handleCommand('default', '1999-12-31'); |
|
174 | - |
|
175 | - $this->assertSame(array( |
|
176 | - 'type' => 'string', |
|
177 | - 'format' => 'date', |
|
178 | - 'default' => '1999-12-31', |
|
179 | - ), $object->toArray()); |
|
180 | - } |
|
181 | - |
|
182 | - protected function setUp(): void |
|
183 | - { |
|
184 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
185 | - } |
|
186 | - |
|
187 | - protected function assertPreConditions(): void |
|
188 | - { |
|
189 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
190 | - } |
|
9 | + protected $parent; |
|
10 | + |
|
11 | + /** |
|
12 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
13 | + */ |
|
14 | + public function testConstructNotADate() |
|
15 | + { |
|
16 | + $this->expectException('\SwaggerGen\Exception', "Not a date: 'wrong'"); |
|
17 | + |
|
18 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'wrong'); |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
23 | + */ |
|
24 | + public function testConstructRange() |
|
25 | + { |
|
26 | + $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date[1,]'"); |
|
27 | + |
|
28 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date[1,]'); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
33 | + */ |
|
34 | + public function testConstructParentheses() |
|
35 | + { |
|
36 | + $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date()'"); |
|
37 | + |
|
38 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date()'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
43 | + */ |
|
44 | + public function testConstructDate() |
|
45 | + { |
|
46 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
47 | + |
|
48 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
49 | + |
|
50 | + $this->assertSame(array( |
|
51 | + 'type' => 'string', |
|
52 | + 'format' => 'date', |
|
53 | + ), $object->toArray()); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
58 | + */ |
|
59 | + public function testConstructDateTime() |
|
60 | + { |
|
61 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'datetime'); |
|
62 | + |
|
63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
64 | + |
|
65 | + $this->assertSame(array( |
|
66 | + 'type' => 'string', |
|
67 | + 'format' => 'date-time', |
|
68 | + ), $object->toArray()); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
73 | + */ |
|
74 | + public function testConstructDateDefaultEmpty() |
|
75 | + { |
|
76 | + $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date='"); |
|
77 | + |
|
78 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date='); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
83 | + */ |
|
84 | + public function testConstructDateDefaultBlank() |
|
85 | + { |
|
86 | + $this->expectException('\SwaggerGen\Exception', "Unparseable date definition: 'date= '"); |
|
87 | + |
|
88 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date= '); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
93 | + */ |
|
94 | + public function testConstructDateDefaultWrong() |
|
95 | + { |
|
96 | + $this->expectException('\SwaggerGen\Exception', "Invalid 'date' default: 'wrong'"); |
|
97 | + |
|
98 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date=wrong'); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
103 | + */ |
|
104 | + public function testConstructDateDefault() |
|
105 | + { |
|
106 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date=1999-12-31'); |
|
107 | + |
|
108 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
109 | + |
|
110 | + $this->assertSame(array( |
|
111 | + 'type' => 'string', |
|
112 | + 'format' => 'date', |
|
113 | + 'default' => '1999-12-31', |
|
114 | + ), $object->toArray()); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @covers \SwaggerGen\Swagger\Type\DateType::__construct |
|
119 | + */ |
|
120 | + public function testConstructDateTimeDefault() |
|
121 | + { |
|
122 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'datetime=1999-12-31T23:59:59+11:00'); |
|
123 | + |
|
124 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
125 | + |
|
126 | + $this->assertSame(array( |
|
127 | + 'type' => 'string', |
|
128 | + 'format' => 'date-time', |
|
129 | + 'default' => '1999-12-31T23:59:59+11:00', |
|
130 | + ), $object->toArray()); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
135 | + */ |
|
136 | + public function testCommandDefaultNoValue() |
|
137 | + { |
|
138 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
139 | + |
|
140 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
141 | + |
|
142 | + $this->expectException('\SwaggerGen\Exception', "Empty date default"); |
|
143 | + $object->handleCommand('default', ''); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
148 | + */ |
|
149 | + public function testCommandDefaultWrong() |
|
150 | + { |
|
151 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
152 | + |
|
153 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
154 | + |
|
155 | + $this->expectException('\SwaggerGen\Exception', "Invalid 'date' default: 'wrong'"); |
|
156 | + $object->handleCommand('default', 'wrong'); |
|
157 | + |
|
158 | + $this->assertSame(array( |
|
159 | + 'type' => 'string', |
|
160 | + 'default' => 'date', |
|
161 | + ), $object->toArray()); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @covers \SwaggerGen\Swagger\Type\DateType->handleCommand |
|
166 | + */ |
|
167 | + public function testCommandDefault() |
|
168 | + { |
|
169 | + $object = new SwaggerGen\Swagger\Type\DateType($this->parent, 'date'); |
|
170 | + |
|
171 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\DateType', $object); |
|
172 | + |
|
173 | + $object->handleCommand('default', '1999-12-31'); |
|
174 | + |
|
175 | + $this->assertSame(array( |
|
176 | + 'type' => 'string', |
|
177 | + 'format' => 'date', |
|
178 | + 'default' => '1999-12-31', |
|
179 | + ), $object->toArray()); |
|
180 | + } |
|
181 | + |
|
182 | + protected function setUp(): void |
|
183 | + { |
|
184 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
185 | + } |
|
186 | + |
|
187 | + protected function assertPreConditions(): void |
|
188 | + { |
|
189 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
@@ -6,160 +6,160 @@ |
||
6 | 6 | class BooleanTypeTest extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - protected $parent; |
|
10 | - |
|
11 | - /** |
|
12 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
13 | - */ |
|
14 | - public function testConstructNotABoolean() |
|
15 | - { |
|
16 | - $this->expectException('\SwaggerGen\Exception', "Not a boolean: 'wrong'"); |
|
17 | - |
|
18 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'wrong'); |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
23 | - */ |
|
24 | - public function testConstructInvalidDefault() |
|
25 | - { |
|
26 | - $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean=null'"); |
|
27 | - |
|
28 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=null'); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
33 | - */ |
|
34 | - public function testConstructNoSpecificationAllowed() |
|
35 | - { |
|
36 | - $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean()=true'"); |
|
37 | - |
|
38 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean()=true'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
43 | - */ |
|
44 | - public function testConstructNoRangeAllowed() |
|
45 | - { |
|
46 | - $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean[0,1]=true'"); |
|
47 | - |
|
48 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean[0,1]=true'); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
53 | - */ |
|
54 | - public function testConstructWithoutDefault() |
|
55 | - { |
|
56 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
57 | - |
|
58 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
59 | - |
|
60 | - $this->assertSame(array( |
|
61 | - 'type' => 'boolean', |
|
62 | - ), $object->toArray()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
67 | - */ |
|
68 | - public function testConstructTrue() |
|
69 | - { |
|
70 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=true'); |
|
71 | - |
|
72 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
73 | - |
|
74 | - $this->assertSame(array( |
|
75 | - 'type' => 'boolean', |
|
76 | - 'default' => true, |
|
77 | - ), $object->toArray()); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
82 | - */ |
|
83 | - public function testConstruct0() |
|
84 | - { |
|
85 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=0'); |
|
86 | - |
|
87 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
88 | - |
|
89 | - $this->assertSame(array( |
|
90 | - 'type' => 'boolean', |
|
91 | - 'default' => false, |
|
92 | - ), $object->toArray()); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
97 | - */ |
|
98 | - public function testCommandDefaultNoValue() |
|
99 | - { |
|
100 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
101 | - |
|
102 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
103 | - |
|
104 | - $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: ''"); |
|
105 | - $object->handleCommand('default', ''); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
110 | - */ |
|
111 | - public function testCommandDefaultInvalidValue() |
|
112 | - { |
|
113 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
114 | - |
|
115 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
116 | - |
|
117 | - $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: 'null'"); |
|
118 | - $object->handleCommand('default', 'null'); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
123 | - */ |
|
124 | - public function testCommandDefaultFalse() |
|
125 | - { |
|
126 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
127 | - |
|
128 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
129 | - |
|
130 | - $object->handleCommand('default', 'false'); |
|
131 | - |
|
132 | - $this->assertSame(array( |
|
133 | - 'type' => 'boolean', |
|
134 | - 'default' => false, |
|
135 | - ), $object->toArray()); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
140 | - */ |
|
141 | - public function testCommandDefault1() |
|
142 | - { |
|
143 | - $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
144 | - |
|
145 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
146 | - |
|
147 | - $object->handleCommand('default', '1'); |
|
148 | - |
|
149 | - $this->assertSame(array( |
|
150 | - 'type' => 'boolean', |
|
151 | - 'default' => true, |
|
152 | - ), $object->toArray()); |
|
153 | - } |
|
154 | - |
|
155 | - protected function setUp(): void |
|
156 | - { |
|
157 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
158 | - } |
|
159 | - |
|
160 | - protected function assertPreConditions(): void |
|
161 | - { |
|
162 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
163 | - } |
|
9 | + protected $parent; |
|
10 | + |
|
11 | + /** |
|
12 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
13 | + */ |
|
14 | + public function testConstructNotABoolean() |
|
15 | + { |
|
16 | + $this->expectException('\SwaggerGen\Exception', "Not a boolean: 'wrong'"); |
|
17 | + |
|
18 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'wrong'); |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
23 | + */ |
|
24 | + public function testConstructInvalidDefault() |
|
25 | + { |
|
26 | + $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean=null'"); |
|
27 | + |
|
28 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=null'); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
33 | + */ |
|
34 | + public function testConstructNoSpecificationAllowed() |
|
35 | + { |
|
36 | + $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean()=true'"); |
|
37 | + |
|
38 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean()=true'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
43 | + */ |
|
44 | + public function testConstructNoRangeAllowed() |
|
45 | + { |
|
46 | + $this->expectException('\SwaggerGen\Exception', "Unparseable boolean definition: 'boolean[0,1]=true'"); |
|
47 | + |
|
48 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean[0,1]=true'); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
53 | + */ |
|
54 | + public function testConstructWithoutDefault() |
|
55 | + { |
|
56 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
57 | + |
|
58 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
59 | + |
|
60 | + $this->assertSame(array( |
|
61 | + 'type' => 'boolean', |
|
62 | + ), $object->toArray()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
67 | + */ |
|
68 | + public function testConstructTrue() |
|
69 | + { |
|
70 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=true'); |
|
71 | + |
|
72 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
73 | + |
|
74 | + $this->assertSame(array( |
|
75 | + 'type' => 'boolean', |
|
76 | + 'default' => true, |
|
77 | + ), $object->toArray()); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @covers \SwaggerGen\Swagger\Type\BooleanType::__construct |
|
82 | + */ |
|
83 | + public function testConstruct0() |
|
84 | + { |
|
85 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean=0'); |
|
86 | + |
|
87 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
88 | + |
|
89 | + $this->assertSame(array( |
|
90 | + 'type' => 'boolean', |
|
91 | + 'default' => false, |
|
92 | + ), $object->toArray()); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
97 | + */ |
|
98 | + public function testCommandDefaultNoValue() |
|
99 | + { |
|
100 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
101 | + |
|
102 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
103 | + |
|
104 | + $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: ''"); |
|
105 | + $object->handleCommand('default', ''); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
110 | + */ |
|
111 | + public function testCommandDefaultInvalidValue() |
|
112 | + { |
|
113 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
114 | + |
|
115 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
116 | + |
|
117 | + $this->expectException('\SwaggerGen\Exception', "Invalid boolean default: 'null'"); |
|
118 | + $object->handleCommand('default', 'null'); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
123 | + */ |
|
124 | + public function testCommandDefaultFalse() |
|
125 | + { |
|
126 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
127 | + |
|
128 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
129 | + |
|
130 | + $object->handleCommand('default', 'false'); |
|
131 | + |
|
132 | + $this->assertSame(array( |
|
133 | + 'type' => 'boolean', |
|
134 | + 'default' => false, |
|
135 | + ), $object->toArray()); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @covers \SwaggerGen\Swagger\Type\BooleanType->handleCommand |
|
140 | + */ |
|
141 | + public function testCommandDefault1() |
|
142 | + { |
|
143 | + $object = new SwaggerGen\Swagger\Type\BooleanType($this->parent, 'boolean'); |
|
144 | + |
|
145 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\BooleanType', $object); |
|
146 | + |
|
147 | + $object->handleCommand('default', '1'); |
|
148 | + |
|
149 | + $this->assertSame(array( |
|
150 | + 'type' => 'boolean', |
|
151 | + 'default' => true, |
|
152 | + ), $object->toArray()); |
|
153 | + } |
|
154 | + |
|
155 | + protected function setUp(): void |
|
156 | + { |
|
157 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
158 | + } |
|
159 | + |
|
160 | + protected function assertPreConditions(): void |
|
161 | + { |
|
162 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
@@ -6,1148 +6,1148 @@ |
||
6 | 6 | class OperationTest extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - protected $parent; |
|
10 | - |
|
11 | - /** |
|
12 | - * @covers \SwaggerGen\Swagger\Operation::__construct |
|
13 | - */ |
|
14 | - public function testConstructor_NoResponse(): void |
|
15 | - { |
|
16 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
17 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
18 | - |
|
19 | - $this->expectException('\SwaggerGen\Exception', "No response defined for operation"); |
|
20 | - $object->toArray(); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
25 | - */ |
|
26 | - public function testConstructor_Summary() |
|
27 | - { |
|
28 | - $object = new \SwaggerGen\Swagger\Operation($this->parent, 'Some words'); |
|
29 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
30 | - |
|
31 | - $return = $object->handleCommand('error', 404); |
|
32 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
33 | - |
|
34 | - $this->assertSame(array( |
|
35 | - 'summary' => 'Some words', |
|
36 | - 'responses' => array( |
|
37 | - 404 => array( |
|
38 | - 'description' => 'Not Found', |
|
39 | - ), |
|
40 | - ), |
|
41 | - ), $object->toArray()); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
46 | - */ |
|
47 | - public function testConstructor_Tag() |
|
48 | - { |
|
49 | - $object = new \SwaggerGen\Swagger\Operation($this->parent, '', new SwaggerGen\Swagger\Tag($this->parent, 'Operations')); |
|
50 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
51 | - |
|
52 | - $return = $object->handleCommand('error', 404); |
|
53 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
54 | - |
|
55 | - $this->assertSame(array( |
|
56 | - 'tags' => array( |
|
57 | - 'Operations', |
|
58 | - ), |
|
59 | - 'responses' => array( |
|
60 | - 404 => array( |
|
61 | - 'description' => 'Not Found', |
|
62 | - ), |
|
63 | - ), |
|
64 | - ), $object->toArray()); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
69 | - */ |
|
70 | - public function testHandleCommand_Summary_Empty() |
|
71 | - { |
|
72 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
74 | - |
|
75 | - $return = $object->handleCommand('summary'); |
|
76 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
77 | - |
|
78 | - $return = $object->handleCommand('response', '200'); |
|
79 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
80 | - |
|
81 | - $this->assertSame(array( |
|
82 | - 'responses' => array( |
|
83 | - 200 => array( |
|
84 | - 'description' => 'OK', |
|
85 | - ), |
|
86 | - ), |
|
87 | - ), $object->toArray()); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
92 | - */ |
|
93 | - public function testHandleCommand_Summary() |
|
94 | - { |
|
95 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
96 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
97 | - |
|
98 | - $return = $object->handleCommand('summary', 'Some words'); |
|
99 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
100 | - |
|
101 | - $return = $object->handleCommand('response', '200'); |
|
102 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
103 | - |
|
104 | - $this->assertSame(array( |
|
105 | - 'summary' => 'Some words', |
|
106 | - 'responses' => array( |
|
107 | - 200 => array( |
|
108 | - 'description' => 'OK', |
|
109 | - ), |
|
110 | - ), |
|
111 | - ), $object->toArray()); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
116 | - */ |
|
117 | - public function testHandleCommand_Description_Empty() |
|
118 | - { |
|
119 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
120 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
121 | - |
|
122 | - $return = $object->handleCommand('description'); |
|
123 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
124 | - |
|
125 | - $return = $object->handleCommand('response', '200'); |
|
126 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
127 | - |
|
128 | - $this->assertSame(array( |
|
129 | - 'responses' => array( |
|
130 | - 200 => array( |
|
131 | - 'description' => 'OK', |
|
132 | - ), |
|
133 | - ), |
|
134 | - ), $object->toArray()); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
139 | - */ |
|
140 | - public function testHandleCommand_Description() |
|
141 | - { |
|
142 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
143 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
144 | - |
|
145 | - $return = $object->handleCommand('description', 'Some words'); |
|
146 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
147 | - |
|
148 | - $return = $object->handleCommand('response', '200'); |
|
149 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
150 | - |
|
151 | - $this->assertSame(array( |
|
152 | - 'description' => 'Some words', |
|
153 | - 'responses' => array( |
|
154 | - 200 => array( |
|
155 | - 'description' => 'OK', |
|
156 | - ), |
|
157 | - ), |
|
158 | - ), $object->toArray()); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
163 | - */ |
|
164 | - public function testHandleCommand_Deprecated() |
|
165 | - { |
|
166 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
167 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
168 | - |
|
169 | - $return = $object->handleCommand('deprecated'); |
|
170 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
171 | - |
|
172 | - $return = $object->handleCommand('response', '200'); |
|
173 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
174 | - |
|
175 | - $this->assertSame(array( |
|
176 | - 'deprecated' => true, |
|
177 | - 'responses' => array( |
|
178 | - 200 => array( |
|
179 | - 'description' => 'OK', |
|
180 | - ), |
|
181 | - ), |
|
182 | - ), $object->toArray()); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
187 | - */ |
|
188 | - public function testHandleCommand_OperationId() |
|
189 | - { |
|
190 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
191 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
192 | - |
|
193 | - $return = $object->handleCommand('id', 'SomeOperation'); |
|
194 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
195 | - |
|
196 | - $return = $object->handleCommand('response', '200'); |
|
197 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
198 | - |
|
199 | - $this->assertSame(array( |
|
200 | - 'operationId' => 'SomeOperation', |
|
201 | - 'responses' => array( |
|
202 | - 200 => array( |
|
203 | - 'description' => 'OK', |
|
204 | - ), |
|
205 | - ), |
|
206 | - ), $object->toArray()); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
211 | - */ |
|
212 | - public function testHandleCommand_OperationId_UniqueInPath() |
|
213 | - { |
|
214 | - $path = $this->parent->handleCommand('endpoint', 'foo'); |
|
215 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
216 | - |
|
217 | - // First occurance |
|
218 | - $operation = $path->handleCommand('operation', 'GET'); |
|
219 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
220 | - |
|
221 | - $return = $operation->handleCommand('id', 'SomeOperation'); |
|
222 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
223 | - |
|
224 | - // Second occurance |
|
225 | - $operation = $path->handleCommand('operation', 'GET'); |
|
226 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
227 | - |
|
228 | - $this->expectException('\SwaggerGen\Exception', "Duplicate operation id 'SomeOperation'"); |
|
229 | - $operation->handleCommand('id', 'SomeOperation'); |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
234 | - */ |
|
235 | - public function testHandleCommand_OperationId_UniqueInSwagger() |
|
236 | - { |
|
237 | - // First occurance |
|
238 | - $path = $this->parent->handleCommand('endpoint', 'foo'); |
|
239 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
240 | - |
|
241 | - $operation = $path->handleCommand('operation', 'GET'); |
|
242 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
243 | - |
|
244 | - $return = $operation->handleCommand('id', 'SomeOperation'); |
|
245 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
246 | - |
|
247 | - // Second occurance |
|
248 | - $path = $this->parent->handleCommand('endpoint', 'bar'); |
|
249 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
250 | - |
|
251 | - $operation = $path->handleCommand('operation', 'GET'); |
|
252 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
253 | - |
|
254 | - $this->expectException('\SwaggerGen\Exception', "Duplicate operation id 'SomeOperation'"); |
|
255 | - $operation->handleCommand('id', 'SomeOperation'); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
260 | - */ |
|
261 | - public function testHandleCommand_Tags_Empty() |
|
262 | - { |
|
263 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
264 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
265 | - |
|
266 | - $return = $object->handleCommand('tags'); |
|
267 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
268 | - |
|
269 | - $return = $object->handleCommand('response', '200'); |
|
270 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
271 | - |
|
272 | - $this->assertSame(array( |
|
273 | - 'responses' => array( |
|
274 | - 200 => array( |
|
275 | - 'description' => 'OK', |
|
276 | - ), |
|
277 | - ), |
|
278 | - ), $object->toArray()); |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
283 | - */ |
|
284 | - public function testHandleCommand_Tags() |
|
285 | - { |
|
286 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
287 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
288 | - |
|
289 | - $return = $object->handleCommand('tags', 'black white'); |
|
290 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
291 | - |
|
292 | - $return = $object->handleCommand('response', '200'); |
|
293 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
294 | - |
|
295 | - $this->assertSame(array( |
|
296 | - 'tags' => array( |
|
297 | - 'black', |
|
298 | - 'white', |
|
299 | - ), |
|
300 | - 'responses' => array( |
|
301 | - 200 => array( |
|
302 | - 'description' => 'OK', |
|
303 | - ), |
|
304 | - ), |
|
305 | - ), $object->toArray()); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
310 | - */ |
|
311 | - public function testHandleCommand_Tags_Append() |
|
312 | - { |
|
313 | - $object = new \SwaggerGen\Swagger\Operation($this->parent, null, new SwaggerGen\Swagger\Tag($this->parent, 'purple')); |
|
314 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
315 | - |
|
316 | - $return = $object->handleCommand('tags', 'black white'); |
|
317 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
318 | - |
|
319 | - $return = $object->handleCommand('tags', 'black green'); |
|
320 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
321 | - |
|
322 | - $return = $object->handleCommand('response', '200'); |
|
323 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
324 | - |
|
325 | - $this->assertSame(array( |
|
326 | - 'tags' => array( |
|
327 | - 'black', |
|
328 | - 'green', |
|
329 | - 'purple', |
|
330 | - 'white', |
|
331 | - ), |
|
332 | - 'responses' => array( |
|
333 | - 200 => array( |
|
334 | - 'description' => 'OK', |
|
335 | - ), |
|
336 | - ), |
|
337 | - ), $object->toArray()); |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
342 | - */ |
|
343 | - public function testHandleCommand_Schemes_Empty() |
|
344 | - { |
|
345 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
346 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
347 | - |
|
348 | - $return = $object->handleCommand('schemes'); |
|
349 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
350 | - |
|
351 | - $return = $object->handleCommand('response', '200'); |
|
352 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
353 | - |
|
354 | - $this->assertSame(array( |
|
355 | - 'responses' => array( |
|
356 | - 200 => array( |
|
357 | - 'description' => 'OK', |
|
358 | - ), |
|
359 | - ), |
|
360 | - ), $object->toArray()); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
365 | - */ |
|
366 | - public function testHandleCommand_Schemes() |
|
367 | - { |
|
368 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
369 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
370 | - |
|
371 | - $return = $object->handleCommand('schemes', 'http https'); |
|
372 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
373 | - |
|
374 | - $return = $object->handleCommand('response', '200'); |
|
375 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
376 | - |
|
377 | - $this->assertSame(array( |
|
378 | - 'schemes' => array( |
|
379 | - 'http', |
|
380 | - 'https', |
|
381 | - ), |
|
382 | - 'responses' => array( |
|
383 | - 200 => array( |
|
384 | - 'description' => 'OK', |
|
385 | - ), |
|
386 | - ), |
|
387 | - ), $object->toArray()); |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
392 | - */ |
|
393 | - public function testHandleCommand_Schemes_Append() |
|
394 | - { |
|
395 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
396 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
397 | - |
|
398 | - $return = $object->handleCommand('schemes', 'ws wss'); |
|
399 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
400 | - |
|
401 | - $return = $object->handleCommand('schemes', 'http ws'); |
|
402 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
403 | - |
|
404 | - $return = $object->handleCommand('response', '200'); |
|
405 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
406 | - |
|
407 | - $this->assertSame(array( |
|
408 | - 'schemes' => array( |
|
409 | - 'http', |
|
410 | - 'ws', |
|
411 | - 'wss', |
|
412 | - ), |
|
413 | - 'responses' => array( |
|
414 | - 200 => array( |
|
415 | - 'description' => 'OK', |
|
416 | - ), |
|
417 | - ), |
|
418 | - ), $object->toArray()); |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
423 | - */ |
|
424 | - public function testHandleCommand_Consumes_Empty() |
|
425 | - { |
|
426 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
427 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
428 | - |
|
429 | - $return = $object->handleCommand('consumes'); |
|
430 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
431 | - |
|
432 | - $return = $object->handleCommand('response', '200'); |
|
433 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
434 | - |
|
435 | - $this->assertSame(array( |
|
436 | - 'responses' => array( |
|
437 | - 200 => array( |
|
438 | - 'description' => 'OK', |
|
439 | - ), |
|
440 | - ), |
|
441 | - ), $object->toArray()); |
|
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
446 | - */ |
|
447 | - public function testHandleCommand_Consumes() |
|
448 | - { |
|
449 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
450 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
451 | - |
|
452 | - $return = $object->handleCommand('consumes', 'image/png text'); |
|
453 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
454 | - |
|
455 | - $return = $object->handleCommand('response', '200'); |
|
456 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
457 | - |
|
458 | - $this->assertSame(array( |
|
459 | - 'consumes' => array( |
|
460 | - 'image/png', |
|
461 | - 'text/plain', |
|
462 | - ), |
|
463 | - 'responses' => array( |
|
464 | - 200 => array( |
|
465 | - 'description' => 'OK', |
|
466 | - ), |
|
467 | - ), |
|
468 | - ), $object->toArray()); |
|
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
473 | - */ |
|
474 | - public function testHandleCommand_Consumes_Append() |
|
475 | - { |
|
476 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
477 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
478 | - |
|
479 | - $return = $object->handleCommand('consumes', 'image/png text'); |
|
480 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
481 | - |
|
482 | - $return = $object->handleCommand('consumes', 'text json'); |
|
483 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
484 | - |
|
485 | - $return = $object->handleCommand('response', '200'); |
|
486 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
487 | - |
|
488 | - $this->assertSame(array( |
|
489 | - 'consumes' => array( |
|
490 | - 'application/json', |
|
491 | - 'image/png', |
|
492 | - 'text/plain', |
|
493 | - ), |
|
494 | - 'responses' => array( |
|
495 | - 200 => array( |
|
496 | - 'description' => 'OK', |
|
497 | - ), |
|
498 | - ), |
|
499 | - ), $object->toArray()); |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
504 | - */ |
|
505 | - public function testHandleCommand_Produces_Empty() |
|
506 | - { |
|
507 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
508 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
509 | - |
|
510 | - $return = $object->handleCommand('produces'); |
|
511 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
512 | - |
|
513 | - $return = $object->handleCommand('response', '200'); |
|
514 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
515 | - |
|
516 | - $this->assertSame(array( |
|
517 | - 'responses' => array( |
|
518 | - 200 => array( |
|
519 | - 'description' => 'OK', |
|
520 | - ), |
|
521 | - ), |
|
522 | - ), $object->toArray()); |
|
523 | - } |
|
524 | - |
|
525 | - /** |
|
526 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
527 | - */ |
|
528 | - public function testHandleCommand_Produces() |
|
529 | - { |
|
530 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
531 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
532 | - |
|
533 | - $return = $object->handleCommand('produces', 'image/png text'); |
|
534 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
535 | - |
|
536 | - $return = $object->handleCommand('response', '200'); |
|
537 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
538 | - |
|
539 | - $this->assertSame(array( |
|
540 | - 'produces' => array( |
|
541 | - 'image/png', |
|
542 | - 'text/plain', |
|
543 | - ), |
|
544 | - 'responses' => array( |
|
545 | - 200 => array( |
|
546 | - 'description' => 'OK', |
|
547 | - ), |
|
548 | - ), |
|
549 | - ), $object->toArray()); |
|
550 | - } |
|
551 | - |
|
552 | - /** |
|
553 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
554 | - */ |
|
555 | - public function testHandleCommand_Produces_Append() |
|
556 | - { |
|
557 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
558 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
559 | - |
|
560 | - $return = $object->handleCommand('produces', 'image/png text'); |
|
561 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
562 | - |
|
563 | - $return = $object->handleCommand('produces', 'text json'); |
|
564 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
565 | - |
|
566 | - $return = $object->handleCommand('response', '200'); |
|
567 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
568 | - |
|
569 | - $this->assertSame(array( |
|
570 | - 'produces' => array( |
|
571 | - 'application/json', |
|
572 | - 'image/png', |
|
573 | - 'text/plain', |
|
574 | - ), |
|
575 | - 'responses' => array( |
|
576 | - 200 => array( |
|
577 | - 'description' => 'OK', |
|
578 | - ), |
|
579 | - ), |
|
580 | - ), $object->toArray()); |
|
581 | - } |
|
582 | - |
|
583 | - /** |
|
584 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
585 | - */ |
|
586 | - public function testHandleCommand_Error_Empty() |
|
587 | - { |
|
588 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
589 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
590 | - |
|
591 | - $this->expectException('\SwaggerGen\Exception', "Invalid error code: ''"); |
|
592 | - $object->handleCommand('error'); |
|
593 | - } |
|
594 | - |
|
595 | - /** |
|
596 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
597 | - */ |
|
598 | - public function testHandleCommand_Error_404() |
|
599 | - { |
|
600 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
601 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
602 | - |
|
603 | - $return = $object->handleCommand('error', 404); |
|
604 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
605 | - |
|
606 | - $this->assertSame(array( |
|
607 | - 'responses' => array( |
|
608 | - 404 => array( |
|
609 | - 'description' => 'Not Found', |
|
610 | - ), |
|
611 | - ), |
|
612 | - ), $object->toArray()); |
|
613 | - } |
|
614 | - |
|
615 | - /** |
|
616 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
617 | - */ |
|
618 | - public function testHandleCommand_Error_404Description() |
|
619 | - { |
|
620 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
621 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
622 | - |
|
623 | - $return = $object->handleCommand('error', '404 Not here, Bro!'); |
|
624 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
625 | - |
|
626 | - $this->assertSame(array( |
|
627 | - 'responses' => array( |
|
628 | - 404 => array( |
|
629 | - 'description' => 'Not here, Bro!', |
|
630 | - ), |
|
631 | - ), |
|
632 | - ), $object->toArray()); |
|
633 | - } |
|
634 | - |
|
635 | - /** |
|
636 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
637 | - */ |
|
638 | - public function testHandleCommand_Errors_Empty() |
|
639 | - { |
|
640 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
641 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
642 | - |
|
643 | - $object->handleCommand('errors'); |
|
644 | - |
|
645 | - $this->expectException('\SwaggerGen\Exception', "No response defined for operation"); |
|
646 | - $object->toArray(); |
|
647 | - } |
|
648 | - |
|
649 | - /** |
|
650 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
651 | - */ |
|
652 | - public function testHandleCommand_Errors() |
|
653 | - { |
|
654 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
655 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
656 | - |
|
657 | - $return = $object->handleCommand('errors', '404 403'); |
|
658 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
659 | - |
|
660 | - $this->assertSame(array( |
|
661 | - 'responses' => array( |
|
662 | - 403 => array( |
|
663 | - 'description' => 'Forbidden', |
|
664 | - ), |
|
665 | - 404 => array( |
|
666 | - 'description' => 'Not Found', |
|
667 | - ), |
|
668 | - ), |
|
669 | - ), $object->toArray()); |
|
670 | - } |
|
671 | - |
|
672 | - /** |
|
673 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
674 | - */ |
|
675 | - public function testHandleCommand_Response_Empty() |
|
676 | - { |
|
677 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
678 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
679 | - |
|
680 | - $this->expectException('\SwaggerGen\Exception', "Invalid response code: ''"); |
|
681 | - $object->handleCommand('response'); |
|
682 | - } |
|
683 | - |
|
684 | - /** |
|
685 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
686 | - */ |
|
687 | - public function testHandleCommand_Response_200() |
|
688 | - { |
|
689 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
690 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
691 | - |
|
692 | - $return = $object->handleCommand('response', '200'); |
|
693 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
694 | - |
|
695 | - $this->assertSame(array( |
|
696 | - 'responses' => array( |
|
697 | - 200 => array( |
|
698 | - 'description' => 'OK', |
|
699 | - ), |
|
700 | - ), |
|
701 | - ), $object->toArray()); |
|
702 | - } |
|
703 | - |
|
704 | - /** |
|
705 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
706 | - */ |
|
707 | - public function testHandleCommand_Response_Definition() |
|
708 | - { |
|
709 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
710 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
711 | - |
|
712 | - $return = $object->handleCommand('response', '200 int'); |
|
713 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
714 | - |
|
715 | - $this->assertSame(array( |
|
716 | - 'responses' => array( |
|
717 | - 200 => array( |
|
718 | - 'description' => 'OK', |
|
719 | - 'schema' => array( |
|
720 | - 'type' => 'integer', |
|
721 | - 'format' => 'int32', |
|
722 | - ), |
|
723 | - ), |
|
724 | - ), |
|
725 | - ), $object->toArray()); |
|
726 | - } |
|
727 | - |
|
728 | - /** |
|
729 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
730 | - */ |
|
731 | - public function testHandleCommand_Response_Description() |
|
732 | - { |
|
733 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
734 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
735 | - |
|
736 | - $return = $object->handleCommand('response', '200 int Stuff is returned'); |
|
737 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
738 | - |
|
739 | - $this->assertSame(array( |
|
740 | - 'responses' => array( |
|
741 | - 200 => array( |
|
742 | - 'description' => 'Stuff is returned', |
|
743 | - 'schema' => array( |
|
744 | - 'type' => 'integer', |
|
745 | - 'format' => 'int32', |
|
746 | - ), |
|
747 | - ), |
|
748 | - ), |
|
749 | - ), $object->toArray()); |
|
750 | - } |
|
751 | - |
|
752 | - /** |
|
753 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
754 | - */ |
|
755 | - public function testHandleCommand_Require_Empty() |
|
756 | - { |
|
757 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
758 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
759 | - |
|
760 | - $this->expectException('\SwaggerGen\Exception', "Empty security requirement name"); |
|
761 | - $object->handleCommand('require'); |
|
762 | - } |
|
763 | - |
|
764 | - /** |
|
765 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
766 | - */ |
|
767 | - public function testHandleCommand_Require_Basic_Undefined() |
|
768 | - { |
|
769 | - // precondition |
|
770 | - $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
771 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
772 | - |
|
773 | - $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
774 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
775 | - |
|
776 | - $return = $object->handleCommand('require', 'basic'); |
|
777 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
778 | - |
|
779 | - $return = $object->handleCommand('response', '200'); |
|
780 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
781 | - |
|
782 | - $this->expectException('\SwaggerGen\Exception', "Required security scheme not defined: 'basic'"); |
|
783 | - $object->toArray(); |
|
784 | - } |
|
785 | - |
|
786 | - /** |
|
787 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
788 | - */ |
|
789 | - public function testHandleCommand_Require_Basic() |
|
790 | - { |
|
791 | - // precondition |
|
792 | - $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
793 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
794 | - $swagger->handleCommand('security', 'basic basic'); |
|
795 | - |
|
796 | - $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
797 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
798 | - |
|
799 | - $return = $object->handleCommand('require', 'basic'); |
|
800 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
801 | - |
|
802 | - $return = $object->handleCommand('response', '200'); |
|
803 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
804 | - |
|
805 | - $this->assertEquals(array( |
|
806 | - 'responses' => array( |
|
807 | - 200 => array( |
|
808 | - 'description' => 'OK', |
|
809 | - ), |
|
810 | - ), |
|
811 | - 'security' => array( |
|
812 | - array( |
|
813 | - 'basic' => array(), |
|
814 | - ), |
|
815 | - ), |
|
816 | - ), $object->toArray()); |
|
817 | - } |
|
818 | - |
|
819 | - /** |
|
820 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
821 | - */ |
|
822 | - public function testHandleCommand_Require_Oauth2() |
|
823 | - { |
|
824 | - // precondition |
|
825 | - $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
826 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
827 | - $swagger->handleCommand('security', 'oauth oauth2 implicit http://www.test'); |
|
828 | - |
|
829 | - $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
830 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
831 | - |
|
832 | - $return = $object->handleCommand('require', 'oauth user:name user:email'); |
|
833 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
834 | - |
|
835 | - $return = $object->handleCommand('response', '200'); |
|
836 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
837 | - |
|
838 | - $this->assertSame(array( |
|
839 | - 'responses' => array( |
|
840 | - 200 => array( |
|
841 | - 'description' => 'OK', |
|
842 | - ), |
|
843 | - ), |
|
844 | - 'security' => array( |
|
845 | - array( |
|
846 | - 'oauth' => array( |
|
847 | - 'user:email', |
|
848 | - 'user:name', |
|
849 | - ), |
|
850 | - ), |
|
851 | - ), |
|
852 | - ), $object->toArray()); |
|
853 | - } |
|
854 | - |
|
855 | - /** |
|
856 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
857 | - */ |
|
858 | - public function testHandleCommand_Body_Required() |
|
859 | - { |
|
860 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
861 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
862 | - |
|
863 | - $return = $object->handleCommand('body', 'int foo'); |
|
864 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $return); |
|
865 | - |
|
866 | - $return = $object->handleCommand('response', '200'); |
|
867 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
868 | - |
|
869 | - $this->assertSame(array( |
|
870 | - 'parameters' => array( |
|
871 | - array( |
|
872 | - 'name' => 'foo', |
|
873 | - 'in' => 'body', |
|
874 | - 'required' => true, |
|
875 | - 'schema' => array( |
|
876 | - 'type' => 'integer', |
|
877 | - 'format' => 'int32', |
|
878 | - ), |
|
879 | - ), |
|
880 | - ), |
|
881 | - 'responses' => array( |
|
882 | - 200 => array( |
|
883 | - 'description' => 'OK', |
|
884 | - ), |
|
885 | - ), |
|
886 | - ), $object->toArray()); |
|
887 | - } |
|
888 | - |
|
889 | - /** |
|
890 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
891 | - */ |
|
892 | - public function testHandleCommand_Body_Optional() |
|
893 | - { |
|
894 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
895 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
896 | - |
|
897 | - $return = $object->handleCommand('body?', 'int foo'); |
|
898 | - $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $return); |
|
899 | - |
|
900 | - $return = $object->handleCommand('response', '200'); |
|
901 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
902 | - |
|
903 | - $this->assertSame(array( |
|
904 | - 'parameters' => array( |
|
905 | - array( |
|
906 | - 'name' => 'foo', |
|
907 | - 'in' => 'body', |
|
908 | - 'schema' => array( |
|
909 | - 'type' => 'integer', |
|
910 | - 'format' => 'int32', |
|
911 | - ), |
|
912 | - ), |
|
913 | - ), |
|
914 | - 'responses' => array( |
|
915 | - 200 => array( |
|
916 | - 'description' => 'OK', |
|
917 | - ), |
|
918 | - ), |
|
919 | - ), $object->toArray()); |
|
920 | - } |
|
921 | - |
|
922 | - /** |
|
923 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
924 | - */ |
|
925 | - public function testHandleCommand_Path_Required() |
|
926 | - { |
|
927 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
928 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
929 | - |
|
930 | - $return = $object->handleCommand('path', 'int foo'); |
|
931 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
932 | - |
|
933 | - $return = $object->handleCommand('response', '200'); |
|
934 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
935 | - |
|
936 | - $this->assertSame(array( |
|
937 | - 'parameters' => array( |
|
938 | - array( |
|
939 | - 'name' => 'foo', |
|
940 | - 'in' => 'path', |
|
941 | - 'required' => true, |
|
942 | - 'type' => 'integer', |
|
943 | - 'format' => 'int32', |
|
944 | - ), |
|
945 | - ), |
|
946 | - 'responses' => array( |
|
947 | - 200 => array( |
|
948 | - 'description' => 'OK', |
|
949 | - ), |
|
950 | - ), |
|
951 | - ), $object->toArray()); |
|
952 | - } |
|
953 | - |
|
954 | - /** |
|
955 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
956 | - */ |
|
957 | - public function testHandleCommand_Query_Required() |
|
958 | - { |
|
959 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
960 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
961 | - |
|
962 | - $return = $object->handleCommand('query', 'int foo'); |
|
963 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
964 | - |
|
965 | - $return = $object->handleCommand('response', '200'); |
|
966 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
967 | - |
|
968 | - $this->assertSame(array( |
|
969 | - 'parameters' => array( |
|
970 | - array( |
|
971 | - 'name' => 'foo', |
|
972 | - 'in' => 'query', |
|
973 | - 'required' => true, |
|
974 | - 'type' => 'integer', |
|
975 | - 'format' => 'int32', |
|
976 | - ), |
|
977 | - ), |
|
978 | - 'responses' => array( |
|
979 | - 200 => array( |
|
980 | - 'description' => 'OK', |
|
981 | - ), |
|
982 | - ), |
|
983 | - ), $object->toArray()); |
|
984 | - } |
|
985 | - |
|
986 | - /** |
|
987 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
988 | - */ |
|
989 | - public function testHandleCommand_Query_Optional() |
|
990 | - { |
|
991 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
992 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
993 | - |
|
994 | - $return = $object->handleCommand('query?', 'int foo'); |
|
995 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
996 | - |
|
997 | - $return = $object->handleCommand('response', '200'); |
|
998 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
999 | - |
|
1000 | - $this->assertSame(array( |
|
1001 | - 'parameters' => array( |
|
1002 | - array( |
|
1003 | - 'name' => 'foo', |
|
1004 | - 'in' => 'query', |
|
1005 | - 'type' => 'integer', |
|
1006 | - 'format' => 'int32', |
|
1007 | - ), |
|
1008 | - ), |
|
1009 | - 'responses' => array( |
|
1010 | - 200 => array( |
|
1011 | - 'description' => 'OK', |
|
1012 | - ), |
|
1013 | - ), |
|
1014 | - ), $object->toArray()); |
|
1015 | - } |
|
1016 | - |
|
1017 | - /** |
|
1018 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1019 | - */ |
|
1020 | - public function testHandleCommand_Header_Required() |
|
1021 | - { |
|
1022 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1023 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1024 | - |
|
1025 | - $return = $object->handleCommand('header', 'int foo'); |
|
1026 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1027 | - |
|
1028 | - $return = $object->handleCommand('response', '200'); |
|
1029 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1030 | - |
|
1031 | - $this->assertSame(array( |
|
1032 | - 'parameters' => array( |
|
1033 | - array( |
|
1034 | - 'name' => 'foo', |
|
1035 | - 'in' => 'header', |
|
1036 | - 'required' => true, |
|
1037 | - 'type' => 'integer', |
|
1038 | - 'format' => 'int32', |
|
1039 | - ), |
|
1040 | - ), |
|
1041 | - 'responses' => array( |
|
1042 | - 200 => array( |
|
1043 | - 'description' => 'OK', |
|
1044 | - ), |
|
1045 | - ), |
|
1046 | - ), $object->toArray()); |
|
1047 | - } |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1051 | - */ |
|
1052 | - public function testHandleCommand_Header_Optional() |
|
1053 | - { |
|
1054 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1055 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1056 | - |
|
1057 | - $return = $object->handleCommand('header?', 'int foo'); |
|
1058 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1059 | - |
|
1060 | - $return = $object->handleCommand('response', '200'); |
|
1061 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1062 | - |
|
1063 | - $this->assertSame(array( |
|
1064 | - 'parameters' => array( |
|
1065 | - array( |
|
1066 | - 'name' => 'foo', |
|
1067 | - 'in' => 'header', |
|
1068 | - 'type' => 'integer', |
|
1069 | - 'format' => 'int32', |
|
1070 | - ), |
|
1071 | - ), |
|
1072 | - 'responses' => array( |
|
1073 | - 200 => array( |
|
1074 | - 'description' => 'OK', |
|
1075 | - ), |
|
1076 | - ), |
|
1077 | - ), $object->toArray()); |
|
1078 | - } |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1082 | - */ |
|
1083 | - public function testHandleCommand_Form_Required() |
|
1084 | - { |
|
1085 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1086 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1087 | - |
|
1088 | - $return = $object->handleCommand('form', 'int foo'); |
|
1089 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1090 | - |
|
1091 | - $return = $object->handleCommand('response', '200'); |
|
1092 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1093 | - |
|
1094 | - $this->assertSame(array( |
|
1095 | - 'parameters' => array( |
|
1096 | - array( |
|
1097 | - 'name' => 'foo', |
|
1098 | - 'in' => 'formData', |
|
1099 | - 'required' => true, |
|
1100 | - 'type' => 'integer', |
|
1101 | - 'format' => 'int32', |
|
1102 | - ), |
|
1103 | - ), |
|
1104 | - 'responses' => array( |
|
1105 | - 200 => array( |
|
1106 | - 'description' => 'OK', |
|
1107 | - ), |
|
1108 | - ), |
|
1109 | - ), $object->toArray()); |
|
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1114 | - */ |
|
1115 | - public function testHandleCommand_Form_Optional() |
|
1116 | - { |
|
1117 | - $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1118 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1119 | - |
|
1120 | - $return = $object->handleCommand('form?', 'int foo'); |
|
1121 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1122 | - |
|
1123 | - $return = $object->handleCommand('response', '200'); |
|
1124 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1125 | - |
|
1126 | - $this->assertSame(array( |
|
1127 | - 'parameters' => array( |
|
1128 | - array( |
|
1129 | - 'name' => 'foo', |
|
1130 | - 'in' => 'formData', |
|
1131 | - 'type' => 'integer', |
|
1132 | - 'format' => 'int32', |
|
1133 | - ), |
|
1134 | - ), |
|
1135 | - 'responses' => array( |
|
1136 | - 200 => array( |
|
1137 | - 'description' => 'OK', |
|
1138 | - ), |
|
1139 | - ), |
|
1140 | - ), $object->toArray()); |
|
1141 | - } |
|
1142 | - |
|
1143 | - protected function setUp(): void |
|
1144 | - { |
|
1145 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
1146 | - } |
|
1147 | - |
|
1148 | - protected function assertPreConditions(): void |
|
1149 | - { |
|
1150 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
1151 | - } |
|
9 | + protected $parent; |
|
10 | + |
|
11 | + /** |
|
12 | + * @covers \SwaggerGen\Swagger\Operation::__construct |
|
13 | + */ |
|
14 | + public function testConstructor_NoResponse(): void |
|
15 | + { |
|
16 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
17 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
18 | + |
|
19 | + $this->expectException('\SwaggerGen\Exception', "No response defined for operation"); |
|
20 | + $object->toArray(); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
25 | + */ |
|
26 | + public function testConstructor_Summary() |
|
27 | + { |
|
28 | + $object = new \SwaggerGen\Swagger\Operation($this->parent, 'Some words'); |
|
29 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
30 | + |
|
31 | + $return = $object->handleCommand('error', 404); |
|
32 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
33 | + |
|
34 | + $this->assertSame(array( |
|
35 | + 'summary' => 'Some words', |
|
36 | + 'responses' => array( |
|
37 | + 404 => array( |
|
38 | + 'description' => 'Not Found', |
|
39 | + ), |
|
40 | + ), |
|
41 | + ), $object->toArray()); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
46 | + */ |
|
47 | + public function testConstructor_Tag() |
|
48 | + { |
|
49 | + $object = new \SwaggerGen\Swagger\Operation($this->parent, '', new SwaggerGen\Swagger\Tag($this->parent, 'Operations')); |
|
50 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
51 | + |
|
52 | + $return = $object->handleCommand('error', 404); |
|
53 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
54 | + |
|
55 | + $this->assertSame(array( |
|
56 | + 'tags' => array( |
|
57 | + 'Operations', |
|
58 | + ), |
|
59 | + 'responses' => array( |
|
60 | + 404 => array( |
|
61 | + 'description' => 'Not Found', |
|
62 | + ), |
|
63 | + ), |
|
64 | + ), $object->toArray()); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
69 | + */ |
|
70 | + public function testHandleCommand_Summary_Empty() |
|
71 | + { |
|
72 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
74 | + |
|
75 | + $return = $object->handleCommand('summary'); |
|
76 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
77 | + |
|
78 | + $return = $object->handleCommand('response', '200'); |
|
79 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
80 | + |
|
81 | + $this->assertSame(array( |
|
82 | + 'responses' => array( |
|
83 | + 200 => array( |
|
84 | + 'description' => 'OK', |
|
85 | + ), |
|
86 | + ), |
|
87 | + ), $object->toArray()); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
92 | + */ |
|
93 | + public function testHandleCommand_Summary() |
|
94 | + { |
|
95 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
96 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
97 | + |
|
98 | + $return = $object->handleCommand('summary', 'Some words'); |
|
99 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
100 | + |
|
101 | + $return = $object->handleCommand('response', '200'); |
|
102 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
103 | + |
|
104 | + $this->assertSame(array( |
|
105 | + 'summary' => 'Some words', |
|
106 | + 'responses' => array( |
|
107 | + 200 => array( |
|
108 | + 'description' => 'OK', |
|
109 | + ), |
|
110 | + ), |
|
111 | + ), $object->toArray()); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
116 | + */ |
|
117 | + public function testHandleCommand_Description_Empty() |
|
118 | + { |
|
119 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
120 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
121 | + |
|
122 | + $return = $object->handleCommand('description'); |
|
123 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
124 | + |
|
125 | + $return = $object->handleCommand('response', '200'); |
|
126 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
127 | + |
|
128 | + $this->assertSame(array( |
|
129 | + 'responses' => array( |
|
130 | + 200 => array( |
|
131 | + 'description' => 'OK', |
|
132 | + ), |
|
133 | + ), |
|
134 | + ), $object->toArray()); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
139 | + */ |
|
140 | + public function testHandleCommand_Description() |
|
141 | + { |
|
142 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
143 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
144 | + |
|
145 | + $return = $object->handleCommand('description', 'Some words'); |
|
146 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
147 | + |
|
148 | + $return = $object->handleCommand('response', '200'); |
|
149 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
150 | + |
|
151 | + $this->assertSame(array( |
|
152 | + 'description' => 'Some words', |
|
153 | + 'responses' => array( |
|
154 | + 200 => array( |
|
155 | + 'description' => 'OK', |
|
156 | + ), |
|
157 | + ), |
|
158 | + ), $object->toArray()); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
163 | + */ |
|
164 | + public function testHandleCommand_Deprecated() |
|
165 | + { |
|
166 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
167 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
168 | + |
|
169 | + $return = $object->handleCommand('deprecated'); |
|
170 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
171 | + |
|
172 | + $return = $object->handleCommand('response', '200'); |
|
173 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
174 | + |
|
175 | + $this->assertSame(array( |
|
176 | + 'deprecated' => true, |
|
177 | + 'responses' => array( |
|
178 | + 200 => array( |
|
179 | + 'description' => 'OK', |
|
180 | + ), |
|
181 | + ), |
|
182 | + ), $object->toArray()); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
187 | + */ |
|
188 | + public function testHandleCommand_OperationId() |
|
189 | + { |
|
190 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
191 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
192 | + |
|
193 | + $return = $object->handleCommand('id', 'SomeOperation'); |
|
194 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
195 | + |
|
196 | + $return = $object->handleCommand('response', '200'); |
|
197 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
198 | + |
|
199 | + $this->assertSame(array( |
|
200 | + 'operationId' => 'SomeOperation', |
|
201 | + 'responses' => array( |
|
202 | + 200 => array( |
|
203 | + 'description' => 'OK', |
|
204 | + ), |
|
205 | + ), |
|
206 | + ), $object->toArray()); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
211 | + */ |
|
212 | + public function testHandleCommand_OperationId_UniqueInPath() |
|
213 | + { |
|
214 | + $path = $this->parent->handleCommand('endpoint', 'foo'); |
|
215 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
216 | + |
|
217 | + // First occurance |
|
218 | + $operation = $path->handleCommand('operation', 'GET'); |
|
219 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
220 | + |
|
221 | + $return = $operation->handleCommand('id', 'SomeOperation'); |
|
222 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
223 | + |
|
224 | + // Second occurance |
|
225 | + $operation = $path->handleCommand('operation', 'GET'); |
|
226 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
227 | + |
|
228 | + $this->expectException('\SwaggerGen\Exception', "Duplicate operation id 'SomeOperation'"); |
|
229 | + $operation->handleCommand('id', 'SomeOperation'); |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
234 | + */ |
|
235 | + public function testHandleCommand_OperationId_UniqueInSwagger() |
|
236 | + { |
|
237 | + // First occurance |
|
238 | + $path = $this->parent->handleCommand('endpoint', 'foo'); |
|
239 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
240 | + |
|
241 | + $operation = $path->handleCommand('operation', 'GET'); |
|
242 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
243 | + |
|
244 | + $return = $operation->handleCommand('id', 'SomeOperation'); |
|
245 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
246 | + |
|
247 | + // Second occurance |
|
248 | + $path = $this->parent->handleCommand('endpoint', 'bar'); |
|
249 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
250 | + |
|
251 | + $operation = $path->handleCommand('operation', 'GET'); |
|
252 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
253 | + |
|
254 | + $this->expectException('\SwaggerGen\Exception', "Duplicate operation id 'SomeOperation'"); |
|
255 | + $operation->handleCommand('id', 'SomeOperation'); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
260 | + */ |
|
261 | + public function testHandleCommand_Tags_Empty() |
|
262 | + { |
|
263 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
264 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
265 | + |
|
266 | + $return = $object->handleCommand('tags'); |
|
267 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
268 | + |
|
269 | + $return = $object->handleCommand('response', '200'); |
|
270 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
271 | + |
|
272 | + $this->assertSame(array( |
|
273 | + 'responses' => array( |
|
274 | + 200 => array( |
|
275 | + 'description' => 'OK', |
|
276 | + ), |
|
277 | + ), |
|
278 | + ), $object->toArray()); |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
283 | + */ |
|
284 | + public function testHandleCommand_Tags() |
|
285 | + { |
|
286 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
287 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
288 | + |
|
289 | + $return = $object->handleCommand('tags', 'black white'); |
|
290 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
291 | + |
|
292 | + $return = $object->handleCommand('response', '200'); |
|
293 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
294 | + |
|
295 | + $this->assertSame(array( |
|
296 | + 'tags' => array( |
|
297 | + 'black', |
|
298 | + 'white', |
|
299 | + ), |
|
300 | + 'responses' => array( |
|
301 | + 200 => array( |
|
302 | + 'description' => 'OK', |
|
303 | + ), |
|
304 | + ), |
|
305 | + ), $object->toArray()); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
310 | + */ |
|
311 | + public function testHandleCommand_Tags_Append() |
|
312 | + { |
|
313 | + $object = new \SwaggerGen\Swagger\Operation($this->parent, null, new SwaggerGen\Swagger\Tag($this->parent, 'purple')); |
|
314 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
315 | + |
|
316 | + $return = $object->handleCommand('tags', 'black white'); |
|
317 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
318 | + |
|
319 | + $return = $object->handleCommand('tags', 'black green'); |
|
320 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
321 | + |
|
322 | + $return = $object->handleCommand('response', '200'); |
|
323 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
324 | + |
|
325 | + $this->assertSame(array( |
|
326 | + 'tags' => array( |
|
327 | + 'black', |
|
328 | + 'green', |
|
329 | + 'purple', |
|
330 | + 'white', |
|
331 | + ), |
|
332 | + 'responses' => array( |
|
333 | + 200 => array( |
|
334 | + 'description' => 'OK', |
|
335 | + ), |
|
336 | + ), |
|
337 | + ), $object->toArray()); |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
342 | + */ |
|
343 | + public function testHandleCommand_Schemes_Empty() |
|
344 | + { |
|
345 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
346 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
347 | + |
|
348 | + $return = $object->handleCommand('schemes'); |
|
349 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
350 | + |
|
351 | + $return = $object->handleCommand('response', '200'); |
|
352 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
353 | + |
|
354 | + $this->assertSame(array( |
|
355 | + 'responses' => array( |
|
356 | + 200 => array( |
|
357 | + 'description' => 'OK', |
|
358 | + ), |
|
359 | + ), |
|
360 | + ), $object->toArray()); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
365 | + */ |
|
366 | + public function testHandleCommand_Schemes() |
|
367 | + { |
|
368 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
369 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
370 | + |
|
371 | + $return = $object->handleCommand('schemes', 'http https'); |
|
372 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
373 | + |
|
374 | + $return = $object->handleCommand('response', '200'); |
|
375 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
376 | + |
|
377 | + $this->assertSame(array( |
|
378 | + 'schemes' => array( |
|
379 | + 'http', |
|
380 | + 'https', |
|
381 | + ), |
|
382 | + 'responses' => array( |
|
383 | + 200 => array( |
|
384 | + 'description' => 'OK', |
|
385 | + ), |
|
386 | + ), |
|
387 | + ), $object->toArray()); |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
392 | + */ |
|
393 | + public function testHandleCommand_Schemes_Append() |
|
394 | + { |
|
395 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
396 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
397 | + |
|
398 | + $return = $object->handleCommand('schemes', 'ws wss'); |
|
399 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
400 | + |
|
401 | + $return = $object->handleCommand('schemes', 'http ws'); |
|
402 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
403 | + |
|
404 | + $return = $object->handleCommand('response', '200'); |
|
405 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
406 | + |
|
407 | + $this->assertSame(array( |
|
408 | + 'schemes' => array( |
|
409 | + 'http', |
|
410 | + 'ws', |
|
411 | + 'wss', |
|
412 | + ), |
|
413 | + 'responses' => array( |
|
414 | + 200 => array( |
|
415 | + 'description' => 'OK', |
|
416 | + ), |
|
417 | + ), |
|
418 | + ), $object->toArray()); |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
423 | + */ |
|
424 | + public function testHandleCommand_Consumes_Empty() |
|
425 | + { |
|
426 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
427 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
428 | + |
|
429 | + $return = $object->handleCommand('consumes'); |
|
430 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
431 | + |
|
432 | + $return = $object->handleCommand('response', '200'); |
|
433 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
434 | + |
|
435 | + $this->assertSame(array( |
|
436 | + 'responses' => array( |
|
437 | + 200 => array( |
|
438 | + 'description' => 'OK', |
|
439 | + ), |
|
440 | + ), |
|
441 | + ), $object->toArray()); |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
446 | + */ |
|
447 | + public function testHandleCommand_Consumes() |
|
448 | + { |
|
449 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
450 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
451 | + |
|
452 | + $return = $object->handleCommand('consumes', 'image/png text'); |
|
453 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
454 | + |
|
455 | + $return = $object->handleCommand('response', '200'); |
|
456 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
457 | + |
|
458 | + $this->assertSame(array( |
|
459 | + 'consumes' => array( |
|
460 | + 'image/png', |
|
461 | + 'text/plain', |
|
462 | + ), |
|
463 | + 'responses' => array( |
|
464 | + 200 => array( |
|
465 | + 'description' => 'OK', |
|
466 | + ), |
|
467 | + ), |
|
468 | + ), $object->toArray()); |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
473 | + */ |
|
474 | + public function testHandleCommand_Consumes_Append() |
|
475 | + { |
|
476 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
477 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
478 | + |
|
479 | + $return = $object->handleCommand('consumes', 'image/png text'); |
|
480 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
481 | + |
|
482 | + $return = $object->handleCommand('consumes', 'text json'); |
|
483 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
484 | + |
|
485 | + $return = $object->handleCommand('response', '200'); |
|
486 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
487 | + |
|
488 | + $this->assertSame(array( |
|
489 | + 'consumes' => array( |
|
490 | + 'application/json', |
|
491 | + 'image/png', |
|
492 | + 'text/plain', |
|
493 | + ), |
|
494 | + 'responses' => array( |
|
495 | + 200 => array( |
|
496 | + 'description' => 'OK', |
|
497 | + ), |
|
498 | + ), |
|
499 | + ), $object->toArray()); |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
504 | + */ |
|
505 | + public function testHandleCommand_Produces_Empty() |
|
506 | + { |
|
507 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
508 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
509 | + |
|
510 | + $return = $object->handleCommand('produces'); |
|
511 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
512 | + |
|
513 | + $return = $object->handleCommand('response', '200'); |
|
514 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
515 | + |
|
516 | + $this->assertSame(array( |
|
517 | + 'responses' => array( |
|
518 | + 200 => array( |
|
519 | + 'description' => 'OK', |
|
520 | + ), |
|
521 | + ), |
|
522 | + ), $object->toArray()); |
|
523 | + } |
|
524 | + |
|
525 | + /** |
|
526 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
527 | + */ |
|
528 | + public function testHandleCommand_Produces() |
|
529 | + { |
|
530 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
531 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
532 | + |
|
533 | + $return = $object->handleCommand('produces', 'image/png text'); |
|
534 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
535 | + |
|
536 | + $return = $object->handleCommand('response', '200'); |
|
537 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
538 | + |
|
539 | + $this->assertSame(array( |
|
540 | + 'produces' => array( |
|
541 | + 'image/png', |
|
542 | + 'text/plain', |
|
543 | + ), |
|
544 | + 'responses' => array( |
|
545 | + 200 => array( |
|
546 | + 'description' => 'OK', |
|
547 | + ), |
|
548 | + ), |
|
549 | + ), $object->toArray()); |
|
550 | + } |
|
551 | + |
|
552 | + /** |
|
553 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
554 | + */ |
|
555 | + public function testHandleCommand_Produces_Append() |
|
556 | + { |
|
557 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
558 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
559 | + |
|
560 | + $return = $object->handleCommand('produces', 'image/png text'); |
|
561 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
562 | + |
|
563 | + $return = $object->handleCommand('produces', 'text json'); |
|
564 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
565 | + |
|
566 | + $return = $object->handleCommand('response', '200'); |
|
567 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
568 | + |
|
569 | + $this->assertSame(array( |
|
570 | + 'produces' => array( |
|
571 | + 'application/json', |
|
572 | + 'image/png', |
|
573 | + 'text/plain', |
|
574 | + ), |
|
575 | + 'responses' => array( |
|
576 | + 200 => array( |
|
577 | + 'description' => 'OK', |
|
578 | + ), |
|
579 | + ), |
|
580 | + ), $object->toArray()); |
|
581 | + } |
|
582 | + |
|
583 | + /** |
|
584 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
585 | + */ |
|
586 | + public function testHandleCommand_Error_Empty() |
|
587 | + { |
|
588 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
589 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
590 | + |
|
591 | + $this->expectException('\SwaggerGen\Exception', "Invalid error code: ''"); |
|
592 | + $object->handleCommand('error'); |
|
593 | + } |
|
594 | + |
|
595 | + /** |
|
596 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
597 | + */ |
|
598 | + public function testHandleCommand_Error_404() |
|
599 | + { |
|
600 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
601 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
602 | + |
|
603 | + $return = $object->handleCommand('error', 404); |
|
604 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
605 | + |
|
606 | + $this->assertSame(array( |
|
607 | + 'responses' => array( |
|
608 | + 404 => array( |
|
609 | + 'description' => 'Not Found', |
|
610 | + ), |
|
611 | + ), |
|
612 | + ), $object->toArray()); |
|
613 | + } |
|
614 | + |
|
615 | + /** |
|
616 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
617 | + */ |
|
618 | + public function testHandleCommand_Error_404Description() |
|
619 | + { |
|
620 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
621 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
622 | + |
|
623 | + $return = $object->handleCommand('error', '404 Not here, Bro!'); |
|
624 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $return); |
|
625 | + |
|
626 | + $this->assertSame(array( |
|
627 | + 'responses' => array( |
|
628 | + 404 => array( |
|
629 | + 'description' => 'Not here, Bro!', |
|
630 | + ), |
|
631 | + ), |
|
632 | + ), $object->toArray()); |
|
633 | + } |
|
634 | + |
|
635 | + /** |
|
636 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
637 | + */ |
|
638 | + public function testHandleCommand_Errors_Empty() |
|
639 | + { |
|
640 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
641 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
642 | + |
|
643 | + $object->handleCommand('errors'); |
|
644 | + |
|
645 | + $this->expectException('\SwaggerGen\Exception', "No response defined for operation"); |
|
646 | + $object->toArray(); |
|
647 | + } |
|
648 | + |
|
649 | + /** |
|
650 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
651 | + */ |
|
652 | + public function testHandleCommand_Errors() |
|
653 | + { |
|
654 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
655 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
656 | + |
|
657 | + $return = $object->handleCommand('errors', '404 403'); |
|
658 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
659 | + |
|
660 | + $this->assertSame(array( |
|
661 | + 'responses' => array( |
|
662 | + 403 => array( |
|
663 | + 'description' => 'Forbidden', |
|
664 | + ), |
|
665 | + 404 => array( |
|
666 | + 'description' => 'Not Found', |
|
667 | + ), |
|
668 | + ), |
|
669 | + ), $object->toArray()); |
|
670 | + } |
|
671 | + |
|
672 | + /** |
|
673 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
674 | + */ |
|
675 | + public function testHandleCommand_Response_Empty() |
|
676 | + { |
|
677 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
678 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
679 | + |
|
680 | + $this->expectException('\SwaggerGen\Exception', "Invalid response code: ''"); |
|
681 | + $object->handleCommand('response'); |
|
682 | + } |
|
683 | + |
|
684 | + /** |
|
685 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
686 | + */ |
|
687 | + public function testHandleCommand_Response_200() |
|
688 | + { |
|
689 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
690 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
691 | + |
|
692 | + $return = $object->handleCommand('response', '200'); |
|
693 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
694 | + |
|
695 | + $this->assertSame(array( |
|
696 | + 'responses' => array( |
|
697 | + 200 => array( |
|
698 | + 'description' => 'OK', |
|
699 | + ), |
|
700 | + ), |
|
701 | + ), $object->toArray()); |
|
702 | + } |
|
703 | + |
|
704 | + /** |
|
705 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
706 | + */ |
|
707 | + public function testHandleCommand_Response_Definition() |
|
708 | + { |
|
709 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
710 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
711 | + |
|
712 | + $return = $object->handleCommand('response', '200 int'); |
|
713 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
714 | + |
|
715 | + $this->assertSame(array( |
|
716 | + 'responses' => array( |
|
717 | + 200 => array( |
|
718 | + 'description' => 'OK', |
|
719 | + 'schema' => array( |
|
720 | + 'type' => 'integer', |
|
721 | + 'format' => 'int32', |
|
722 | + ), |
|
723 | + ), |
|
724 | + ), |
|
725 | + ), $object->toArray()); |
|
726 | + } |
|
727 | + |
|
728 | + /** |
|
729 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
730 | + */ |
|
731 | + public function testHandleCommand_Response_Description() |
|
732 | + { |
|
733 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
734 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
735 | + |
|
736 | + $return = $object->handleCommand('response', '200 int Stuff is returned'); |
|
737 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
738 | + |
|
739 | + $this->assertSame(array( |
|
740 | + 'responses' => array( |
|
741 | + 200 => array( |
|
742 | + 'description' => 'Stuff is returned', |
|
743 | + 'schema' => array( |
|
744 | + 'type' => 'integer', |
|
745 | + 'format' => 'int32', |
|
746 | + ), |
|
747 | + ), |
|
748 | + ), |
|
749 | + ), $object->toArray()); |
|
750 | + } |
|
751 | + |
|
752 | + /** |
|
753 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
754 | + */ |
|
755 | + public function testHandleCommand_Require_Empty() |
|
756 | + { |
|
757 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
758 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
759 | + |
|
760 | + $this->expectException('\SwaggerGen\Exception', "Empty security requirement name"); |
|
761 | + $object->handleCommand('require'); |
|
762 | + } |
|
763 | + |
|
764 | + /** |
|
765 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
766 | + */ |
|
767 | + public function testHandleCommand_Require_Basic_Undefined() |
|
768 | + { |
|
769 | + // precondition |
|
770 | + $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
771 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
772 | + |
|
773 | + $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
774 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
775 | + |
|
776 | + $return = $object->handleCommand('require', 'basic'); |
|
777 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
778 | + |
|
779 | + $return = $object->handleCommand('response', '200'); |
|
780 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
781 | + |
|
782 | + $this->expectException('\SwaggerGen\Exception', "Required security scheme not defined: 'basic'"); |
|
783 | + $object->toArray(); |
|
784 | + } |
|
785 | + |
|
786 | + /** |
|
787 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
788 | + */ |
|
789 | + public function testHandleCommand_Require_Basic() |
|
790 | + { |
|
791 | + // precondition |
|
792 | + $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
793 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
794 | + $swagger->handleCommand('security', 'basic basic'); |
|
795 | + |
|
796 | + $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
797 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
798 | + |
|
799 | + $return = $object->handleCommand('require', 'basic'); |
|
800 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
801 | + |
|
802 | + $return = $object->handleCommand('response', '200'); |
|
803 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
804 | + |
|
805 | + $this->assertEquals(array( |
|
806 | + 'responses' => array( |
|
807 | + 200 => array( |
|
808 | + 'description' => 'OK', |
|
809 | + ), |
|
810 | + ), |
|
811 | + 'security' => array( |
|
812 | + array( |
|
813 | + 'basic' => array(), |
|
814 | + ), |
|
815 | + ), |
|
816 | + ), $object->toArray()); |
|
817 | + } |
|
818 | + |
|
819 | + /** |
|
820 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
821 | + */ |
|
822 | + public function testHandleCommand_Require_Oauth2() |
|
823 | + { |
|
824 | + // precondition |
|
825 | + $swagger = new \SwaggerGen\Swagger\Swagger(); |
|
826 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $swagger); |
|
827 | + $swagger->handleCommand('security', 'oauth oauth2 implicit http://www.test'); |
|
828 | + |
|
829 | + $object = new \SwaggerGen\Swagger\Operation($swagger); |
|
830 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
831 | + |
|
832 | + $return = $object->handleCommand('require', 'oauth user:name user:email'); |
|
833 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $return); |
|
834 | + |
|
835 | + $return = $object->handleCommand('response', '200'); |
|
836 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
837 | + |
|
838 | + $this->assertSame(array( |
|
839 | + 'responses' => array( |
|
840 | + 200 => array( |
|
841 | + 'description' => 'OK', |
|
842 | + ), |
|
843 | + ), |
|
844 | + 'security' => array( |
|
845 | + array( |
|
846 | + 'oauth' => array( |
|
847 | + 'user:email', |
|
848 | + 'user:name', |
|
849 | + ), |
|
850 | + ), |
|
851 | + ), |
|
852 | + ), $object->toArray()); |
|
853 | + } |
|
854 | + |
|
855 | + /** |
|
856 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
857 | + */ |
|
858 | + public function testHandleCommand_Body_Required() |
|
859 | + { |
|
860 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
861 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
862 | + |
|
863 | + $return = $object->handleCommand('body', 'int foo'); |
|
864 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $return); |
|
865 | + |
|
866 | + $return = $object->handleCommand('response', '200'); |
|
867 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
868 | + |
|
869 | + $this->assertSame(array( |
|
870 | + 'parameters' => array( |
|
871 | + array( |
|
872 | + 'name' => 'foo', |
|
873 | + 'in' => 'body', |
|
874 | + 'required' => true, |
|
875 | + 'schema' => array( |
|
876 | + 'type' => 'integer', |
|
877 | + 'format' => 'int32', |
|
878 | + ), |
|
879 | + ), |
|
880 | + ), |
|
881 | + 'responses' => array( |
|
882 | + 200 => array( |
|
883 | + 'description' => 'OK', |
|
884 | + ), |
|
885 | + ), |
|
886 | + ), $object->toArray()); |
|
887 | + } |
|
888 | + |
|
889 | + /** |
|
890 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
891 | + */ |
|
892 | + public function testHandleCommand_Body_Optional() |
|
893 | + { |
|
894 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
895 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
896 | + |
|
897 | + $return = $object->handleCommand('body?', 'int foo'); |
|
898 | + $this->assertInstanceOf('\SwaggerGen\Swagger\BodyParameter', $return); |
|
899 | + |
|
900 | + $return = $object->handleCommand('response', '200'); |
|
901 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
902 | + |
|
903 | + $this->assertSame(array( |
|
904 | + 'parameters' => array( |
|
905 | + array( |
|
906 | + 'name' => 'foo', |
|
907 | + 'in' => 'body', |
|
908 | + 'schema' => array( |
|
909 | + 'type' => 'integer', |
|
910 | + 'format' => 'int32', |
|
911 | + ), |
|
912 | + ), |
|
913 | + ), |
|
914 | + 'responses' => array( |
|
915 | + 200 => array( |
|
916 | + 'description' => 'OK', |
|
917 | + ), |
|
918 | + ), |
|
919 | + ), $object->toArray()); |
|
920 | + } |
|
921 | + |
|
922 | + /** |
|
923 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
924 | + */ |
|
925 | + public function testHandleCommand_Path_Required() |
|
926 | + { |
|
927 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
928 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
929 | + |
|
930 | + $return = $object->handleCommand('path', 'int foo'); |
|
931 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
932 | + |
|
933 | + $return = $object->handleCommand('response', '200'); |
|
934 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
935 | + |
|
936 | + $this->assertSame(array( |
|
937 | + 'parameters' => array( |
|
938 | + array( |
|
939 | + 'name' => 'foo', |
|
940 | + 'in' => 'path', |
|
941 | + 'required' => true, |
|
942 | + 'type' => 'integer', |
|
943 | + 'format' => 'int32', |
|
944 | + ), |
|
945 | + ), |
|
946 | + 'responses' => array( |
|
947 | + 200 => array( |
|
948 | + 'description' => 'OK', |
|
949 | + ), |
|
950 | + ), |
|
951 | + ), $object->toArray()); |
|
952 | + } |
|
953 | + |
|
954 | + /** |
|
955 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
956 | + */ |
|
957 | + public function testHandleCommand_Query_Required() |
|
958 | + { |
|
959 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
960 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
961 | + |
|
962 | + $return = $object->handleCommand('query', 'int foo'); |
|
963 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
964 | + |
|
965 | + $return = $object->handleCommand('response', '200'); |
|
966 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
967 | + |
|
968 | + $this->assertSame(array( |
|
969 | + 'parameters' => array( |
|
970 | + array( |
|
971 | + 'name' => 'foo', |
|
972 | + 'in' => 'query', |
|
973 | + 'required' => true, |
|
974 | + 'type' => 'integer', |
|
975 | + 'format' => 'int32', |
|
976 | + ), |
|
977 | + ), |
|
978 | + 'responses' => array( |
|
979 | + 200 => array( |
|
980 | + 'description' => 'OK', |
|
981 | + ), |
|
982 | + ), |
|
983 | + ), $object->toArray()); |
|
984 | + } |
|
985 | + |
|
986 | + /** |
|
987 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
988 | + */ |
|
989 | + public function testHandleCommand_Query_Optional() |
|
990 | + { |
|
991 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
992 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
993 | + |
|
994 | + $return = $object->handleCommand('query?', 'int foo'); |
|
995 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
996 | + |
|
997 | + $return = $object->handleCommand('response', '200'); |
|
998 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
999 | + |
|
1000 | + $this->assertSame(array( |
|
1001 | + 'parameters' => array( |
|
1002 | + array( |
|
1003 | + 'name' => 'foo', |
|
1004 | + 'in' => 'query', |
|
1005 | + 'type' => 'integer', |
|
1006 | + 'format' => 'int32', |
|
1007 | + ), |
|
1008 | + ), |
|
1009 | + 'responses' => array( |
|
1010 | + 200 => array( |
|
1011 | + 'description' => 'OK', |
|
1012 | + ), |
|
1013 | + ), |
|
1014 | + ), $object->toArray()); |
|
1015 | + } |
|
1016 | + |
|
1017 | + /** |
|
1018 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1019 | + */ |
|
1020 | + public function testHandleCommand_Header_Required() |
|
1021 | + { |
|
1022 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1023 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1024 | + |
|
1025 | + $return = $object->handleCommand('header', 'int foo'); |
|
1026 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1027 | + |
|
1028 | + $return = $object->handleCommand('response', '200'); |
|
1029 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1030 | + |
|
1031 | + $this->assertSame(array( |
|
1032 | + 'parameters' => array( |
|
1033 | + array( |
|
1034 | + 'name' => 'foo', |
|
1035 | + 'in' => 'header', |
|
1036 | + 'required' => true, |
|
1037 | + 'type' => 'integer', |
|
1038 | + 'format' => 'int32', |
|
1039 | + ), |
|
1040 | + ), |
|
1041 | + 'responses' => array( |
|
1042 | + 200 => array( |
|
1043 | + 'description' => 'OK', |
|
1044 | + ), |
|
1045 | + ), |
|
1046 | + ), $object->toArray()); |
|
1047 | + } |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1051 | + */ |
|
1052 | + public function testHandleCommand_Header_Optional() |
|
1053 | + { |
|
1054 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1055 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1056 | + |
|
1057 | + $return = $object->handleCommand('header?', 'int foo'); |
|
1058 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1059 | + |
|
1060 | + $return = $object->handleCommand('response', '200'); |
|
1061 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1062 | + |
|
1063 | + $this->assertSame(array( |
|
1064 | + 'parameters' => array( |
|
1065 | + array( |
|
1066 | + 'name' => 'foo', |
|
1067 | + 'in' => 'header', |
|
1068 | + 'type' => 'integer', |
|
1069 | + 'format' => 'int32', |
|
1070 | + ), |
|
1071 | + ), |
|
1072 | + 'responses' => array( |
|
1073 | + 200 => array( |
|
1074 | + 'description' => 'OK', |
|
1075 | + ), |
|
1076 | + ), |
|
1077 | + ), $object->toArray()); |
|
1078 | + } |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1082 | + */ |
|
1083 | + public function testHandleCommand_Form_Required() |
|
1084 | + { |
|
1085 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1086 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1087 | + |
|
1088 | + $return = $object->handleCommand('form', 'int foo'); |
|
1089 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1090 | + |
|
1091 | + $return = $object->handleCommand('response', '200'); |
|
1092 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1093 | + |
|
1094 | + $this->assertSame(array( |
|
1095 | + 'parameters' => array( |
|
1096 | + array( |
|
1097 | + 'name' => 'foo', |
|
1098 | + 'in' => 'formData', |
|
1099 | + 'required' => true, |
|
1100 | + 'type' => 'integer', |
|
1101 | + 'format' => 'int32', |
|
1102 | + ), |
|
1103 | + ), |
|
1104 | + 'responses' => array( |
|
1105 | + 200 => array( |
|
1106 | + 'description' => 'OK', |
|
1107 | + ), |
|
1108 | + ), |
|
1109 | + ), $object->toArray()); |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
1114 | + */ |
|
1115 | + public function testHandleCommand_Form_Optional() |
|
1116 | + { |
|
1117 | + $object = new \SwaggerGen\Swagger\Operation($this->parent); |
|
1118 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $object); |
|
1119 | + |
|
1120 | + $return = $object->handleCommand('form?', 'int foo'); |
|
1121 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $return); |
|
1122 | + |
|
1123 | + $return = $object->handleCommand('response', '200'); |
|
1124 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $return); |
|
1125 | + |
|
1126 | + $this->assertSame(array( |
|
1127 | + 'parameters' => array( |
|
1128 | + array( |
|
1129 | + 'name' => 'foo', |
|
1130 | + 'in' => 'formData', |
|
1131 | + 'type' => 'integer', |
|
1132 | + 'format' => 'int32', |
|
1133 | + ), |
|
1134 | + ), |
|
1135 | + 'responses' => array( |
|
1136 | + 200 => array( |
|
1137 | + 'description' => 'OK', |
|
1138 | + ), |
|
1139 | + ), |
|
1140 | + ), $object->toArray()); |
|
1141 | + } |
|
1142 | + |
|
1143 | + protected function setUp(): void |
|
1144 | + { |
|
1145 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\Swagger'); |
|
1146 | + } |
|
1147 | + |
|
1148 | + protected function assertPreConditions(): void |
|
1149 | + { |
|
1150 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
1151 | + } |
|
1152 | 1152 | |
1153 | 1153 | } |
@@ -7,124 +7,124 @@ |
||
7 | 7 | class ContactTest extends TestCase |
8 | 8 | { |
9 | 9 | |
10 | - protected $parent; |
|
11 | - |
|
12 | - /** |
|
13 | - * @covers \SwaggerGen\Swagger\Contact::__construct |
|
14 | - */ |
|
15 | - public function testConstructorEmpty() |
|
16 | - { |
|
17 | - $object = new \SwaggerGen\Swagger\Contact($this->parent); |
|
18 | - |
|
19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
20 | - |
|
21 | - $this->assertSame(array(), $object->toArray()); |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * @covers \SwaggerGen\Swagger\Contact::__construct |
|
26 | - */ |
|
27 | - public function testConstructorName() |
|
28 | - { |
|
29 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name'); |
|
30 | - |
|
31 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
32 | - |
|
33 | - $this->assertSame(array( |
|
34 | - 'name' => 'Name', |
|
35 | - ), $object->toArray()); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @covers \SwaggerGen\Swagger\Contact::__construct |
|
40 | - */ |
|
41 | - public function testConstructorUrl() |
|
42 | - { |
|
43 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, null, 'http://example.com'); |
|
44 | - |
|
45 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
46 | - |
|
47 | - $this->assertSame(array( |
|
48 | - 'url' => 'http://example.com', |
|
49 | - ), $object->toArray()); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @covers \SwaggerGen\Swagger\Contact::__construct |
|
54 | - */ |
|
55 | - public function testConstructorEmail() |
|
56 | - { |
|
57 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, null, null, '[email protected]'); |
|
58 | - |
|
59 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
60 | - |
|
61 | - $this->assertSame(array( |
|
62 | - 'email' => '[email protected]', |
|
63 | - ), $object->toArray()); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
68 | - */ |
|
69 | - public function testCommandName() |
|
70 | - { |
|
71 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
72 | - |
|
73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
74 | - |
|
75 | - $object->handleCommand('name', 'Somebody'); |
|
76 | - |
|
77 | - $this->assertSame(array( |
|
78 | - 'name' => 'Somebody', |
|
79 | - 'url' => 'http://example.com', |
|
80 | - 'email' => '[email protected]', |
|
81 | - ), $object->toArray()); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
86 | - */ |
|
87 | - public function testCommandUrl() |
|
88 | - { |
|
89 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
90 | - |
|
91 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
92 | - |
|
93 | - $object->handleCommand('url', 'http://site.test'); |
|
94 | - |
|
95 | - $this->assertSame(array( |
|
96 | - 'name' => 'Name', |
|
97 | - 'url' => 'http://site.test', |
|
98 | - 'email' => '[email protected]', |
|
99 | - ), $object->toArray()); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
104 | - */ |
|
105 | - public function testCommandEmail() |
|
106 | - { |
|
107 | - $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
108 | - |
|
109 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
110 | - |
|
111 | - $object->handleCommand('email', '[email protected]'); |
|
112 | - |
|
113 | - $this->assertSame(array( |
|
114 | - 'name' => 'Name', |
|
115 | - 'url' => 'http://example.com', |
|
116 | - 'email' => '[email protected]', |
|
117 | - ), $object->toArray()); |
|
118 | - } |
|
119 | - |
|
120 | - protected function setUp(): void |
|
121 | - { |
|
122 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
123 | - } |
|
124 | - |
|
125 | - protected function assertPreConditions(): void |
|
126 | - { |
|
127 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
128 | - } |
|
10 | + protected $parent; |
|
11 | + |
|
12 | + /** |
|
13 | + * @covers \SwaggerGen\Swagger\Contact::__construct |
|
14 | + */ |
|
15 | + public function testConstructorEmpty() |
|
16 | + { |
|
17 | + $object = new \SwaggerGen\Swagger\Contact($this->parent); |
|
18 | + |
|
19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
20 | + |
|
21 | + $this->assertSame(array(), $object->toArray()); |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * @covers \SwaggerGen\Swagger\Contact::__construct |
|
26 | + */ |
|
27 | + public function testConstructorName() |
|
28 | + { |
|
29 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name'); |
|
30 | + |
|
31 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
32 | + |
|
33 | + $this->assertSame(array( |
|
34 | + 'name' => 'Name', |
|
35 | + ), $object->toArray()); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @covers \SwaggerGen\Swagger\Contact::__construct |
|
40 | + */ |
|
41 | + public function testConstructorUrl() |
|
42 | + { |
|
43 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, null, 'http://example.com'); |
|
44 | + |
|
45 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
46 | + |
|
47 | + $this->assertSame(array( |
|
48 | + 'url' => 'http://example.com', |
|
49 | + ), $object->toArray()); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @covers \SwaggerGen\Swagger\Contact::__construct |
|
54 | + */ |
|
55 | + public function testConstructorEmail() |
|
56 | + { |
|
57 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, null, null, '[email protected]'); |
|
58 | + |
|
59 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
60 | + |
|
61 | + $this->assertSame(array( |
|
62 | + 'email' => '[email protected]', |
|
63 | + ), $object->toArray()); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
68 | + */ |
|
69 | + public function testCommandName() |
|
70 | + { |
|
71 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
72 | + |
|
73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
74 | + |
|
75 | + $object->handleCommand('name', 'Somebody'); |
|
76 | + |
|
77 | + $this->assertSame(array( |
|
78 | + 'name' => 'Somebody', |
|
79 | + 'url' => 'http://example.com', |
|
80 | + 'email' => '[email protected]', |
|
81 | + ), $object->toArray()); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
86 | + */ |
|
87 | + public function testCommandUrl() |
|
88 | + { |
|
89 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
90 | + |
|
91 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
92 | + |
|
93 | + $object->handleCommand('url', 'http://site.test'); |
|
94 | + |
|
95 | + $this->assertSame(array( |
|
96 | + 'name' => 'Name', |
|
97 | + 'url' => 'http://site.test', |
|
98 | + 'email' => '[email protected]', |
|
99 | + ), $object->toArray()); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @covers \SwaggerGen\Swagger\Contact::handleCommand |
|
104 | + */ |
|
105 | + public function testCommandEmail() |
|
106 | + { |
|
107 | + $object = new \SwaggerGen\Swagger\Contact($this->parent, 'Name', 'http://example.com', '[email protected]'); |
|
108 | + |
|
109 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Contact', $object); |
|
110 | + |
|
111 | + $object->handleCommand('email', '[email protected]'); |
|
112 | + |
|
113 | + $this->assertSame(array( |
|
114 | + 'name' => 'Name', |
|
115 | + 'url' => 'http://example.com', |
|
116 | + 'email' => '[email protected]', |
|
117 | + ), $object->toArray()); |
|
118 | + } |
|
119 | + |
|
120 | + protected function setUp(): void |
|
121 | + { |
|
122 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
123 | + } |
|
124 | + |
|
125 | + protected function assertPreConditions(): void |
|
126 | + { |
|
127 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
@@ -7,81 +7,81 @@ |
||
7 | 7 | class ErrorTest extends TestCase |
8 | 8 | { |
9 | 9 | |
10 | - protected $parent; |
|
11 | - |
|
12 | - /** |
|
13 | - * @covers \SwaggerGen\Swagger\Error::__construct |
|
14 | - */ |
|
15 | - public function testConstructor_200(): void |
|
16 | - { |
|
17 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
18 | - |
|
19 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
20 | - |
|
21 | - $this->assertSame(array( |
|
22 | - 'description' => 'OK', |
|
23 | - ), $object->toArray()); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @covers \SwaggerGen\Swagger\Error::__construct |
|
28 | - */ |
|
29 | - public function testConstructor_404(): void |
|
30 | - { |
|
31 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 404); |
|
32 | - |
|
33 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
34 | - |
|
35 | - $this->assertSame(array( |
|
36 | - 'description' => 'Not Found', |
|
37 | - ), $object->toArray()); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @covers \SwaggerGen\Swagger\Error::__construct |
|
42 | - */ |
|
43 | - public function testConstructor_Description(): void |
|
44 | - { |
|
45 | - $object = new \SwaggerGen\Swagger\Error($this->parent, '200', 'Fine And Dandy'); |
|
46 | - |
|
47 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
48 | - |
|
49 | - $this->assertSame(array( |
|
50 | - 'description' => 'Fine And Dandy', |
|
51 | - ), $object->toArray()); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Just checks that the `header` command is inherited. Actual tests for |
|
56 | - * this command are in `ResponseTest` |
|
57 | - * @covers \SwaggerGen\Swagger\Type\Error->handleCommand |
|
58 | - */ |
|
59 | - public function testHandleCommand_Header(): void |
|
60 | - { |
|
61 | - $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
62 | - |
|
63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
64 | - |
|
65 | - $object->handleCommand('header', 'integer bar'); |
|
66 | - |
|
67 | - $this->assertSame(array( |
|
68 | - 'description' => 'OK', |
|
69 | - 'headers' => array( |
|
70 | - 'bar' => array( |
|
71 | - 'type' => 'integer', |
|
72 | - ), |
|
73 | - ), |
|
74 | - ), $object->toArray()); |
|
75 | - } |
|
76 | - |
|
77 | - protected function setUp(): void |
|
78 | - { |
|
79 | - $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
80 | - } |
|
81 | - |
|
82 | - protected function assertPreConditions(): void |
|
83 | - { |
|
84 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
85 | - } |
|
10 | + protected $parent; |
|
11 | + |
|
12 | + /** |
|
13 | + * @covers \SwaggerGen\Swagger\Error::__construct |
|
14 | + */ |
|
15 | + public function testConstructor_200(): void |
|
16 | + { |
|
17 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
18 | + |
|
19 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
20 | + |
|
21 | + $this->assertSame(array( |
|
22 | + 'description' => 'OK', |
|
23 | + ), $object->toArray()); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @covers \SwaggerGen\Swagger\Error::__construct |
|
28 | + */ |
|
29 | + public function testConstructor_404(): void |
|
30 | + { |
|
31 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 404); |
|
32 | + |
|
33 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
34 | + |
|
35 | + $this->assertSame(array( |
|
36 | + 'description' => 'Not Found', |
|
37 | + ), $object->toArray()); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @covers \SwaggerGen\Swagger\Error::__construct |
|
42 | + */ |
|
43 | + public function testConstructor_Description(): void |
|
44 | + { |
|
45 | + $object = new \SwaggerGen\Swagger\Error($this->parent, '200', 'Fine And Dandy'); |
|
46 | + |
|
47 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
48 | + |
|
49 | + $this->assertSame(array( |
|
50 | + 'description' => 'Fine And Dandy', |
|
51 | + ), $object->toArray()); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Just checks that the `header` command is inherited. Actual tests for |
|
56 | + * this command are in `ResponseTest` |
|
57 | + * @covers \SwaggerGen\Swagger\Type\Error->handleCommand |
|
58 | + */ |
|
59 | + public function testHandleCommand_Header(): void |
|
60 | + { |
|
61 | + $object = new \SwaggerGen\Swagger\Error($this->parent, 200); |
|
62 | + |
|
63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Error', $object); |
|
64 | + |
|
65 | + $object->handleCommand('header', 'integer bar'); |
|
66 | + |
|
67 | + $this->assertSame(array( |
|
68 | + 'description' => 'OK', |
|
69 | + 'headers' => array( |
|
70 | + 'bar' => array( |
|
71 | + 'type' => 'integer', |
|
72 | + ), |
|
73 | + ), |
|
74 | + ), $object->toArray()); |
|
75 | + } |
|
76 | + |
|
77 | + protected function setUp(): void |
|
78 | + { |
|
79 | + $this->parent = $this->getMockForAbstractClass(AbstractObject::class); |
|
80 | + } |
|
81 | + |
|
82 | + protected function assertPreConditions(): void |
|
83 | + { |
|
84 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
@@ -10,22 +10,22 @@ |
||
10 | 10 | class Issue0012Test extends TestCase |
11 | 11 | { |
12 | 12 | |
13 | - public function testIssue() |
|
14 | - { |
|
15 | - $object = new \SwaggerGen\SwaggerGen(); |
|
16 | - $array = $object->getSwagger(array(' |
|
13 | + public function testIssue() |
|
14 | + { |
|
15 | + $object = new \SwaggerGen\SwaggerGen(); |
|
16 | + $array = $object->getSwagger(array(' |
|
17 | 17 | api Test |
18 | 18 | endpoint /test |
19 | 19 | method GET something |
20 | 20 | response 200 object(modifications:array(ModificationHistory),users:array(User)) |
21 | 21 | ')); |
22 | 22 | |
23 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
25 | - . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
26 | - . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
27 | - . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
28 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
29 | - } |
|
23 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
25 | + . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
26 | + . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
27 | + . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
28 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | } |
@@ -6,128 +6,128 @@ |
||
6 | 6 | class Issue0005Test extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
11 | - */ |
|
12 | - public function testHandleCommand_Model_Property() |
|
13 | - { |
|
14 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
16 | - |
|
17 | - $schema = $object->handleCommand('model', 'foo'); |
|
18 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
19 | - |
|
20 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
21 | - |
|
22 | - $path = $object->handleCommand('endpoint'); |
|
23 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
24 | - |
|
25 | - $this->assertSame(array( |
|
26 | - 'swagger' => '2.0', |
|
27 | - 'info' => array( |
|
28 | - 'title' => 'undefined', |
|
29 | - 'version' => '0', |
|
30 | - ), |
|
31 | - 'paths' => array( |
|
32 | - '/' => array(), |
|
33 | - ), |
|
34 | - 'definitions' => array( |
|
35 | - 'foo' => array( |
|
36 | - 'type' => 'object', |
|
37 | - 'required' => array( |
|
38 | - 'bar', |
|
39 | - ), |
|
40 | - 'properties' => array( |
|
41 | - 'bar' => array( |
|
42 | - 'type' => 'string', |
|
43 | - 'description' => 'Some words here', |
|
44 | - ), |
|
45 | - ), |
|
46 | - ), |
|
47 | - ), |
|
48 | - ), $object->toArray()); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
53 | - */ |
|
54 | - public function testHandleCommand_Model_DuplicateProperties() |
|
55 | - { |
|
56 | - $object = new \SwaggerGen\Swagger\Swagger(); |
|
57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
58 | - |
|
59 | - $schema = $object->handleCommand('model', 'foo'); |
|
60 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
61 | - |
|
62 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
63 | - $schema->handleCommand('property', 'integer bar Some other words'); |
|
64 | - |
|
65 | - $path = $object->handleCommand('endpoint'); |
|
66 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
67 | - |
|
68 | - $this->assertSame(array( |
|
69 | - 'swagger' => '2.0', |
|
70 | - 'info' => array( |
|
71 | - 'title' => 'undefined', |
|
72 | - 'version' => '0', |
|
73 | - ), |
|
74 | - 'paths' => array( |
|
75 | - '/' => array(), |
|
76 | - ), |
|
77 | - 'definitions' => array( |
|
78 | - 'foo' => array( |
|
79 | - 'type' => 'object', |
|
80 | - 'required' => array( |
|
81 | - 'bar', |
|
82 | - ), |
|
83 | - 'properties' => array( |
|
84 | - 'bar' => array( |
|
85 | - 'type' => 'integer', |
|
86 | - 'format' => 'int32', |
|
87 | - 'description' => 'Some other words', |
|
88 | - ), |
|
89 | - ), |
|
90 | - ), |
|
91 | - ), |
|
92 | - ), $object->toArray()); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
97 | - */ |
|
98 | - public function testHandleCommand_Query_Duplicate() |
|
99 | - { |
|
100 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
101 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
102 | - |
|
103 | - $operation = new \SwaggerGen\Swagger\Operation($object); |
|
104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
105 | - |
|
106 | - $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
107 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | - |
|
109 | - $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
110 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
111 | - |
|
112 | - $response = $operation->handleCommand('response', '200'); |
|
113 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
114 | - |
|
115 | - $this->assertSame(array( |
|
116 | - 'parameters' => array( |
|
117 | - array( |
|
118 | - 'name' => 'foo', |
|
119 | - 'in' => 'query', |
|
120 | - 'description' => 'Other text', |
|
121 | - 'required' => true, |
|
122 | - 'type' => 'string', |
|
123 | - ), |
|
124 | - ), |
|
125 | - 'responses' => array( |
|
126 | - 200 => array( |
|
127 | - 'description' => 'OK', |
|
128 | - ), |
|
129 | - ), |
|
130 | - ), $operation->toArray()); |
|
131 | - } |
|
9 | + /** |
|
10 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
11 | + */ |
|
12 | + public function testHandleCommand_Model_Property() |
|
13 | + { |
|
14 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
16 | + |
|
17 | + $schema = $object->handleCommand('model', 'foo'); |
|
18 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
19 | + |
|
20 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
21 | + |
|
22 | + $path = $object->handleCommand('endpoint'); |
|
23 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
24 | + |
|
25 | + $this->assertSame(array( |
|
26 | + 'swagger' => '2.0', |
|
27 | + 'info' => array( |
|
28 | + 'title' => 'undefined', |
|
29 | + 'version' => '0', |
|
30 | + ), |
|
31 | + 'paths' => array( |
|
32 | + '/' => array(), |
|
33 | + ), |
|
34 | + 'definitions' => array( |
|
35 | + 'foo' => array( |
|
36 | + 'type' => 'object', |
|
37 | + 'required' => array( |
|
38 | + 'bar', |
|
39 | + ), |
|
40 | + 'properties' => array( |
|
41 | + 'bar' => array( |
|
42 | + 'type' => 'string', |
|
43 | + 'description' => 'Some words here', |
|
44 | + ), |
|
45 | + ), |
|
46 | + ), |
|
47 | + ), |
|
48 | + ), $object->toArray()); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
53 | + */ |
|
54 | + public function testHandleCommand_Model_DuplicateProperties() |
|
55 | + { |
|
56 | + $object = new \SwaggerGen\Swagger\Swagger(); |
|
57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
58 | + |
|
59 | + $schema = $object->handleCommand('model', 'foo'); |
|
60 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
61 | + |
|
62 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
63 | + $schema->handleCommand('property', 'integer bar Some other words'); |
|
64 | + |
|
65 | + $path = $object->handleCommand('endpoint'); |
|
66 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
67 | + |
|
68 | + $this->assertSame(array( |
|
69 | + 'swagger' => '2.0', |
|
70 | + 'info' => array( |
|
71 | + 'title' => 'undefined', |
|
72 | + 'version' => '0', |
|
73 | + ), |
|
74 | + 'paths' => array( |
|
75 | + '/' => array(), |
|
76 | + ), |
|
77 | + 'definitions' => array( |
|
78 | + 'foo' => array( |
|
79 | + 'type' => 'object', |
|
80 | + 'required' => array( |
|
81 | + 'bar', |
|
82 | + ), |
|
83 | + 'properties' => array( |
|
84 | + 'bar' => array( |
|
85 | + 'type' => 'integer', |
|
86 | + 'format' => 'int32', |
|
87 | + 'description' => 'Some other words', |
|
88 | + ), |
|
89 | + ), |
|
90 | + ), |
|
91 | + ), |
|
92 | + ), $object->toArray()); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
97 | + */ |
|
98 | + public function testHandleCommand_Query_Duplicate() |
|
99 | + { |
|
100 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
101 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
102 | + |
|
103 | + $operation = new \SwaggerGen\Swagger\Operation($object); |
|
104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
105 | + |
|
106 | + $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
107 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | + |
|
109 | + $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
110 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
111 | + |
|
112 | + $response = $operation->handleCommand('response', '200'); |
|
113 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
114 | + |
|
115 | + $this->assertSame(array( |
|
116 | + 'parameters' => array( |
|
117 | + array( |
|
118 | + 'name' => 'foo', |
|
119 | + 'in' => 'query', |
|
120 | + 'description' => 'Other text', |
|
121 | + 'required' => true, |
|
122 | + 'type' => 'string', |
|
123 | + ), |
|
124 | + ), |
|
125 | + 'responses' => array( |
|
126 | + 200 => array( |
|
127 | + 'description' => 'OK', |
|
128 | + ), |
|
129 | + ), |
|
130 | + ), $operation->toArray()); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | class Issue0015Test extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * Tests issue 15; Allow enumeration of property values |
|
11 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
12 | - */ |
|
13 | - public function testPropertyEnumeration() |
|
14 | - { |
|
15 | - $object = new \SwaggerGen\SwaggerGen(); |
|
16 | - $array = $object->getSwagger(array(' |
|
9 | + /** |
|
10 | + * Tests issue 15; Allow enumeration of property values |
|
11 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
12 | + */ |
|
13 | + public function testPropertyEnumeration() |
|
14 | + { |
|
15 | + $object = new \SwaggerGen\SwaggerGen(); |
|
16 | + $array = $object->getSwagger(array(' |
|
17 | 17 | api Test |
18 | 18 | definition ClassName |
19 | 19 | title ClassName |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | response 204 |
27 | 27 | ')); |
28 | 28 | |
29 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
30 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"204":{"description":"No Content"}}}}}' |
|
31 | - . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
32 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | - } |
|
29 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
30 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"204":{"description":"No Content"}}}}}' |
|
31 | + . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
32 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | } |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | class Issue0002Test extends TestCase |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * Tests issue 2; @rest/require should create object on each item |
|
11 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
12 | - */ |
|
13 | - public function testRequireMustBeObject() |
|
14 | - { |
|
15 | - $object = new \SwaggerGen\SwaggerGen(); |
|
16 | - $array = $object->getSwagger(array(' |
|
9 | + /** |
|
10 | + * Tests issue 2; @rest/require should create object on each item |
|
11 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
12 | + */ |
|
13 | + public function testRequireMustBeObject() |
|
14 | + { |
|
15 | + $object = new \SwaggerGen\SwaggerGen(); |
|
16 | + $array = $object->getSwagger(array(' |
|
17 | 17 | security api_key apikey X-Api-Authentication header |
18 | 18 | require api_key |
19 | 19 | api Test |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | response 202 |
24 | 24 | ')); |
25 | 25 | |
26 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
27 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
28 | - . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
29 | - . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
30 | - } |
|
26 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
27 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
28 | + . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
29 | + . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
30 | + } |
|
31 | 31 | |
32 | - public function testRequireAsObjectWithScopes() |
|
33 | - { |
|
34 | - $object = new \SwaggerGen\SwaggerGen(); |
|
35 | - $array = $object->getSwagger(array(' |
|
32 | + public function testRequireAsObjectWithScopes() |
|
33 | + { |
|
34 | + $object = new \SwaggerGen\SwaggerGen(); |
|
35 | + $array = $object->getSwagger(array(' |
|
36 | 36 | security oauth oauth2 implicit http://www.test |
37 | 37 | require oauth user:name |
38 | 38 | api Test |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | response 202 |
43 | 43 | ')); |
44 | 44 | |
45 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
46 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
47 | - . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
48 | - . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
49 | - } |
|
45 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
46 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
47 | + . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
48 | + . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |