| @@ 252-273 (lines=22) @@ | ||
| 249 | /** |
|
| 250 | * @test |
|
| 251 | */ |
|
| 252 | public function canUseXRouterControllerForDiKeyInPath() |
|
| 253 | { |
|
| 254 | $diKey = 'my.x_router.controller'; |
|
| 255 | $expected = "$diKey:post"; |
|
| 256 | $this->decriptionMock |
|
| 257 | ->expects($this->any()) |
|
| 258 | ->method('getPaths') |
|
| 259 | ->willReturn([new Path('/a', [new Operation('/a:post', '/a', 'post')])]); |
|
| 260 | ||
| 261 | $this->decriptionMock |
|
| 262 | ->expects($this->atLeast(1)) |
|
| 263 | ->method('getExtension') |
|
| 264 | ->willReturnCallback(function (string $name) use ($diKey) { |
|
| 265 | return $name == 'router-controller' ? $diKey : null; |
|
| 266 | }); |
|
| 267 | ||
| 268 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 269 | ||
| 270 | $actual = $routes->get('swagger.path.a.post'); |
|
| 271 | $this->assertNotNull($actual); |
|
| 272 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * @test |
|
| @@ 278-299 (lines=22) @@ | ||
| 275 | /** |
|
| 276 | * @test |
|
| 277 | */ |
|
| 278 | public function canUseXRouterForDiKeyInPath() |
|
| 279 | { |
|
| 280 | $router = 'my.x_router'; |
|
| 281 | $expected = "$router.a:post"; |
|
| 282 | $this->decriptionMock |
|
| 283 | ->expects($this->any()) |
|
| 284 | ->method('getPaths') |
|
| 285 | ->willReturn([new Path('/a', [new Operation('/a:post', '/a', 'post')])]); |
|
| 286 | ||
| 287 | $this->decriptionMock |
|
| 288 | ->expects($this->atLeast(1)) |
|
| 289 | ->method('getExtension') |
|
| 290 | ->willReturnCallback(function (string $name) use ($router) { |
|
| 291 | return $name == 'router' ? $router : null; |
|
| 292 | }); |
|
| 293 | ||
| 294 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 295 | ||
| 296 | $actual = $routes->get('swagger.path.a.post'); |
|
| 297 | $this->assertNotNull($actual); |
|
| 298 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 299 | } |
|
| 300 | ||
| 301 | /** |
|
| 302 | * @test |
|