@@ 176-197 (lines=22) @@ | ||
173 | /** |
|
174 | * @test |
|
175 | */ |
|
176 | public function canUseOperationIdAsControllerKey() |
|
177 | { |
|
178 | $expected = 'my.controller.key:methodName'; |
|
179 | $pathDefinitions = (object)[ |
|
180 | '/a' => (object)[ |
|
181 | 'get' => (object)[], |
|
182 | 'post' => (object)['operationId' => $expected] |
|
183 | ], |
|
184 | '/b' => (object)['get' => (object)[]], |
|
185 | ]; |
|
186 | ||
187 | $this->documentMock |
|
188 | ->expects($this->any()) |
|
189 | ->method('getPathDefinitions') |
|
190 | ->willReturn($pathDefinitions); |
|
191 | ||
192 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
193 | ||
194 | $actual = $routes->get('swagger.path.a.methodName'); |
|
195 | $this->assertNotNull($actual); |
|
196 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
197 | } |
|
198 | ||
199 | /** |
|
200 | * @test |
|
@@ 202-224 (lines=23) @@ | ||
199 | /** |
|
200 | * @test |
|
201 | */ |
|
202 | public function canUseXRouterControllerForDiKeyInOperation() |
|
203 | { |
|
204 | $diKey = 'my.x_router.controller'; |
|
205 | $expected = "$diKey:post"; |
|
206 | $pathDefinitions = (object)[ |
|
207 | '/a' => (object)[ |
|
208 | 'get' => (object)[], |
|
209 | 'post' => (object)['x-router-controller' => $diKey] |
|
210 | ], |
|
211 | '/b' => (object)['get' => (object)[]], |
|
212 | ]; |
|
213 | ||
214 | $this->documentMock |
|
215 | ->expects($this->any()) |
|
216 | ->method('getPathDefinitions') |
|
217 | ->willReturn($pathDefinitions); |
|
218 | ||
219 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
220 | ||
221 | $actual = $routes->get('swagger.path.a.post'); |
|
222 | $this->assertNotNull($actual); |
|
223 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
224 | } |
|
225 | ||
226 | /** |
|
227 | * @test |
|
@@ 229-252 (lines=24) @@ | ||
226 | /** |
|
227 | * @test |
|
228 | */ |
|
229 | public function canUseXRouterControllerForDiKeyInPath() |
|
230 | { |
|
231 | $diKey = 'my.x_router.controller'; |
|
232 | $expected = "$diKey:post"; |
|
233 | $pathDefinitions = (object)[ |
|
234 | '/a' => (object)[ |
|
235 | 'x-router-controller' => $diKey, |
|
236 | 'get' => (object)[], |
|
237 | 'post' => (object)[] |
|
238 | ], |
|
239 | '/b' => (object)['get' => (object)[]], |
|
240 | ]; |
|
241 | ||
242 | $this->documentMock |
|
243 | ->expects($this->any()) |
|
244 | ->method('getPathDefinitions') |
|
245 | ->willReturn($pathDefinitions); |
|
246 | ||
247 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
248 | ||
249 | $actual = $routes->get('swagger.path.a.post'); |
|
250 | $this->assertNotNull($actual); |
|
251 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
252 | } |
|
253 | ||
254 | /** |
|
255 | * @test |
|
@@ 257-280 (lines=24) @@ | ||
254 | /** |
|
255 | * @test |
|
256 | */ |
|
257 | public function canUseXRouterForDiKeyInPath() |
|
258 | { |
|
259 | $router = 'my.x_router'; |
|
260 | $expected = "$router.a:post"; |
|
261 | $pathDefinitions = (object)[ |
|
262 | 'x-router' => $router, |
|
263 | '/a' => (object)[ |
|
264 | 'get' => (object)[], |
|
265 | 'post' => (object)[] |
|
266 | ], |
|
267 | '/b' => (object)['get' => (object)[]], |
|
268 | ]; |
|
269 | ||
270 | $this->documentMock |
|
271 | ->expects($this->any()) |
|
272 | ->method('getPathDefinitions') |
|
273 | ->willReturn($pathDefinitions); |
|
274 | ||
275 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
276 | ||
277 | $actual = $routes->get('swagger.path.a.post'); |
|
278 | $this->assertNotNull($actual); |
|
279 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
280 | } |
|
281 | ||
282 | /** |
|
283 | * @test |