@@ -3,247 +3,247 @@ |
||
3 | 3 | class InfoTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\Info |
|
20 | - */ |
|
21 | - public function testNoConstructor(): void |
|
22 | - { |
|
23 | - $object = new \SwaggerGen\Swagger\Info; |
|
24 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
25 | - |
|
26 | - $this->assertSame(array( |
|
27 | - 'title' => 'undefined', |
|
28 | - 'version' => '0', |
|
29 | - ), $object->toArray()); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
34 | - */ |
|
35 | - public function testCommandTitle() |
|
36 | - { |
|
37 | - $object = new \SwaggerGen\Swagger\Info; |
|
38 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
39 | - |
|
40 | - $object->handleCommand('title', 'This is the title'); |
|
41 | - |
|
42 | - $this->assertSame(array( |
|
43 | - 'title' => 'This is the title', |
|
44 | - 'version' => '0', |
|
45 | - ), $object->toArray()); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
50 | - */ |
|
51 | - public function testCommandDescription() |
|
52 | - { |
|
53 | - $object = new \SwaggerGen\Swagger\Info; |
|
54 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
55 | - |
|
56 | - $object->handleCommand('description', 'This is the description'); |
|
57 | - |
|
58 | - $this->assertSame(array( |
|
59 | - 'title' => 'undefined', |
|
60 | - 'description' => 'This is the description', |
|
61 | - 'version' => '0', |
|
62 | - ), $object->toArray()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
67 | - */ |
|
68 | - public function testCommandVersion() |
|
69 | - { |
|
70 | - $object = new \SwaggerGen\Swagger\Info; |
|
71 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
72 | - |
|
73 | - $object->handleCommand('version', '1.2.3a'); |
|
74 | - |
|
75 | - $this->assertSame(array( |
|
76 | - 'title' => 'undefined', |
|
77 | - 'version' => '1.2.3a', |
|
78 | - ), $object->toArray()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
83 | - */ |
|
84 | - public function testCommandTermsofservice() |
|
85 | - { |
|
86 | - $object = new \SwaggerGen\Swagger\Info; |
|
87 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
88 | - |
|
89 | - $object->handleCommand('termsofservice', 'These are the terms'); |
|
90 | - |
|
91 | - $this->assertSame(array( |
|
92 | - 'title' => 'undefined', |
|
93 | - 'termsOfService' => 'These are the terms', |
|
94 | - 'version' => '0', |
|
95 | - ), $object->toArray()); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
100 | - */ |
|
101 | - public function testCommandTerms() |
|
102 | - { |
|
103 | - $object = new \SwaggerGen\Swagger\Info; |
|
104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
105 | - |
|
106 | - $object->handleCommand('terms', 'These are the terms'); |
|
107 | - |
|
108 | - $this->assertSame(array( |
|
109 | - 'title' => 'undefined', |
|
110 | - 'termsOfService' => 'These are the terms', |
|
111 | - 'version' => '0', |
|
112 | - ), $object->toArray()); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
117 | - */ |
|
118 | - public function testCommandContactNameUrlEmail() |
|
119 | - { |
|
120 | - $object = new \SwaggerGen\Swagger\Info; |
|
121 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
122 | - |
|
123 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
124 | - |
|
125 | - $this->assertSame(array( |
|
126 | - 'title' => 'undefined', |
|
127 | - 'contact' => array( |
|
128 | - 'name' => 'Arthur D. Author', |
|
129 | - 'url' => 'http://example.test', |
|
130 | - 'email' => '[email protected]', |
|
131 | - ), |
|
132 | - 'version' => '0', |
|
133 | - ), $object->toArray()); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
138 | - */ |
|
139 | - public function testCommandContactNameEmailNameUrlName() |
|
140 | - { |
|
141 | - $object = new \SwaggerGen\Swagger\Info; |
|
142 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
143 | - |
|
144 | - $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
145 | - |
|
146 | - $this->assertSame(array( |
|
147 | - 'title' => 'undefined', |
|
148 | - 'contact' => array( |
|
149 | - 'name' => 'Arthur D. Author', |
|
150 | - 'url' => 'http://example.test', |
|
151 | - 'email' => '[email protected]', |
|
152 | - ), |
|
153 | - 'version' => '0', |
|
154 | - ), $object->toArray()); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
159 | - */ |
|
160 | - public function testCommandLicenseNameUrl() |
|
161 | - { |
|
162 | - $object = new \SwaggerGen\Swagger\Info; |
|
163 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
164 | - |
|
165 | - $object->handleCommand('license', 'NAME http://example.test'); |
|
166 | - |
|
167 | - $this->assertSame(array( |
|
168 | - 'title' => 'undefined', |
|
169 | - 'license' => array( |
|
170 | - 'name' => 'NAME', |
|
171 | - 'url' => 'http://example.test', |
|
172 | - ), |
|
173 | - 'version' => '0', |
|
174 | - ), $object->toArray()); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
179 | - */ |
|
180 | - public function testCommandLicenseUrlName() |
|
181 | - { |
|
182 | - $object = new \SwaggerGen\Swagger\Info; |
|
183 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
184 | - |
|
185 | - $object->handleCommand('license', 'http://example.test NAME'); |
|
186 | - |
|
187 | - $this->assertSame(array( |
|
188 | - 'title' => 'undefined', |
|
189 | - 'license' => array( |
|
190 | - 'name' => 'NAME', |
|
191 | - 'url' => 'http://example.test', |
|
192 | - ), |
|
193 | - 'version' => '0', |
|
194 | - ), $object->toArray()); |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
199 | - */ |
|
200 | - public function testCommandLicenseShorthand() |
|
201 | - { |
|
202 | - $object = new \SwaggerGen\Swagger\Info; |
|
203 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
204 | - |
|
205 | - $object->handleCommand('license', 'BSD'); |
|
206 | - |
|
207 | - $this->assertSame(array( |
|
208 | - 'title' => 'undefined', |
|
209 | - 'license' => array( |
|
210 | - 'name' => 'BSD', |
|
211 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
212 | - ), |
|
213 | - 'version' => '0', |
|
214 | - ), $object->toArray()); |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
219 | - */ |
|
220 | - public function testCommandAll() |
|
221 | - { |
|
222 | - $object = new \SwaggerGen\Swagger\Info; |
|
223 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
224 | - |
|
225 | - $object->handleCommand('description', 'This is the description'); |
|
226 | - $object->handleCommand('license', 'BSD'); |
|
227 | - $object->handleCommand('terms', 'These are the terms'); |
|
228 | - $object->handleCommand('version', '1.2.3a'); |
|
229 | - $object->handleCommand('title', 'This is the title'); |
|
230 | - $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
231 | - |
|
232 | - $this->assertSame(array( |
|
233 | - 'title' => 'This is the title', |
|
234 | - 'description' => 'This is the description', |
|
235 | - 'termsOfService' => 'These are the terms', |
|
236 | - 'contact' => array( |
|
237 | - 'name' => 'Arthur D. Author', |
|
238 | - 'url' => 'http://example.test', |
|
239 | - 'email' => '[email protected]', |
|
240 | - ), |
|
241 | - 'license' => array( |
|
242 | - 'name' => 'BSD', |
|
243 | - 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
244 | - ), |
|
245 | - 'version' => '1.2.3a', |
|
246 | - ), $object->toArray()); |
|
247 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\Info |
|
20 | + */ |
|
21 | + public function testNoConstructor(): void |
|
22 | + { |
|
23 | + $object = new \SwaggerGen\Swagger\Info; |
|
24 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
25 | + |
|
26 | + $this->assertSame(array( |
|
27 | + 'title' => 'undefined', |
|
28 | + 'version' => '0', |
|
29 | + ), $object->toArray()); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
34 | + */ |
|
35 | + public function testCommandTitle() |
|
36 | + { |
|
37 | + $object = new \SwaggerGen\Swagger\Info; |
|
38 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
39 | + |
|
40 | + $object->handleCommand('title', 'This is the title'); |
|
41 | + |
|
42 | + $this->assertSame(array( |
|
43 | + 'title' => 'This is the title', |
|
44 | + 'version' => '0', |
|
45 | + ), $object->toArray()); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
50 | + */ |
|
51 | + public function testCommandDescription() |
|
52 | + { |
|
53 | + $object = new \SwaggerGen\Swagger\Info; |
|
54 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
55 | + |
|
56 | + $object->handleCommand('description', 'This is the description'); |
|
57 | + |
|
58 | + $this->assertSame(array( |
|
59 | + 'title' => 'undefined', |
|
60 | + 'description' => 'This is the description', |
|
61 | + 'version' => '0', |
|
62 | + ), $object->toArray()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
67 | + */ |
|
68 | + public function testCommandVersion() |
|
69 | + { |
|
70 | + $object = new \SwaggerGen\Swagger\Info; |
|
71 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
72 | + |
|
73 | + $object->handleCommand('version', '1.2.3a'); |
|
74 | + |
|
75 | + $this->assertSame(array( |
|
76 | + 'title' => 'undefined', |
|
77 | + 'version' => '1.2.3a', |
|
78 | + ), $object->toArray()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
83 | + */ |
|
84 | + public function testCommandTermsofservice() |
|
85 | + { |
|
86 | + $object = new \SwaggerGen\Swagger\Info; |
|
87 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
88 | + |
|
89 | + $object->handleCommand('termsofservice', 'These are the terms'); |
|
90 | + |
|
91 | + $this->assertSame(array( |
|
92 | + 'title' => 'undefined', |
|
93 | + 'termsOfService' => 'These are the terms', |
|
94 | + 'version' => '0', |
|
95 | + ), $object->toArray()); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
100 | + */ |
|
101 | + public function testCommandTerms() |
|
102 | + { |
|
103 | + $object = new \SwaggerGen\Swagger\Info; |
|
104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
105 | + |
|
106 | + $object->handleCommand('terms', 'These are the terms'); |
|
107 | + |
|
108 | + $this->assertSame(array( |
|
109 | + 'title' => 'undefined', |
|
110 | + 'termsOfService' => 'These are the terms', |
|
111 | + 'version' => '0', |
|
112 | + ), $object->toArray()); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
117 | + */ |
|
118 | + public function testCommandContactNameUrlEmail() |
|
119 | + { |
|
120 | + $object = new \SwaggerGen\Swagger\Info; |
|
121 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
122 | + |
|
123 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
124 | + |
|
125 | + $this->assertSame(array( |
|
126 | + 'title' => 'undefined', |
|
127 | + 'contact' => array( |
|
128 | + 'name' => 'Arthur D. Author', |
|
129 | + 'url' => 'http://example.test', |
|
130 | + 'email' => '[email protected]', |
|
131 | + ), |
|
132 | + 'version' => '0', |
|
133 | + ), $object->toArray()); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
138 | + */ |
|
139 | + public function testCommandContactNameEmailNameUrlName() |
|
140 | + { |
|
141 | + $object = new \SwaggerGen\Swagger\Info; |
|
142 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
143 | + |
|
144 | + $object->handleCommand('contact', 'Arthur [email protected] D. http://example.test Author '); |
|
145 | + |
|
146 | + $this->assertSame(array( |
|
147 | + 'title' => 'undefined', |
|
148 | + 'contact' => array( |
|
149 | + 'name' => 'Arthur D. Author', |
|
150 | + 'url' => 'http://example.test', |
|
151 | + 'email' => '[email protected]', |
|
152 | + ), |
|
153 | + 'version' => '0', |
|
154 | + ), $object->toArray()); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
159 | + */ |
|
160 | + public function testCommandLicenseNameUrl() |
|
161 | + { |
|
162 | + $object = new \SwaggerGen\Swagger\Info; |
|
163 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
164 | + |
|
165 | + $object->handleCommand('license', 'NAME http://example.test'); |
|
166 | + |
|
167 | + $this->assertSame(array( |
|
168 | + 'title' => 'undefined', |
|
169 | + 'license' => array( |
|
170 | + 'name' => 'NAME', |
|
171 | + 'url' => 'http://example.test', |
|
172 | + ), |
|
173 | + 'version' => '0', |
|
174 | + ), $object->toArray()); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
179 | + */ |
|
180 | + public function testCommandLicenseUrlName() |
|
181 | + { |
|
182 | + $object = new \SwaggerGen\Swagger\Info; |
|
183 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
184 | + |
|
185 | + $object->handleCommand('license', 'http://example.test NAME'); |
|
186 | + |
|
187 | + $this->assertSame(array( |
|
188 | + 'title' => 'undefined', |
|
189 | + 'license' => array( |
|
190 | + 'name' => 'NAME', |
|
191 | + 'url' => 'http://example.test', |
|
192 | + ), |
|
193 | + 'version' => '0', |
|
194 | + ), $object->toArray()); |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
199 | + */ |
|
200 | + public function testCommandLicenseShorthand() |
|
201 | + { |
|
202 | + $object = new \SwaggerGen\Swagger\Info; |
|
203 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
204 | + |
|
205 | + $object->handleCommand('license', 'BSD'); |
|
206 | + |
|
207 | + $this->assertSame(array( |
|
208 | + 'title' => 'undefined', |
|
209 | + 'license' => array( |
|
210 | + 'name' => 'BSD', |
|
211 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
212 | + ), |
|
213 | + 'version' => '0', |
|
214 | + ), $object->toArray()); |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @covers \SwaggerGen\Swagger\Info::handleCommand |
|
219 | + */ |
|
220 | + public function testCommandAll() |
|
221 | + { |
|
222 | + $object = new \SwaggerGen\Swagger\Info; |
|
223 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Info', $object); |
|
224 | + |
|
225 | + $object->handleCommand('description', 'This is the description'); |
|
226 | + $object->handleCommand('license', 'BSD'); |
|
227 | + $object->handleCommand('terms', 'These are the terms'); |
|
228 | + $object->handleCommand('version', '1.2.3a'); |
|
229 | + $object->handleCommand('title', 'This is the title'); |
|
230 | + $object->handleCommand('contact', 'Arthur D. Author http://example.test [email protected]'); |
|
231 | + |
|
232 | + $this->assertSame(array( |
|
233 | + 'title' => 'This is the title', |
|
234 | + 'description' => 'This is the description', |
|
235 | + 'termsOfService' => 'These are the terms', |
|
236 | + 'contact' => array( |
|
237 | + 'name' => 'Arthur D. Author', |
|
238 | + 'url' => 'http://example.test', |
|
239 | + 'email' => '[email protected]', |
|
240 | + ), |
|
241 | + 'license' => array( |
|
242 | + 'name' => 'BSD', |
|
243 | + 'url' => 'https://opensource.org/licenses/BSD-2-Clause', |
|
244 | + ), |
|
245 | + 'version' => '1.2.3a', |
|
246 | + ), $object->toArray()); |
|
247 | + } |
|
248 | 248 | |
249 | 249 | } |
@@ -3,113 +3,113 @@ |
||
3 | 3 | class LicenseTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - protected $parent; |
|
7 | - |
|
8 | - protected function setUp(): void |
|
9 | - { |
|
10 | - $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | - } |
|
12 | - |
|
13 | - protected function assertPreConditions(): void |
|
14 | - { |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
20 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
21 | - */ |
|
22 | - public function testConstructor2Unknown(): void |
|
23 | - { |
|
24 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
25 | - |
|
26 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
27 | - |
|
28 | - $this->assertSame(array( |
|
29 | - 'name' => 'Name', |
|
30 | - ), $object->toArray()); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
35 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
36 | - */ |
|
37 | - public function testConstructor2Known() |
|
38 | - { |
|
39 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
40 | - |
|
41 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
42 | - |
|
43 | - $this->assertSame(array( |
|
44 | - 'name' => 'MIT', |
|
45 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
46 | - ), $object->toArray()); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
51 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
52 | - */ |
|
53 | - public function testConstructor3Unknown() |
|
54 | - { |
|
55 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
56 | - |
|
57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
58 | - |
|
59 | - $this->assertSame(array( |
|
60 | - 'name' => 'Name', |
|
61 | - 'url' => 'http://example', |
|
62 | - ), $object->toArray()); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @covers \SwaggerGen\Swagger\License::__construct |
|
67 | - * @covers \SwaggerGen\Swagger\License::toArray |
|
68 | - */ |
|
69 | - public function testConstructor3Known() |
|
70 | - { |
|
71 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
72 | - |
|
73 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
74 | - |
|
75 | - $this->assertSame(array( |
|
76 | - 'name' => 'MIT', |
|
77 | - 'url' => 'http://example', |
|
78 | - ), $object->toArray()); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
83 | - */ |
|
84 | - public function testCommandName() |
|
85 | - { |
|
86 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
87 | - |
|
88 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
89 | - |
|
90 | - $object->handleCommand('name', 'GPL-3'); |
|
91 | - |
|
92 | - $this->assertSame(array( |
|
93 | - 'name' => 'GPL-3', |
|
94 | - 'url' => 'http://opensource.org/licenses/MIT', |
|
95 | - ), $object->toArray()); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
100 | - */ |
|
101 | - public function testCommandUrl() |
|
102 | - { |
|
103 | - $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
104 | - |
|
105 | - $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
106 | - |
|
107 | - $object->handleCommand('url', 'http://example'); |
|
108 | - |
|
109 | - $this->assertSame(array( |
|
110 | - 'name' => 'MIT', |
|
111 | - 'url' => 'http://example', |
|
112 | - ), $object->toArray()); |
|
113 | - } |
|
6 | + protected $parent; |
|
7 | + |
|
8 | + protected function setUp(): void |
|
9 | + { |
|
10 | + $this->parent = $this->getMockForAbstractClass('\SwaggerGen\Swagger\AbstractObject'); |
|
11 | + } |
|
12 | + |
|
13 | + protected function assertPreConditions(): void |
|
14 | + { |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\AbstractObject', $this->parent); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
20 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
21 | + */ |
|
22 | + public function testConstructor2Unknown(): void |
|
23 | + { |
|
24 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name'); |
|
25 | + |
|
26 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
27 | + |
|
28 | + $this->assertSame(array( |
|
29 | + 'name' => 'Name', |
|
30 | + ), $object->toArray()); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
35 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
36 | + */ |
|
37 | + public function testConstructor2Known() |
|
38 | + { |
|
39 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
40 | + |
|
41 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
42 | + |
|
43 | + $this->assertSame(array( |
|
44 | + 'name' => 'MIT', |
|
45 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
46 | + ), $object->toArray()); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
51 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
52 | + */ |
|
53 | + public function testConstructor3Unknown() |
|
54 | + { |
|
55 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'Name', 'http://example'); |
|
56 | + |
|
57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
58 | + |
|
59 | + $this->assertSame(array( |
|
60 | + 'name' => 'Name', |
|
61 | + 'url' => 'http://example', |
|
62 | + ), $object->toArray()); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @covers \SwaggerGen\Swagger\License::__construct |
|
67 | + * @covers \SwaggerGen\Swagger\License::toArray |
|
68 | + */ |
|
69 | + public function testConstructor3Known() |
|
70 | + { |
|
71 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT', 'http://example'); |
|
72 | + |
|
73 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
74 | + |
|
75 | + $this->assertSame(array( |
|
76 | + 'name' => 'MIT', |
|
77 | + 'url' => 'http://example', |
|
78 | + ), $object->toArray()); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
83 | + */ |
|
84 | + public function testCommandName() |
|
85 | + { |
|
86 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
87 | + |
|
88 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
89 | + |
|
90 | + $object->handleCommand('name', 'GPL-3'); |
|
91 | + |
|
92 | + $this->assertSame(array( |
|
93 | + 'name' => 'GPL-3', |
|
94 | + 'url' => 'http://opensource.org/licenses/MIT', |
|
95 | + ), $object->toArray()); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @covers \SwaggerGen\Swagger\Tag::handleCommand |
|
100 | + */ |
|
101 | + public function testCommandUrl() |
|
102 | + { |
|
103 | + $object = new \SwaggerGen\Swagger\License($this->parent, 'MIT'); |
|
104 | + |
|
105 | + $this->assertInstanceOf('\SwaggerGen\Swagger\License', $object); |
|
106 | + |
|
107 | + $object->handleCommand('url', 'http://example'); |
|
108 | + |
|
109 | + $this->assertSame(array( |
|
110 | + 'name' => 'MIT', |
|
111 | + 'url' => 'http://example', |
|
112 | + ), $object->toArray()); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
@@ -3,94 +3,94 @@ discard block |
||
3 | 3 | class SwaggerGenTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\SwaggerGen::__construct |
|
8 | - */ |
|
9 | - public function testConstructor_Empty() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\SwaggerGen(); |
|
12 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
13 | - |
|
14 | - $this->expectException('\SwaggerGen\Exception', 'No path defined'); |
|
15 | - $object->getSwagger(array()); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
20 | - */ |
|
21 | - public function testGetSwagger_ShortestPossible() |
|
22 | - { |
|
23 | - $object = new \SwaggerGen\SwaggerGen(); |
|
24 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
25 | - |
|
26 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\SwaggerGen::__construct |
|
8 | + */ |
|
9 | + public function testConstructor_Empty() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\SwaggerGen(); |
|
12 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
13 | + |
|
14 | + $this->expectException('\SwaggerGen\Exception', 'No path defined'); |
|
15 | + $object->getSwagger(array()); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
20 | + */ |
|
21 | + public function testGetSwagger_ShortestPossible() |
|
22 | + { |
|
23 | + $object = new \SwaggerGen\SwaggerGen(); |
|
24 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
25 | + |
|
26 | + $array = $object->getSwagger(array(' |
|
27 | 27 | endpoint |
28 | 28 | method GET |
29 | 29 | response 202 |
30 | 30 | ')); |
31 | 31 | |
32 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | - } |
|
32 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @covers \SwaggerGen\SwaggerGen::__construct |
|
37 | + */ |
|
38 | + public function testConstructor_BadContext() |
|
39 | + { |
|
40 | + $object = new \SwaggerGen\SwaggerGen(); |
|
41 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
34 | 42 | |
35 | - /** |
|
36 | - * @covers \SwaggerGen\SwaggerGen::__construct |
|
37 | - */ |
|
38 | - public function testConstructor_BadContext() |
|
39 | - { |
|
40 | - $object = new \SwaggerGen\SwaggerGen(); |
|
41 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
42 | - |
|
43 | - $this->expectException('\SwaggerGen\StatementException', 'Invalid error code: \'\''); |
|
44 | - try { |
|
45 | - $object->getSwagger(array(' |
|
43 | + $this->expectException('\SwaggerGen\StatementException', 'Invalid error code: \'\''); |
|
44 | + try { |
|
45 | + $object->getSwagger(array(' |
|
46 | 46 | endpoint |
47 | 47 | method GET |
48 | 48 | error |
49 | 49 | ')); |
50 | - } catch (\SwaggerGen\StatementException $e) { |
|
51 | - $this->assertSame("Invalid error code: ''", $e->getMessage()); |
|
52 | - $this->assertSame(3, $e->getStatement()->getLine()); |
|
53 | - |
|
54 | - throw $e; // rethrow to satisfy expected exception check |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
60 | - */ |
|
61 | - public function testGetSwagger_JSON() |
|
62 | - { |
|
63 | - $object = new \SwaggerGen\SwaggerGen(); |
|
64 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
65 | - |
|
66 | - $output = $object->getSwagger(array(' |
|
50 | + } catch (\SwaggerGen\StatementException $e) { |
|
51 | + $this->assertSame("Invalid error code: ''", $e->getMessage()); |
|
52 | + $this->assertSame(3, $e->getStatement()->getLine()); |
|
53 | + |
|
54 | + throw $e; // rethrow to satisfy expected exception check |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
60 | + */ |
|
61 | + public function testGetSwagger_JSON() |
|
62 | + { |
|
63 | + $object = new \SwaggerGen\SwaggerGen(); |
|
64 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
65 | + |
|
66 | + $output = $object->getSwagger(array(' |
|
67 | 67 | endpoint |
68 | 68 | method GET |
69 | 69 | response 202 |
70 | 70 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_JSON); |
71 | 71 | |
72 | - $this->assertSame('{"swagger":"2.0","info":{"title":"undefined","version":"0"},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', $output); |
|
73 | - } |
|
72 | + $this->assertSame('{"swagger":"2.0","info":{"title":"undefined","version":"0"},"paths":{"\/":{"get":{"responses":{"202":{"description":"Accepted"}}}}}}', $output); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
77 | - */ |
|
78 | - public function testGetSwagger_JSON_Pretty() |
|
79 | - { |
|
80 | - if (!defined('JSON_PRETTY_PRINT')) { |
|
81 | - $this->markTestSkipped('JSON_PRETTY_PRINT available since PHP 5.4.0'); |
|
82 | - } |
|
75 | + /** |
|
76 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
77 | + */ |
|
78 | + public function testGetSwagger_JSON_Pretty() |
|
79 | + { |
|
80 | + if (!defined('JSON_PRETTY_PRINT')) { |
|
81 | + $this->markTestSkipped('JSON_PRETTY_PRINT available since PHP 5.4.0'); |
|
82 | + } |
|
83 | 83 | |
84 | - $object = new \SwaggerGen\SwaggerGen(); |
|
85 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
84 | + $object = new \SwaggerGen\SwaggerGen(); |
|
85 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
86 | 86 | |
87 | - $output = $object->getSwagger(array(' |
|
87 | + $output = $object->getSwagger(array(' |
|
88 | 88 | endpoint |
89 | 89 | method GET |
90 | 90 | response 202 |
91 | 91 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_JSON_PRETTY); |
92 | 92 | |
93 | - $this->assertSame('{ |
|
93 | + $this->assertSame('{ |
|
94 | 94 | "swagger": "2.0", |
95 | 95 | "info": { |
96 | 96 | "title": "undefined", |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | }', $output); |
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
115 | - */ |
|
116 | - public function testGetSwagger_YAML() |
|
117 | - { |
|
118 | - if (!extension_loaded('yaml')) { |
|
119 | - $this->markTestSkipped('The YAML extension is not available.'); |
|
120 | - } else { |
|
121 | - $object = new \SwaggerGen\SwaggerGen(); |
|
122 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
123 | - |
|
124 | - $output = $object->getSwagger(array(' |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @covers \SwaggerGen\SwaggerGen::getSwagger |
|
115 | + */ |
|
116 | + public function testGetSwagger_YAML() |
|
117 | + { |
|
118 | + if (!extension_loaded('yaml')) { |
|
119 | + $this->markTestSkipped('The YAML extension is not available.'); |
|
120 | + } else { |
|
121 | + $object = new \SwaggerGen\SwaggerGen(); |
|
122 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
123 | + |
|
124 | + $output = $object->getSwagger(array(' |
|
125 | 125 | endpoint |
126 | 126 | method GET |
127 | 127 | response 202 |
128 | 128 | '), array(), \SwaggerGen\SwaggerGen::FORMAT_YAML); |
129 | 129 | |
130 | - $this->assertSame('--- |
|
130 | + $this->assertSame('--- |
|
131 | 131 | swagger: "2.0" |
132 | 132 | info: |
133 | 133 | title: undefined |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | description: Accepted |
141 | 141 | ... |
142 | 142 | ', $output); |
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @covers \SwaggerGen\SwaggerGen::define |
|
148 | - */ |
|
149 | - public function testDefine_NotDefined() |
|
150 | - { |
|
151 | - $object = new \SwaggerGen\SwaggerGen(); |
|
152 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
153 | - |
|
154 | - $array = $object->getSwagger(array(' |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @covers \SwaggerGen\SwaggerGen::define |
|
148 | + */ |
|
149 | + public function testDefine_NotDefined() |
|
150 | + { |
|
151 | + $object = new \SwaggerGen\SwaggerGen(); |
|
152 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
153 | + |
|
154 | + $array = $object->getSwagger(array(' |
|
155 | 155 | endpoint |
156 | 156 | method GET |
157 | 157 | if d |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | response 204 |
161 | 161 | endif |
162 | 162 | ')); |
163 | - $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
164 | - $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @covers \SwaggerGen\SwaggerGen::define |
|
169 | - */ |
|
170 | - public function testDefine_Defined() |
|
171 | - { |
|
172 | - $object = new \SwaggerGen\SwaggerGen(); |
|
173 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
174 | - |
|
175 | - $object->define('d'); |
|
176 | - $array = $object->getSwagger(array(' |
|
163 | + $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
164 | + $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @covers \SwaggerGen\SwaggerGen::define |
|
169 | + */ |
|
170 | + public function testDefine_Defined() |
|
171 | + { |
|
172 | + $object = new \SwaggerGen\SwaggerGen(); |
|
173 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
174 | + |
|
175 | + $object->define('d'); |
|
176 | + $array = $object->getSwagger(array(' |
|
177 | 177 | endpoint |
178 | 178 | method GET |
179 | 179 | if d |
@@ -182,21 +182,21 @@ discard block |
||
182 | 182 | response 204 |
183 | 183 | endif |
184 | 184 | ')); |
185 | - $this->assertArrayHasKey(202, $array['paths']['/']['get']['responses']); |
|
186 | - $this->assertArrayNotHasKey(204, $array['paths']['/']['get']['responses']); |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @covers \SwaggerGen\SwaggerGen::define |
|
191 | - */ |
|
192 | - public function testUndefine() |
|
193 | - { |
|
194 | - $object = new \SwaggerGen\SwaggerGen(); |
|
195 | - $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
196 | - |
|
197 | - $object->define('d'); |
|
198 | - $object->undefine('d'); |
|
199 | - $array = $object->getSwagger(array(' |
|
185 | + $this->assertArrayHasKey(202, $array['paths']['/']['get']['responses']); |
|
186 | + $this->assertArrayNotHasKey(204, $array['paths']['/']['get']['responses']); |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @covers \SwaggerGen\SwaggerGen::define |
|
191 | + */ |
|
192 | + public function testUndefine() |
|
193 | + { |
|
194 | + $object = new \SwaggerGen\SwaggerGen(); |
|
195 | + $this->assertInstanceof('\SwaggerGen\SwaggerGen', $object); |
|
196 | + |
|
197 | + $object->define('d'); |
|
198 | + $object->undefine('d'); |
|
199 | + $array = $object->getSwagger(array(' |
|
200 | 200 | endpoint |
201 | 201 | method GET |
202 | 202 | if d |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | response 204 |
206 | 206 | endif |
207 | 207 | ')); |
208 | - $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
209 | - $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
210 | - } |
|
208 | + $this->assertArrayNotHasKey(202, $array['paths']['/']['get']['responses']); |
|
209 | + $this->assertArrayHasKey(204, $array['paths']['/']['get']['responses']); |
|
210 | + } |
|
211 | 211 | } |
@@ -3,128 +3,128 @@ |
||
3 | 3 | class Issue0005Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
8 | - */ |
|
9 | - public function testHandleCommand_Model_Property() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
12 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
13 | - |
|
14 | - $schema = $object->handleCommand('model', 'foo'); |
|
15 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
16 | - |
|
17 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
18 | - |
|
19 | - $path = $object->handleCommand('endpoint'); |
|
20 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
21 | - |
|
22 | - $this->assertSame(array( |
|
23 | - 'swagger' => '2.0', |
|
24 | - 'info' => array( |
|
25 | - 'title' => 'undefined', |
|
26 | - 'version' => '0', |
|
27 | - ), |
|
28 | - 'paths' => array( |
|
29 | - '/' => array(), |
|
30 | - ), |
|
31 | - 'definitions' => array( |
|
32 | - 'foo' => array( |
|
33 | - 'type' => 'object', |
|
34 | - 'required' => array( |
|
35 | - 'bar', |
|
36 | - ), |
|
37 | - 'properties' => array( |
|
38 | - 'bar' => array( |
|
39 | - 'type' => 'string', |
|
40 | - 'description' => 'Some words here', |
|
41 | - ), |
|
42 | - ), |
|
43 | - ), |
|
44 | - ), |
|
45 | - ), $object->toArray()); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
50 | - */ |
|
51 | - public function testHandleCommand_Model_DuplicateProperties() |
|
52 | - { |
|
53 | - $object = new \SwaggerGen\Swagger\Swagger(); |
|
54 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
55 | - |
|
56 | - $schema = $object->handleCommand('model', 'foo'); |
|
57 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
58 | - |
|
59 | - $schema->handleCommand('property', 'string bar Some words here'); |
|
60 | - $schema->handleCommand('property', 'integer bar Some other words'); |
|
61 | - |
|
62 | - $path = $object->handleCommand('endpoint'); |
|
63 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
64 | - |
|
65 | - $this->assertSame(array( |
|
66 | - 'swagger' => '2.0', |
|
67 | - 'info' => array( |
|
68 | - 'title' => 'undefined', |
|
69 | - 'version' => '0', |
|
70 | - ), |
|
71 | - 'paths' => array( |
|
72 | - '/' => array(), |
|
73 | - ), |
|
74 | - 'definitions' => array( |
|
75 | - 'foo' => array( |
|
76 | - 'type' => 'object', |
|
77 | - 'required' => array( |
|
78 | - 'bar', |
|
79 | - ), |
|
80 | - 'properties' => array( |
|
81 | - 'bar' => array( |
|
82 | - 'type' => 'integer', |
|
83 | - 'format' => 'int32', |
|
84 | - 'description' => 'Some other words', |
|
85 | - ), |
|
86 | - ), |
|
87 | - ), |
|
88 | - ), |
|
89 | - ), $object->toArray()); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
94 | - */ |
|
95 | - public function testHandleCommand_Query_Duplicate() |
|
96 | - { |
|
97 | - $object = new \SwaggerGen\Swagger\Swagger; |
|
98 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
99 | - |
|
100 | - $operation = new \SwaggerGen\Swagger\Operation($object); |
|
101 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
102 | - |
|
103 | - $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
104 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
105 | - |
|
106 | - $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
107 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | - |
|
109 | - $response = $operation->handleCommand('response', '200'); |
|
110 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
111 | - |
|
112 | - $this->assertSame(array( |
|
113 | - 'parameters' => array( |
|
114 | - array( |
|
115 | - 'name' => 'foo', |
|
116 | - 'in' => 'query', |
|
117 | - 'description' => 'Other text', |
|
118 | - 'required' => true, |
|
119 | - 'type' => 'string', |
|
120 | - ), |
|
121 | - ), |
|
122 | - 'responses' => array( |
|
123 | - 200 => array( |
|
124 | - 'description' => 'OK', |
|
125 | - ), |
|
126 | - ), |
|
127 | - ), $operation->toArray()); |
|
128 | - } |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
8 | + */ |
|
9 | + public function testHandleCommand_Model_Property() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
12 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
13 | + |
|
14 | + $schema = $object->handleCommand('model', 'foo'); |
|
15 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
16 | + |
|
17 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
18 | + |
|
19 | + $path = $object->handleCommand('endpoint'); |
|
20 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
21 | + |
|
22 | + $this->assertSame(array( |
|
23 | + 'swagger' => '2.0', |
|
24 | + 'info' => array( |
|
25 | + 'title' => 'undefined', |
|
26 | + 'version' => '0', |
|
27 | + ), |
|
28 | + 'paths' => array( |
|
29 | + '/' => array(), |
|
30 | + ), |
|
31 | + 'definitions' => array( |
|
32 | + 'foo' => array( |
|
33 | + 'type' => 'object', |
|
34 | + 'required' => array( |
|
35 | + 'bar', |
|
36 | + ), |
|
37 | + 'properties' => array( |
|
38 | + 'bar' => array( |
|
39 | + 'type' => 'string', |
|
40 | + 'description' => 'Some words here', |
|
41 | + ), |
|
42 | + ), |
|
43 | + ), |
|
44 | + ), |
|
45 | + ), $object->toArray()); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @covers \SwaggerGen\Swagger\Swagger::__construct |
|
50 | + */ |
|
51 | + public function testHandleCommand_Model_DuplicateProperties() |
|
52 | + { |
|
53 | + $object = new \SwaggerGen\Swagger\Swagger(); |
|
54 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
55 | + |
|
56 | + $schema = $object->handleCommand('model', 'foo'); |
|
57 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Schema', $schema); |
|
58 | + |
|
59 | + $schema->handleCommand('property', 'string bar Some words here'); |
|
60 | + $schema->handleCommand('property', 'integer bar Some other words'); |
|
61 | + |
|
62 | + $path = $object->handleCommand('endpoint'); |
|
63 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Path', $path); |
|
64 | + |
|
65 | + $this->assertSame(array( |
|
66 | + 'swagger' => '2.0', |
|
67 | + 'info' => array( |
|
68 | + 'title' => 'undefined', |
|
69 | + 'version' => '0', |
|
70 | + ), |
|
71 | + 'paths' => array( |
|
72 | + '/' => array(), |
|
73 | + ), |
|
74 | + 'definitions' => array( |
|
75 | + 'foo' => array( |
|
76 | + 'type' => 'object', |
|
77 | + 'required' => array( |
|
78 | + 'bar', |
|
79 | + ), |
|
80 | + 'properties' => array( |
|
81 | + 'bar' => array( |
|
82 | + 'type' => 'integer', |
|
83 | + 'format' => 'int32', |
|
84 | + 'description' => 'Some other words', |
|
85 | + ), |
|
86 | + ), |
|
87 | + ), |
|
88 | + ), |
|
89 | + ), $object->toArray()); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @covers \SwaggerGen\Swagger\Operation::handleCommand |
|
94 | + */ |
|
95 | + public function testHandleCommand_Query_Duplicate() |
|
96 | + { |
|
97 | + $object = new \SwaggerGen\Swagger\Swagger; |
|
98 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Swagger', $object); |
|
99 | + |
|
100 | + $operation = new \SwaggerGen\Swagger\Operation($object); |
|
101 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Operation', $operation); |
|
102 | + |
|
103 | + $parameter = $operation->handleCommand('query', 'int foo Some text'); |
|
104 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
105 | + |
|
106 | + $parameter = $operation->handleCommand('query', 'string foo Other text'); |
|
107 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Parameter', $parameter); |
|
108 | + |
|
109 | + $response = $operation->handleCommand('response', '200'); |
|
110 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Response', $response); |
|
111 | + |
|
112 | + $this->assertSame(array( |
|
113 | + 'parameters' => array( |
|
114 | + array( |
|
115 | + 'name' => 'foo', |
|
116 | + 'in' => 'query', |
|
117 | + 'description' => 'Other text', |
|
118 | + 'required' => true, |
|
119 | + 'type' => 'string', |
|
120 | + ), |
|
121 | + ), |
|
122 | + 'responses' => array( |
|
123 | + 200 => array( |
|
124 | + 'description' => 'OK', |
|
125 | + ), |
|
126 | + ), |
|
127 | + ), $operation->toArray()); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | class Issue0012Test extends SwaggerGen_TestCase |
8 | 8 | { |
9 | 9 | |
10 | - public function testIssue() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
10 | + public function testIssue() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | api Test |
15 | 15 | endpoint /test |
16 | 16 | method GET something |
17 | 17 | response 200 object(modifications:array(ModificationHistory),users:array(User)) |
18 | 18 | ')); |
19 | 19 | |
20 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
21 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
22 | - . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
23 | - . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
24 | - . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
25 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
26 | - } |
|
20 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
21 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
22 | + . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["modifications","users"]' |
|
23 | + . ',"properties":{"modifications":{"type":"array","items":{"$ref":"#\/definitions\/ModificationHistory"}}' |
|
24 | + . ',"users":{"type":"array","items":{"$ref":"#\/definitions\/User"}}}}}}}}}' |
|
25 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | } |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class Issue0002Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Tests issue 2; @rest/require should create object on each item |
|
8 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
9 | - */ |
|
10 | - public function testRequireMustBeObject() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * Tests issue 2; @rest/require should create object on each item |
|
8 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/2 |
|
9 | + */ |
|
10 | + public function testRequireMustBeObject() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | security api_key apikey X-Api-Authentication header |
15 | 15 | require api_key |
16 | 16 | api Test |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | response 202 |
21 | 21 | ')); |
22 | 22 | |
23 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
25 | - . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
26 | - . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
27 | - } |
|
23 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
24 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
25 | + . ',"security":[{"api_key":[]}]}}},"securityDefinitions":{"api_key":{"type":"apiKey","name":"X-Api-Authentication","in":"header"}}' |
|
26 | + . ',"security":[{"api_key":[]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
27 | + } |
|
28 | 28 | |
29 | - public function testRequireAsObjectWithScopes() |
|
30 | - { |
|
31 | - $object = new \SwaggerGen\SwaggerGen(); |
|
32 | - $array = $object->getSwagger(array(' |
|
29 | + public function testRequireAsObjectWithScopes() |
|
30 | + { |
|
31 | + $object = new \SwaggerGen\SwaggerGen(); |
|
32 | + $array = $object->getSwagger(array(' |
|
33 | 33 | security oauth oauth2 implicit http://www.test |
34 | 34 | require oauth user:name |
35 | 35 | api Test |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | response 202 |
40 | 40 | ')); |
41 | 41 | |
42 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
43 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
44 | - . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
45 | - . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
46 | - } |
|
42 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
43 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"202":{"description":"Accepted"}}' |
|
44 | + . ',"security":[{"oauth":["user:name"]}]}}},"securityDefinitions":{"oauth":{"type":"oauth2","flow":"implicit","authorizationUrl":"http:\/\/www.test"}}' |
|
45 | + . ',"security":[{"oauth":["user:name"]}],"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class Issue0015Test extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Tests issue 15; Allow enumeration of property values |
|
8 | - * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
9 | - */ |
|
10 | - public function testPropertyEnumeration() |
|
11 | - { |
|
12 | - $object = new \SwaggerGen\SwaggerGen(); |
|
13 | - $array = $object->getSwagger(array(' |
|
6 | + /** |
|
7 | + * Tests issue 15; Allow enumeration of property values |
|
8 | + * https://github.com/vanderlee/PHPSwaggerGen/issues/15 |
|
9 | + */ |
|
10 | + public function testPropertyEnumeration() |
|
11 | + { |
|
12 | + $object = new \SwaggerGen\SwaggerGen(); |
|
13 | + $array = $object->getSwagger(array(' |
|
14 | 14 | api Test |
15 | 15 | definition ClassName |
16 | 16 | title ClassName |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | response 204 |
24 | 24 | ')); |
25 | 25 | |
26 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
27 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something","responses":{"204":{"description":"No Content"}}}}}' |
|
28 | - . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
29 | - . ',"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":{"204":{"description":"No Content"}}}}}' |
|
28 | + . ',"definitions":{"ClassName":{"type":"object","required":["type","meaningOfLifeTheUniverseAndEverything"],"properties":{"type":{"type":"string","enum":["ClassName"]},"meaningOfLifeTheUniverseAndEverything":{"type":"integer","format":"int32","enum":[42]}},"title":"ClassName"}}' |
|
29 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -3,515 +3,515 @@ |
||
3 | 3 | class ParserTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Test if the statement matches the expected values |
|
8 | - * @param \SwaggerGen\Statement $statement |
|
9 | - * @param string $command |
|
10 | - * @param string $data |
|
11 | - */ |
|
12 | - private function assertStatement($statement, $command, $data = '') |
|
13 | - { |
|
14 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
15 | - $this->assertSame($command, $statement->getCommand()); |
|
16 | - $this->assertSame($data, $statement->getData()); |
|
17 | - } |
|
18 | - |
|
19 | - /** |
|
20 | - * Test if the statement matches the expected values |
|
21 | - * @param array[] $expected |
|
22 | - * @param SwaggerGen\Parser\Php\Statement[] $statements |
|
23 | - */ |
|
24 | - private function assertStatements(array $expected, array $statements) |
|
25 | - { |
|
26 | - $this->assertCount(count($expected), $statements, join("\n", $statements)); |
|
27 | - foreach ($expected as $index => $command) { |
|
28 | - $statement = $statements[$index]; |
|
29 | - $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
30 | - $this->assertSame($command[0], $statement->getCommand()); |
|
31 | - $this->assertSame($command[1], $statement->getData()); |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
37 | - */ |
|
38 | - public function testConstructor_Empty() |
|
39 | - { |
|
40 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
41 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
46 | - */ |
|
47 | - public function testConstructor_Dirs() |
|
48 | - { |
|
49 | - $this->markTestIncomplete('Not yet implemented.'); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @covers \SwaggerGen\Parser\Php\Parser::addDirs |
|
54 | - */ |
|
55 | - public function testAddDirs() |
|
56 | - { |
|
57 | - $this->markTestIncomplete('Not yet implemented.'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Test all open-curlies are (ac-)counted for in functions |
|
62 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
63 | - */ |
|
64 | - public function testParse_CurlyBraceFunction() |
|
65 | - { |
|
66 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
67 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
68 | - |
|
69 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CurlyBraceFunction.php'); |
|
70 | - $this->assertCount(6, $statements); |
|
71 | - $this->assertStatement($statements[0], 'title', 'CurlyBraceFunction'); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
76 | - */ |
|
77 | - public function testParse_NoMethods() |
|
78 | - { |
|
79 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
80 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
81 | - |
|
82 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_NoMethods.php'); |
|
83 | - |
|
84 | - $this->assertCount(2, $statements); |
|
85 | - |
|
86 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
87 | - $this->assertStatement($statements[1], 'version', '2'); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
92 | - */ |
|
93 | - public function testParse_WithMethod() |
|
94 | - { |
|
95 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
96 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
97 | - |
|
98 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_WithMethod.php'); |
|
99 | - |
|
100 | - $this->assertCount(4, $statements); |
|
101 | - |
|
102 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
103 | - $this->assertStatement($statements[1], 'version', '2'); |
|
104 | - $this->assertStatement($statements[2], 'description', 'some description'); |
|
105 | - $this->assertStatement($statements[3], 'method', 'get something'); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
110 | - */ |
|
111 | - public function testParse_LineContinuation() |
|
112 | - { |
|
113 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
114 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
115 | - |
|
116 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_LineContinuation.php'); |
|
117 | - |
|
118 | - $this->assertCount(2, $statements); |
|
119 | - |
|
120 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
121 | - $this->assertStatement($statements[1], 'description', 'About this strange little class'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
126 | - */ |
|
127 | - public function testParse_InClass() |
|
128 | - { |
|
129 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
130 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
131 | - |
|
132 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InClass.php'); |
|
133 | - |
|
134 | - $this->assertCount(3, $statements); |
|
135 | - |
|
136 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
137 | - $this->assertStatement($statements[1], 'description', 'Some description'); |
|
138 | - $this->assertStatement($statements[2], 'license', 'mit'); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
143 | - */ |
|
144 | - public function testParse_CommentsTypes() |
|
145 | - { |
|
146 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
147 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
148 | - |
|
149 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CommentsTypes.php'); |
|
150 | - |
|
151 | - $this->assertCount(3, $statements); |
|
152 | - |
|
153 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
154 | - $this->assertStatement($statements[1], 'version', '2'); |
|
155 | - $this->assertStatement($statements[2], 'license', 'mit'); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
160 | - */ |
|
161 | - public function testParse_MethodNonDoc() |
|
162 | - { |
|
163 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
164 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
165 | - |
|
166 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_MethodNonDoc.php'); |
|
167 | - |
|
168 | - $this->assertCount(3, $statements); |
|
169 | - |
|
170 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
171 | - $this->assertStatement($statements[1], 'version', '2'); |
|
172 | - $this->assertStatement($statements[2], 'method', 'get something'); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
177 | - */ |
|
178 | - public function testParse_InMethod() |
|
179 | - { |
|
180 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
181 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
182 | - |
|
183 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InMethod.php'); |
|
184 | - |
|
185 | - $this->assertCount(4, $statements); |
|
186 | - |
|
187 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
188 | - $this->assertStatement($statements[1], 'version', '2'); |
|
189 | - $this->assertStatement($statements[2], 'description', 'some description'); |
|
190 | - $this->assertStatement($statements[3], 'method', 'get something'); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
195 | - */ |
|
196 | - public function testParse_AfterClass() |
|
197 | - { |
|
198 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
199 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
200 | - |
|
201 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_AfterClass.php'); |
|
202 | - |
|
203 | - $this->assertCount(2, $statements); |
|
204 | - |
|
205 | - $this->assertStatement($statements[0], 'license', 'mit'); |
|
206 | - $this->assertStatement($statements[1], 'title', 'Some words'); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
211 | - */ |
|
212 | - public function testParse_Prefix() |
|
213 | - { |
|
214 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
215 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
216 | - |
|
217 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Prefix.php'); |
|
218 | - |
|
219 | - $this->assertCount(1, $statements); |
|
220 | - |
|
221 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | - */ |
|
227 | - public function testParse_PropertyReadOnly() |
|
228 | - { |
|
229 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | - |
|
232 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | - |
|
234 | - $this->assertCount(4, $statements); |
|
235 | - |
|
236 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | - $this->assertStatement($statements[1], 'version', '2'); |
|
238 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | - $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | - */ |
|
245 | - public function testParse_PropertyOptional() |
|
246 | - { |
|
247 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | - |
|
250 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | - |
|
252 | - $this->assertCount(4, $statements); |
|
253 | - |
|
254 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | - $this->assertStatement($statements[1], 'version', '2'); |
|
256 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | - $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
262 | - */ |
|
263 | - public function testParse_Minimal() |
|
264 | - { |
|
265 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
266 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
267 | - |
|
268 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Minimal.php'); |
|
269 | - |
|
270 | - $this->assertCount(4, $statements); |
|
271 | - |
|
272 | - $this->assertStatement($statements[0], 'title', 'Minimal'); |
|
273 | - $this->assertStatement($statements[1], 'api', 'MyApi Example'); |
|
274 | - $this->assertStatement($statements[2], 'endpoint', '/endpoint'); |
|
275 | - $this->assertStatement($statements[3], 'method', 'GET Something'); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Tests FunctionName |
|
280 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
281 | - */ |
|
282 | - public function testParse_SeeFunction() |
|
283 | - { |
|
284 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
285 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
286 | - |
|
287 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeFunction.php'); |
|
288 | - |
|
289 | - $this->assertStatements(array( |
|
290 | - array('api', 'MyApi Example'), |
|
291 | - array('endpoint', '/endpoint'), |
|
292 | - array('method', 'GET Something'), |
|
293 | - array('error', '400'), |
|
294 | - ), $statements); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Tests $this->MethodName |
|
299 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
300 | - */ |
|
301 | - public function testParse_SeeThisMethod() |
|
302 | - { |
|
303 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
304 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
305 | - |
|
306 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeThisMethod.php'); |
|
307 | - |
|
308 | - $this->assertStatements(array( |
|
309 | - array('api', 'MyApi Example'), |
|
310 | - array('endpoint', '/endpoint'), |
|
311 | - array('method', 'GET Something'), |
|
312 | - array('error', '400'), |
|
313 | - ), $statements); |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Tests Class->MethodName |
|
318 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
319 | - */ |
|
320 | - public function testParse_SeeObjectMethod() |
|
321 | - { |
|
322 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
323 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
324 | - |
|
325 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeObjectMethod.php'); |
|
326 | - |
|
327 | - $this->assertStatements(array( |
|
328 | - array('api', 'MyApi Example'), |
|
329 | - array('endpoint', '/endpoint'), |
|
330 | - array('method', 'GET Something'), |
|
331 | - array('error', '400'), |
|
332 | - ), $statements); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Tests self::MethodName |
|
337 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
338 | - */ |
|
339 | - public function testParse_SeeSelfMethod() |
|
340 | - { |
|
341 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
342 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
343 | - |
|
344 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeSelfMethod.php'); |
|
345 | - |
|
346 | - $this->assertStatements(array( |
|
347 | - array('api', 'MyApi Example'), |
|
348 | - array('endpoint', '/endpoint'), |
|
349 | - array('method', 'GET Something'), |
|
350 | - array('error', '400'), |
|
351 | - ), $statements); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Tests Class::MethodName |
|
356 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
357 | - */ |
|
358 | - public function testParse_SeeClassMethod() |
|
359 | - { |
|
360 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
361 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
362 | - |
|
363 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeClassMethod.php'); |
|
364 | - |
|
365 | - $this->assertStatements(array( |
|
366 | - array('api', 'MyApi Example'), |
|
367 | - array('endpoint', '/endpoint'), |
|
368 | - array('method', 'GET Something'), |
|
369 | - array('error', '400'), |
|
370 | - ), $statements); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Tests static::MethodName |
|
375 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
376 | - */ |
|
377 | - public function testParse_StaticMethod() |
|
378 | - { |
|
379 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
380 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
381 | - |
|
382 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_StaticMethod.php'); |
|
383 | - |
|
384 | - $this->assertStatements(array( |
|
385 | - array('api', 'MyApi Example'), |
|
386 | - array('endpoint', '/endpoint'), |
|
387 | - array('method', 'GET Something'), |
|
388 | - array('error', '400'), |
|
389 | - ), $statements); |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Tests $this->MethodName with inheritance |
|
394 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
395 | - */ |
|
396 | - public function testParse_SeeInheritedThisMethod() |
|
397 | - { |
|
398 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
399 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
400 | - |
|
401 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedThisMethod.php'); |
|
402 | - |
|
403 | - $this->assertStatements(array( |
|
404 | - array('api', 'MyApi Example'), |
|
405 | - array('endpoint', '/endpoint'), |
|
406 | - array('method', 'GET Something'), |
|
407 | - array('error', '400'), |
|
408 | - ), $statements); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * Tests Class->MethodName with inheritance |
|
413 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
414 | - */ |
|
415 | - public function testParse_SeeInheritedObjectMethod() |
|
416 | - { |
|
417 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
418 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
419 | - |
|
420 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedObjectMethod.php'); |
|
421 | - |
|
422 | - $this->assertStatements(array( |
|
423 | - array('api', 'MyApi Example'), |
|
424 | - array('endpoint', '/endpoint'), |
|
425 | - array('method', 'GET Something'), |
|
426 | - array('error', '400'), |
|
427 | - ), $statements); |
|
428 | - } |
|
429 | - |
|
430 | - /** |
|
431 | - * Tests Autoloading other class when referenced |
|
432 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
433 | - */ |
|
434 | - public function testParse_Autoload_Parse() |
|
435 | - { |
|
436 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
437 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
438 | - |
|
439 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php', array( |
|
440 | - __DIR__ . '/ParserTest', |
|
441 | - )); |
|
442 | - |
|
443 | - $this->assertStatements(array( |
|
444 | - array('api', 'MyApi Example'), |
|
445 | - array('endpoint', '/endpoint'), |
|
446 | - array('method', 'GET Something'), |
|
447 | - array('error', '400'), |
|
448 | - ), $statements); |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Tests Autoloading other class when referenced |
|
453 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
454 | - */ |
|
455 | - public function testParse_Autoload_Construct() |
|
456 | - { |
|
457 | - $object = new \SwaggerGen\Parser\Php\Parser(array( |
|
458 | - __DIR__ . '/ParserTest', |
|
459 | - )); |
|
460 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
461 | - |
|
462 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
463 | - |
|
464 | - $this->assertStatements(array( |
|
465 | - array('api', 'MyApi Example'), |
|
466 | - array('endpoint', '/endpoint'), |
|
467 | - array('method', 'GET Something'), |
|
468 | - array('error', '400'), |
|
469 | - ), $statements); |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Tests Autoloading other class when referenced |
|
474 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
475 | - */ |
|
476 | - public function testParse_Autoload_AddDirs() |
|
477 | - { |
|
478 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
479 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
480 | - |
|
481 | - $object->addDirs(array( |
|
482 | - __DIR__ . '/ParserTest', |
|
483 | - )); |
|
484 | - |
|
485 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
486 | - |
|
487 | - $this->assertStatements(array( |
|
488 | - array('api', 'MyApi Example'), |
|
489 | - array('endpoint', '/endpoint'), |
|
490 | - array('method', 'GET Something'), |
|
491 | - array('error', '400'), |
|
492 | - ), $statements); |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
497 | - */ |
|
498 | - public function testParse_XTag() |
|
499 | - { |
|
500 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
501 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
502 | - |
|
503 | - $object->addDirs(array( |
|
504 | - __DIR__ . '/ParserTest', |
|
505 | - )); |
|
506 | - |
|
507 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_XTag.php'); |
|
508 | - |
|
509 | - $this->assertStatements(array( |
|
510 | - array('api', 'MyApi Example'), |
|
511 | - array('endpoint', '/endpoint'), |
|
512 | - array('x-something', 'else'), |
|
513 | - array('method', 'GET Something'), |
|
514 | - ), $statements); |
|
515 | - } |
|
6 | + /** |
|
7 | + * Test if the statement matches the expected values |
|
8 | + * @param \SwaggerGen\Statement $statement |
|
9 | + * @param string $command |
|
10 | + * @param string $data |
|
11 | + */ |
|
12 | + private function assertStatement($statement, $command, $data = '') |
|
13 | + { |
|
14 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
15 | + $this->assertSame($command, $statement->getCommand()); |
|
16 | + $this->assertSame($data, $statement->getData()); |
|
17 | + } |
|
18 | + |
|
19 | + /** |
|
20 | + * Test if the statement matches the expected values |
|
21 | + * @param array[] $expected |
|
22 | + * @param SwaggerGen\Parser\Php\Statement[] $statements |
|
23 | + */ |
|
24 | + private function assertStatements(array $expected, array $statements) |
|
25 | + { |
|
26 | + $this->assertCount(count($expected), $statements, join("\n", $statements)); |
|
27 | + foreach ($expected as $index => $command) { |
|
28 | + $statement = $statements[$index]; |
|
29 | + $this->assertInstanceOf('\SwaggerGen\Statement', $statement); |
|
30 | + $this->assertSame($command[0], $statement->getCommand()); |
|
31 | + $this->assertSame($command[1], $statement->getData()); |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
37 | + */ |
|
38 | + public function testConstructor_Empty() |
|
39 | + { |
|
40 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
41 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @covers \SwaggerGen\Parser\Php\Parser::__construct |
|
46 | + */ |
|
47 | + public function testConstructor_Dirs() |
|
48 | + { |
|
49 | + $this->markTestIncomplete('Not yet implemented.'); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @covers \SwaggerGen\Parser\Php\Parser::addDirs |
|
54 | + */ |
|
55 | + public function testAddDirs() |
|
56 | + { |
|
57 | + $this->markTestIncomplete('Not yet implemented.'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Test all open-curlies are (ac-)counted for in functions |
|
62 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
63 | + */ |
|
64 | + public function testParse_CurlyBraceFunction() |
|
65 | + { |
|
66 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
67 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
68 | + |
|
69 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CurlyBraceFunction.php'); |
|
70 | + $this->assertCount(6, $statements); |
|
71 | + $this->assertStatement($statements[0], 'title', 'CurlyBraceFunction'); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
76 | + */ |
|
77 | + public function testParse_NoMethods() |
|
78 | + { |
|
79 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
80 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
81 | + |
|
82 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_NoMethods.php'); |
|
83 | + |
|
84 | + $this->assertCount(2, $statements); |
|
85 | + |
|
86 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
87 | + $this->assertStatement($statements[1], 'version', '2'); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
92 | + */ |
|
93 | + public function testParse_WithMethod() |
|
94 | + { |
|
95 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
96 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
97 | + |
|
98 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_WithMethod.php'); |
|
99 | + |
|
100 | + $this->assertCount(4, $statements); |
|
101 | + |
|
102 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
103 | + $this->assertStatement($statements[1], 'version', '2'); |
|
104 | + $this->assertStatement($statements[2], 'description', 'some description'); |
|
105 | + $this->assertStatement($statements[3], 'method', 'get something'); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
110 | + */ |
|
111 | + public function testParse_LineContinuation() |
|
112 | + { |
|
113 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
114 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
115 | + |
|
116 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_LineContinuation.php'); |
|
117 | + |
|
118 | + $this->assertCount(2, $statements); |
|
119 | + |
|
120 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
121 | + $this->assertStatement($statements[1], 'description', 'About this strange little class'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
126 | + */ |
|
127 | + public function testParse_InClass() |
|
128 | + { |
|
129 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
130 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
131 | + |
|
132 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InClass.php'); |
|
133 | + |
|
134 | + $this->assertCount(3, $statements); |
|
135 | + |
|
136 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
137 | + $this->assertStatement($statements[1], 'description', 'Some description'); |
|
138 | + $this->assertStatement($statements[2], 'license', 'mit'); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
143 | + */ |
|
144 | + public function testParse_CommentsTypes() |
|
145 | + { |
|
146 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
147 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
148 | + |
|
149 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_CommentsTypes.php'); |
|
150 | + |
|
151 | + $this->assertCount(3, $statements); |
|
152 | + |
|
153 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
154 | + $this->assertStatement($statements[1], 'version', '2'); |
|
155 | + $this->assertStatement($statements[2], 'license', 'mit'); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
160 | + */ |
|
161 | + public function testParse_MethodNonDoc() |
|
162 | + { |
|
163 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
164 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
165 | + |
|
166 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_MethodNonDoc.php'); |
|
167 | + |
|
168 | + $this->assertCount(3, $statements); |
|
169 | + |
|
170 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
171 | + $this->assertStatement($statements[1], 'version', '2'); |
|
172 | + $this->assertStatement($statements[2], 'method', 'get something'); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
177 | + */ |
|
178 | + public function testParse_InMethod() |
|
179 | + { |
|
180 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
181 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
182 | + |
|
183 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_InMethod.php'); |
|
184 | + |
|
185 | + $this->assertCount(4, $statements); |
|
186 | + |
|
187 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
188 | + $this->assertStatement($statements[1], 'version', '2'); |
|
189 | + $this->assertStatement($statements[2], 'description', 'some description'); |
|
190 | + $this->assertStatement($statements[3], 'method', 'get something'); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
195 | + */ |
|
196 | + public function testParse_AfterClass() |
|
197 | + { |
|
198 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
199 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
200 | + |
|
201 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_AfterClass.php'); |
|
202 | + |
|
203 | + $this->assertCount(2, $statements); |
|
204 | + |
|
205 | + $this->assertStatement($statements[0], 'license', 'mit'); |
|
206 | + $this->assertStatement($statements[1], 'title', 'Some words'); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
211 | + */ |
|
212 | + public function testParse_Prefix() |
|
213 | + { |
|
214 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
215 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
216 | + |
|
217 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Prefix.php'); |
|
218 | + |
|
219 | + $this->assertCount(1, $statements); |
|
220 | + |
|
221 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | + */ |
|
227 | + public function testParse_PropertyReadOnly() |
|
228 | + { |
|
229 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | + |
|
232 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | + |
|
234 | + $this->assertCount(4, $statements); |
|
235 | + |
|
236 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | + $this->assertStatement($statements[1], 'version', '2'); |
|
238 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | + $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | + */ |
|
245 | + public function testParse_PropertyOptional() |
|
246 | + { |
|
247 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | + |
|
250 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | + |
|
252 | + $this->assertCount(4, $statements); |
|
253 | + |
|
254 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | + $this->assertStatement($statements[1], 'version', '2'); |
|
256 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | + $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
262 | + */ |
|
263 | + public function testParse_Minimal() |
|
264 | + { |
|
265 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
266 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
267 | + |
|
268 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Minimal.php'); |
|
269 | + |
|
270 | + $this->assertCount(4, $statements); |
|
271 | + |
|
272 | + $this->assertStatement($statements[0], 'title', 'Minimal'); |
|
273 | + $this->assertStatement($statements[1], 'api', 'MyApi Example'); |
|
274 | + $this->assertStatement($statements[2], 'endpoint', '/endpoint'); |
|
275 | + $this->assertStatement($statements[3], 'method', 'GET Something'); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Tests FunctionName |
|
280 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
281 | + */ |
|
282 | + public function testParse_SeeFunction() |
|
283 | + { |
|
284 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
285 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
286 | + |
|
287 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeFunction.php'); |
|
288 | + |
|
289 | + $this->assertStatements(array( |
|
290 | + array('api', 'MyApi Example'), |
|
291 | + array('endpoint', '/endpoint'), |
|
292 | + array('method', 'GET Something'), |
|
293 | + array('error', '400'), |
|
294 | + ), $statements); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Tests $this->MethodName |
|
299 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
300 | + */ |
|
301 | + public function testParse_SeeThisMethod() |
|
302 | + { |
|
303 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
304 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
305 | + |
|
306 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeThisMethod.php'); |
|
307 | + |
|
308 | + $this->assertStatements(array( |
|
309 | + array('api', 'MyApi Example'), |
|
310 | + array('endpoint', '/endpoint'), |
|
311 | + array('method', 'GET Something'), |
|
312 | + array('error', '400'), |
|
313 | + ), $statements); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Tests Class->MethodName |
|
318 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
319 | + */ |
|
320 | + public function testParse_SeeObjectMethod() |
|
321 | + { |
|
322 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
323 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
324 | + |
|
325 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeObjectMethod.php'); |
|
326 | + |
|
327 | + $this->assertStatements(array( |
|
328 | + array('api', 'MyApi Example'), |
|
329 | + array('endpoint', '/endpoint'), |
|
330 | + array('method', 'GET Something'), |
|
331 | + array('error', '400'), |
|
332 | + ), $statements); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Tests self::MethodName |
|
337 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
338 | + */ |
|
339 | + public function testParse_SeeSelfMethod() |
|
340 | + { |
|
341 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
342 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
343 | + |
|
344 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeSelfMethod.php'); |
|
345 | + |
|
346 | + $this->assertStatements(array( |
|
347 | + array('api', 'MyApi Example'), |
|
348 | + array('endpoint', '/endpoint'), |
|
349 | + array('method', 'GET Something'), |
|
350 | + array('error', '400'), |
|
351 | + ), $statements); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Tests Class::MethodName |
|
356 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
357 | + */ |
|
358 | + public function testParse_SeeClassMethod() |
|
359 | + { |
|
360 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
361 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
362 | + |
|
363 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeClassMethod.php'); |
|
364 | + |
|
365 | + $this->assertStatements(array( |
|
366 | + array('api', 'MyApi Example'), |
|
367 | + array('endpoint', '/endpoint'), |
|
368 | + array('method', 'GET Something'), |
|
369 | + array('error', '400'), |
|
370 | + ), $statements); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Tests static::MethodName |
|
375 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
376 | + */ |
|
377 | + public function testParse_StaticMethod() |
|
378 | + { |
|
379 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
380 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
381 | + |
|
382 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_StaticMethod.php'); |
|
383 | + |
|
384 | + $this->assertStatements(array( |
|
385 | + array('api', 'MyApi Example'), |
|
386 | + array('endpoint', '/endpoint'), |
|
387 | + array('method', 'GET Something'), |
|
388 | + array('error', '400'), |
|
389 | + ), $statements); |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Tests $this->MethodName with inheritance |
|
394 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
395 | + */ |
|
396 | + public function testParse_SeeInheritedThisMethod() |
|
397 | + { |
|
398 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
399 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
400 | + |
|
401 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedThisMethod.php'); |
|
402 | + |
|
403 | + $this->assertStatements(array( |
|
404 | + array('api', 'MyApi Example'), |
|
405 | + array('endpoint', '/endpoint'), |
|
406 | + array('method', 'GET Something'), |
|
407 | + array('error', '400'), |
|
408 | + ), $statements); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * Tests Class->MethodName with inheritance |
|
413 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
414 | + */ |
|
415 | + public function testParse_SeeInheritedObjectMethod() |
|
416 | + { |
|
417 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
418 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
419 | + |
|
420 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_SeeInheritedObjectMethod.php'); |
|
421 | + |
|
422 | + $this->assertStatements(array( |
|
423 | + array('api', 'MyApi Example'), |
|
424 | + array('endpoint', '/endpoint'), |
|
425 | + array('method', 'GET Something'), |
|
426 | + array('error', '400'), |
|
427 | + ), $statements); |
|
428 | + } |
|
429 | + |
|
430 | + /** |
|
431 | + * Tests Autoloading other class when referenced |
|
432 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
433 | + */ |
|
434 | + public function testParse_Autoload_Parse() |
|
435 | + { |
|
436 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
437 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
438 | + |
|
439 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php', array( |
|
440 | + __DIR__ . '/ParserTest', |
|
441 | + )); |
|
442 | + |
|
443 | + $this->assertStatements(array( |
|
444 | + array('api', 'MyApi Example'), |
|
445 | + array('endpoint', '/endpoint'), |
|
446 | + array('method', 'GET Something'), |
|
447 | + array('error', '400'), |
|
448 | + ), $statements); |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Tests Autoloading other class when referenced |
|
453 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
454 | + */ |
|
455 | + public function testParse_Autoload_Construct() |
|
456 | + { |
|
457 | + $object = new \SwaggerGen\Parser\Php\Parser(array( |
|
458 | + __DIR__ . '/ParserTest', |
|
459 | + )); |
|
460 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
461 | + |
|
462 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
463 | + |
|
464 | + $this->assertStatements(array( |
|
465 | + array('api', 'MyApi Example'), |
|
466 | + array('endpoint', '/endpoint'), |
|
467 | + array('method', 'GET Something'), |
|
468 | + array('error', '400'), |
|
469 | + ), $statements); |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Tests Autoloading other class when referenced |
|
474 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
475 | + */ |
|
476 | + public function testParse_Autoload_AddDirs() |
|
477 | + { |
|
478 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
479 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
480 | + |
|
481 | + $object->addDirs(array( |
|
482 | + __DIR__ . '/ParserTest', |
|
483 | + )); |
|
484 | + |
|
485 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_Autoload.php'); |
|
486 | + |
|
487 | + $this->assertStatements(array( |
|
488 | + array('api', 'MyApi Example'), |
|
489 | + array('endpoint', '/endpoint'), |
|
490 | + array('method', 'GET Something'), |
|
491 | + array('error', '400'), |
|
492 | + ), $statements); |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
497 | + */ |
|
498 | + public function testParse_XTag() |
|
499 | + { |
|
500 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
501 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
502 | + |
|
503 | + $object->addDirs(array( |
|
504 | + __DIR__ . '/ParserTest', |
|
505 | + )); |
|
506 | + |
|
507 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_XTag.php'); |
|
508 | + |
|
509 | + $this->assertStatements(array( |
|
510 | + array('api', 'MyApi Example'), |
|
511 | + array('endpoint', '/endpoint'), |
|
512 | + array('x-something', 'else'), |
|
513 | + array('method', 'GET Something'), |
|
514 | + ), $statements); |
|
515 | + } |
|
516 | 516 | |
517 | 517 | } |
@@ -3,42 +3,42 @@ discard block |
||
3 | 3 | class PreprocessorTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
8 | - */ |
|
9 | - public function testConstructor_Empty() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
12 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
13 | - } |
|
14 | - |
|
15 | - /** |
|
16 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
17 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::getPrefix |
|
18 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::setPrefix |
|
19 | - */ |
|
20 | - public function testConstructor_Prefix() |
|
21 | - { |
|
22 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
23 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
24 | - $this->assertEquals('rest', $object->getPrefix()); |
|
25 | - |
|
26 | - $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
27 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
28 | - $this->assertEquals('foo', $object->getPrefix()); |
|
29 | - |
|
30 | - $object->setPrefix('bar'); |
|
31 | - $this->assertEquals('bar', $object->getPrefix()); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
36 | - */ |
|
37 | - public function testPreprocess_Ifdef_NotDefined() |
|
38 | - { |
|
39 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
40 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
41 | - $out = $object->preprocess('<?php |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
8 | + */ |
|
9 | + public function testConstructor_Empty() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
12 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
13 | + } |
|
14 | + |
|
15 | + /** |
|
16 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::__construct |
|
17 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::getPrefix |
|
18 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::setPrefix |
|
19 | + */ |
|
20 | + public function testConstructor_Prefix() |
|
21 | + { |
|
22 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
23 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
24 | + $this->assertEquals('rest', $object->getPrefix()); |
|
25 | + |
|
26 | + $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
27 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
28 | + $this->assertEquals('foo', $object->getPrefix()); |
|
29 | + |
|
30 | + $object->setPrefix('bar'); |
|
31 | + $this->assertEquals('bar', $object->getPrefix()); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
36 | + */ |
|
37 | + public function testPreprocess_Ifdef_NotDefined() |
|
38 | + { |
|
39 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
40 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
41 | + $out = $object->preprocess('<?php |
|
42 | 42 | /** |
43 | 43 | * @rest\ifdef test |
44 | 44 | * @rest\whatever |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | */ |
47 | 47 | '); |
48 | 48 | |
49 | - $this->assertEquals('<?php |
|
49 | + $this->assertEquals('<?php |
|
50 | 50 | /** |
51 | 51 | * @!rest\ifdef test |
52 | 52 | * @!rest\whatever |
53 | 53 | * @!rest\endif |
54 | 54 | */ |
55 | 55 | ', $out); |
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
60 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
61 | - */ |
|
62 | - public function testPreprocess_Ifdef_Defined() |
|
63 | - { |
|
64 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
65 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
66 | - $object->define('test'); |
|
67 | - $out = $object->preprocess('<?php |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
60 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
61 | + */ |
|
62 | + public function testPreprocess_Ifdef_Defined() |
|
63 | + { |
|
64 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
65 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
66 | + $object->define('test'); |
|
67 | + $out = $object->preprocess('<?php |
|
68 | 68 | /** |
69 | 69 | * @rest\ifdef test |
70 | 70 | * @rest\whatever |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | */ |
73 | 73 | '); |
74 | 74 | |
75 | - $this->assertEquals('<?php |
|
75 | + $this->assertEquals('<?php |
|
76 | 76 | /** |
77 | 77 | * @!rest\ifdef test |
78 | 78 | * @rest\whatever |
79 | 79 | * @!rest\endif |
80 | 80 | */ |
81 | 81 | ', $out); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
86 | - */ |
|
87 | - public function testPreprocess_Ifndef_NotDefined() |
|
88 | - { |
|
89 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
90 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
91 | - $out = $object->preprocess('<?php |
|
84 | + /** |
|
85 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
86 | + */ |
|
87 | + public function testPreprocess_Ifndef_NotDefined() |
|
88 | + { |
|
89 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
90 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
91 | + $out = $object->preprocess('<?php |
|
92 | 92 | /** |
93 | 93 | * @rest\ifndef test |
94 | 94 | * @rest\whatever |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | '); |
98 | 98 | |
99 | - $this->assertEquals('<?php |
|
99 | + $this->assertEquals('<?php |
|
100 | 100 | /** |
101 | 101 | * @!rest\ifndef test |
102 | 102 | * @rest\whatever |
103 | 103 | * @!rest\endif |
104 | 104 | */ |
105 | 105 | ', $out); |
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
110 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
111 | - */ |
|
112 | - public function testPreprocess_Ifndef_Defined() |
|
113 | - { |
|
114 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
115 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
116 | - $object->define('test'); |
|
117 | - $out = $object->preprocess('<?php |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
110 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
111 | + */ |
|
112 | + public function testPreprocess_Ifndef_Defined() |
|
113 | + { |
|
114 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
115 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
116 | + $object->define('test'); |
|
117 | + $out = $object->preprocess('<?php |
|
118 | 118 | /** |
119 | 119 | * @rest\ifndef test |
120 | 120 | * @rest\whatever |
@@ -122,23 +122,23 @@ discard block |
||
122 | 122 | */ |
123 | 123 | '); |
124 | 124 | |
125 | - $this->assertEquals('<?php |
|
125 | + $this->assertEquals('<?php |
|
126 | 126 | /** |
127 | 127 | * @!rest\ifndef test |
128 | 128 | * @!rest\whatever |
129 | 129 | * @!rest\endif |
130 | 130 | */ |
131 | 131 | ', $out); |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
136 | - */ |
|
137 | - public function testPreprocess_Define() |
|
138 | - { |
|
139 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
140 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
141 | - $out = $object->preprocess('<?php |
|
134 | + /** |
|
135 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
136 | + */ |
|
137 | + public function testPreprocess_Define() |
|
138 | + { |
|
139 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
140 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
141 | + $out = $object->preprocess('<?php |
|
142 | 142 | /** |
143 | 143 | * @rest\define test |
144 | 144 | * @rest\ifndef test |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | '); |
149 | 149 | |
150 | - $this->assertEquals('<?php |
|
150 | + $this->assertEquals('<?php |
|
151 | 151 | /** |
152 | 152 | * @!rest\define test |
153 | 153 | * @!rest\ifndef test |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @!rest\endif |
156 | 156 | */ |
157 | 157 | ', $out); |
158 | - } |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
162 | - */ |
|
163 | - public function testPreprocess_Undef() |
|
164 | - { |
|
165 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
166 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
167 | - $out = $object->preprocess('<?php |
|
160 | + /** |
|
161 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
162 | + */ |
|
163 | + public function testPreprocess_Undef() |
|
164 | + { |
|
165 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
166 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
167 | + $out = $object->preprocess('<?php |
|
168 | 168 | /** |
169 | 169 | * @rest\define test |
170 | 170 | * @rest\undef test |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | '); |
176 | 176 | |
177 | - $this->assertEquals('<?php |
|
177 | + $this->assertEquals('<?php |
|
178 | 178 | /** |
179 | 179 | * @!rest\define test |
180 | 180 | * @!rest\undef test |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * @!rest\endif |
184 | 184 | */ |
185 | 185 | ', $out); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
190 | - */ |
|
191 | - public function testPreprocess_If_NotDefined() |
|
192 | - { |
|
193 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
194 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
195 | - $out = $object->preprocess('<?php |
|
188 | + /** |
|
189 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
190 | + */ |
|
191 | + public function testPreprocess_If_NotDefined() |
|
192 | + { |
|
193 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
194 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
195 | + $out = $object->preprocess('<?php |
|
196 | 196 | /** |
197 | 197 | * @rest\if test red |
198 | 198 | * @rest\whatever |
@@ -200,25 +200,25 @@ discard block |
||
200 | 200 | */ |
201 | 201 | '); |
202 | 202 | |
203 | - $this->assertEquals('<?php |
|
203 | + $this->assertEquals('<?php |
|
204 | 204 | /** |
205 | 205 | * @!rest\if test red |
206 | 206 | * @!rest\whatever |
207 | 207 | * @!rest\endif |
208 | 208 | */ |
209 | 209 | ', $out); |
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
214 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
215 | - */ |
|
216 | - public function testPreprocess_If_AnyValue() |
|
217 | - { |
|
218 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
219 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
220 | - $object->define('test', 'green'); |
|
221 | - $out = $object->preprocess('<?php |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
214 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
215 | + */ |
|
216 | + public function testPreprocess_If_AnyValue() |
|
217 | + { |
|
218 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
219 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
220 | + $object->define('test', 'green'); |
|
221 | + $out = $object->preprocess('<?php |
|
222 | 222 | /** |
223 | 223 | * @rest\if test |
224 | 224 | * @rest\whatever |
@@ -226,25 +226,25 @@ discard block |
||
226 | 226 | */ |
227 | 227 | '); |
228 | 228 | |
229 | - $this->assertEquals('<?php |
|
229 | + $this->assertEquals('<?php |
|
230 | 230 | /** |
231 | 231 | * @!rest\if test |
232 | 232 | * @rest\whatever |
233 | 233 | * @!rest\endif |
234 | 234 | */ |
235 | 235 | ', $out); |
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
240 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
241 | - */ |
|
242 | - public function testPreprocess_If_NoValue() |
|
243 | - { |
|
244 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
245 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
246 | - $object->define('test'); |
|
247 | - $out = $object->preprocess('<?php |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
240 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
241 | + */ |
|
242 | + public function testPreprocess_If_NoValue() |
|
243 | + { |
|
244 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
245 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
246 | + $object->define('test'); |
|
247 | + $out = $object->preprocess('<?php |
|
248 | 248 | /** |
249 | 249 | * @rest\if test red |
250 | 250 | * @rest\whatever |
@@ -252,25 +252,25 @@ discard block |
||
252 | 252 | */ |
253 | 253 | '); |
254 | 254 | |
255 | - $this->assertEquals('<?php |
|
255 | + $this->assertEquals('<?php |
|
256 | 256 | /** |
257 | 257 | * @!rest\if test red |
258 | 258 | * @!rest\whatever |
259 | 259 | * @!rest\endif |
260 | 260 | */ |
261 | 261 | ', $out); |
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
266 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
267 | - */ |
|
268 | - public function testPreprocess_If_Mismatch() |
|
269 | - { |
|
270 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
271 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
272 | - $object->define('test', 'green'); |
|
273 | - $out = $object->preprocess('<?php |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
266 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
267 | + */ |
|
268 | + public function testPreprocess_If_Mismatch() |
|
269 | + { |
|
270 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
271 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
272 | + $object->define('test', 'green'); |
|
273 | + $out = $object->preprocess('<?php |
|
274 | 274 | /** |
275 | 275 | * @rest\if test red |
276 | 276 | * @rest\whatever |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | */ |
279 | 279 | '); |
280 | 280 | |
281 | - $this->assertEquals('<?php |
|
281 | + $this->assertEquals('<?php |
|
282 | 282 | /** |
283 | 283 | * @!rest\if test red |
284 | 284 | * @!rest\whatever |
285 | 285 | * @!rest\endif |
286 | 286 | */ |
287 | 287 | ', $out); |
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
292 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
293 | - */ |
|
294 | - public function testPreprocess_If_Match() |
|
295 | - { |
|
296 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
297 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
298 | - $object->define('test', 'red'); |
|
299 | - $out = $object->preprocess('<?php |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
292 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
293 | + */ |
|
294 | + public function testPreprocess_If_Match() |
|
295 | + { |
|
296 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
297 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
298 | + $object->define('test', 'red'); |
|
299 | + $out = $object->preprocess('<?php |
|
300 | 300 | /** |
301 | 301 | * @rest\if test red |
302 | 302 | * @rest\whatever |
@@ -304,25 +304,25 @@ discard block |
||
304 | 304 | */ |
305 | 305 | '); |
306 | 306 | |
307 | - $this->assertEquals('<?php |
|
307 | + $this->assertEquals('<?php |
|
308 | 308 | /** |
309 | 309 | * @!rest\if test red |
310 | 310 | * @rest\whatever |
311 | 311 | * @!rest\endif |
312 | 312 | */ |
313 | 313 | ', $out); |
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
318 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
319 | - */ |
|
320 | - public function testPreprocess_Else_Match() |
|
321 | - { |
|
322 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
323 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
324 | - $object->define('test', 'blue'); |
|
325 | - $out = $object->preprocess('<?php |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
318 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
319 | + */ |
|
320 | + public function testPreprocess_Else_Match() |
|
321 | + { |
|
322 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
323 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
324 | + $object->define('test', 'blue'); |
|
325 | + $out = $object->preprocess('<?php |
|
326 | 326 | /** |
327 | 327 | * @rest\if test red |
328 | 328 | * @rest\whatever |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | '); |
334 | 334 | |
335 | - $this->assertEquals('<?php |
|
335 | + $this->assertEquals('<?php |
|
336 | 336 | /** |
337 | 337 | * @!rest\if test red |
338 | 338 | * @!rest\whatever |
@@ -341,18 +341,18 @@ discard block |
||
341 | 341 | * @!rest\endif |
342 | 342 | */ |
343 | 343 | ', $out); |
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
348 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
349 | - */ |
|
350 | - public function testPreprocess_Elif_Match() |
|
351 | - { |
|
352 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
353 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
354 | - $object->define('test', 'blue'); |
|
355 | - $out = $object->preprocess('<?php |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
348 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
349 | + */ |
|
350 | + public function testPreprocess_Elif_Match() |
|
351 | + { |
|
352 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
353 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
354 | + $object->define('test', 'blue'); |
|
355 | + $out = $object->preprocess('<?php |
|
356 | 356 | /** |
357 | 357 | * @rest\if test red |
358 | 358 | * @rest\whatever |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | '); |
366 | 366 | |
367 | - $this->assertEquals('<?php |
|
367 | + $this->assertEquals('<?php |
|
368 | 368 | /** |
369 | 369 | * @!rest\if test red |
370 | 370 | * @!rest\whatever |
@@ -375,18 +375,18 @@ discard block |
||
375 | 375 | * @!rest\endif |
376 | 376 | */ |
377 | 377 | ', $out); |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
382 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
383 | - */ |
|
384 | - public function testPreprocess_Elif_NoValue() |
|
385 | - { |
|
386 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
387 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
388 | - $object->define('test', 'blue'); |
|
389 | - $out = $object->preprocess('<?php |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
382 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
383 | + */ |
|
384 | + public function testPreprocess_Elif_NoValue() |
|
385 | + { |
|
386 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
387 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
388 | + $object->define('test', 'blue'); |
|
389 | + $out = $object->preprocess('<?php |
|
390 | 390 | /** |
391 | 391 | * @rest\if test red |
392 | 392 | * @rest\whatever |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | '); |
400 | 400 | |
401 | - $this->assertEquals('<?php |
|
401 | + $this->assertEquals('<?php |
|
402 | 402 | /** |
403 | 403 | * @!rest\if test red |
404 | 404 | * @!rest\whatever |
@@ -409,16 +409,16 @@ discard block |
||
409 | 409 | * @!rest\endif |
410 | 410 | */ |
411 | 411 | ', $out); |
412 | - } |
|
412 | + } |
|
413 | 413 | |
414 | - /** |
|
415 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
416 | - */ |
|
417 | - public function testPreprocess_Ifdef_AffectPrefixedOnly() |
|
418 | - { |
|
419 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
420 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
421 | - $out = $object->preprocess('<?php |
|
414 | + /** |
|
415 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
416 | + */ |
|
417 | + public function testPreprocess_Ifdef_AffectPrefixedOnly() |
|
418 | + { |
|
419 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
420 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
421 | + $out = $object->preprocess('<?php |
|
422 | 422 | /** |
423 | 423 | * @rest\ifdef test |
424 | 424 | * @rest\whatever |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | '); |
431 | 431 | |
432 | - $this->assertEquals('<?php |
|
432 | + $this->assertEquals('<?php |
|
433 | 433 | /** |
434 | 434 | * @!rest\ifdef test |
435 | 435 | * @!rest\whatever |
@@ -439,20 +439,20 @@ discard block |
||
439 | 439 | * @!rest\endif |
440 | 440 | */ |
441 | 441 | ', $out); |
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
446 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::undefine |
|
447 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
448 | - */ |
|
449 | - public function testPreprocess_Undefine() |
|
450 | - { |
|
451 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
452 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
453 | - $object->define('test'); |
|
454 | - $object->undefine('test'); |
|
455 | - $out = $object->preprocess('<?php |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
446 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::undefine |
|
447 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
448 | + */ |
|
449 | + public function testPreprocess_Undefine() |
|
450 | + { |
|
451 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
452 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
453 | + $object->define('test'); |
|
454 | + $object->undefine('test'); |
|
455 | + $out = $object->preprocess('<?php |
|
456 | 456 | /** |
457 | 457 | * @rest\ifdef test |
458 | 458 | * @rest\whatever |
@@ -460,27 +460,27 @@ discard block |
||
460 | 460 | */ |
461 | 461 | '); |
462 | 462 | |
463 | - $this->assertEquals('<?php |
|
463 | + $this->assertEquals('<?php |
|
464 | 464 | /** |
465 | 465 | * @!rest\ifdef test |
466 | 466 | * @!rest\whatever |
467 | 467 | * @!rest\endif |
468 | 468 | */ |
469 | 469 | ', $out); |
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
474 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::resetDefines |
|
475 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
476 | - */ |
|
477 | - public function testPreprocess_ResetDefines() |
|
478 | - { |
|
479 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
480 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
481 | - $object->define('test'); |
|
482 | - $object->resetDefines(); |
|
483 | - $out = $object->preprocess('<?php |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
474 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::resetDefines |
|
475 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
476 | + */ |
|
477 | + public function testPreprocess_ResetDefines() |
|
478 | + { |
|
479 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
480 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
481 | + $object->define('test'); |
|
482 | + $object->resetDefines(); |
|
483 | + $out = $object->preprocess('<?php |
|
484 | 484 | /** |
485 | 485 | * @rest\ifdef test |
486 | 486 | * @rest\whatever |
@@ -488,25 +488,25 @@ discard block |
||
488 | 488 | */ |
489 | 489 | '); |
490 | 490 | |
491 | - $this->assertEquals('<?php |
|
491 | + $this->assertEquals('<?php |
|
492 | 492 | /** |
493 | 493 | * @!rest\ifdef test |
494 | 494 | * @!rest\whatever |
495 | 495 | * @!rest\endif |
496 | 496 | */ |
497 | 497 | ', $out); |
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::addDefines |
|
502 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
503 | - */ |
|
504 | - public function testPreprocess_AddDefines() |
|
505 | - { |
|
506 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
507 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
508 | - $object->addDefines(array('test' => true)); |
|
509 | - $out = $object->preprocess('<?php |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::addDefines |
|
502 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
503 | + */ |
|
504 | + public function testPreprocess_AddDefines() |
|
505 | + { |
|
506 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
507 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
508 | + $object->addDefines(array('test' => true)); |
|
509 | + $out = $object->preprocess('<?php |
|
510 | 510 | /** |
511 | 511 | * @rest\ifdef test |
512 | 512 | * @rest\whatever |
@@ -514,23 +514,23 @@ discard block |
||
514 | 514 | */ |
515 | 515 | '); |
516 | 516 | |
517 | - $this->assertEquals('<?php |
|
517 | + $this->assertEquals('<?php |
|
518 | 518 | /** |
519 | 519 | * @!rest\ifdef test |
520 | 520 | * @rest\whatever |
521 | 521 | * @!rest\endif |
522 | 522 | */ |
523 | 523 | ', $out); |
524 | - } |
|
524 | + } |
|
525 | 525 | |
526 | - /** |
|
527 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
528 | - */ |
|
529 | - public function testPreprocess_AlternativePrefix() |
|
530 | - { |
|
531 | - $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
532 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
533 | - $out = $object->preprocess('<?php |
|
526 | + /** |
|
527 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocess |
|
528 | + */ |
|
529 | + public function testPreprocess_AlternativePrefix() |
|
530 | + { |
|
531 | + $object = new \SwaggerGen\Parser\Php\Preprocessor('foo'); |
|
532 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
533 | + $out = $object->preprocess('<?php |
|
534 | 534 | /** |
535 | 535 | * @foo\ifdef test |
536 | 536 | * @foo\whatever |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | '); |
541 | 541 | |
542 | - $this->assertEquals('<?php |
|
542 | + $this->assertEquals('<?php |
|
543 | 543 | /** |
544 | 544 | * @!foo\ifdef test |
545 | 545 | * @!foo\whatever |
@@ -547,31 +547,31 @@ discard block |
||
547 | 547 | * @!foo\endif |
548 | 548 | */ |
549 | 549 | ', $out); |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | - /** |
|
553 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
554 | - * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocessFile |
|
555 | - */ |
|
556 | - public function testPreprocessFile() |
|
557 | - { |
|
558 | - $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
559 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
560 | - $object->define('test'); |
|
552 | + /** |
|
553 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::define |
|
554 | + * @covers \SwaggerGen\Parser\Php\Preprocessor::preprocessFile |
|
555 | + */ |
|
556 | + public function testPreprocessFile() |
|
557 | + { |
|
558 | + $object = new \SwaggerGen\Parser\Php\Preprocessor(); |
|
559 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Preprocessor', $object); |
|
560 | + $object->define('test'); |
|
561 | 561 | |
562 | - $out = $object->preprocessFile(__DIR__ . '/PreprocessorTest/testPreprocessFile.php'); |
|
562 | + $out = $object->preprocessFile(__DIR__ . '/PreprocessorTest/testPreprocessFile.php'); |
|
563 | 563 | |
564 | - $this->assertEquals('<?php |
|
564 | + $this->assertEquals('<?php |
|
565 | 565 | |
566 | 566 | /** |
567 | 567 | * @!rest\ifdef test |
568 | 568 | * @rest\whatever |
569 | 569 | * @!rest\endif |
570 | 570 | */', $out); |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | - //@todo preprocess($content) -> mingle with other PHP code |
|
574 | - //@todo preprocess($content) -> Condition within comment |
|
575 | - //@todo preprocess($content) -> Condition over comments |
|
576 | - //@todo preprocess($content) -> Condition over code |
|
573 | + //@todo preprocess($content) -> mingle with other PHP code |
|
574 | + //@todo preprocess($content) -> Condition within comment |
|
575 | + //@todo preprocess($content) -> Condition over comments |
|
576 | + //@todo preprocess($content) -> Condition over code |
|
577 | 577 | } |