| @@ 293-314 (lines=22) @@ | ||
| 290 | /** |
|
| 291 | * @test |
|
| 292 | */ |
|
| 293 | public function canUseXRouterControllerForDiKeyInPath() |
|
| 294 | { |
|
| 295 | $diKey = 'my.x_router.controller'; |
|
| 296 | $expected = "$diKey:post"; |
|
| 297 | $this->decriptionMock |
|
| 298 | ->expects($this->any()) |
|
| 299 | ->method('getPaths') |
|
| 300 | ->willReturn([new Path('/a', [new Operation('/a:post', '/a', 'post')])]); |
|
| 301 | ||
| 302 | $this->decriptionMock |
|
| 303 | ->expects($this->atLeast(1)) |
|
| 304 | ->method('getExtension') |
|
| 305 | ->willReturnCallback( |
|
| 306 | function (string $name) use ($diKey) { |
|
| 307 | return $name == 'router-controller' ? $diKey : null; |
|
| 308 | } |
|
| 309 | ); |
|
| 310 | ||
| 311 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 312 | ||
| 313 | $actual = $routes->get('swagger.path.a.post'); |
|
| 314 | $this->assertNotNull($actual); |
|
| 315 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 316 | } |
|
| 317 | ||
| @@ 321-342 (lines=22) @@ | ||
| 318 | /** |
|
| 319 | * @test |
|
| 320 | */ |
|
| 321 | public function canUseXRouterForDiKeyInPath() |
|
| 322 | { |
|
| 323 | $router = 'my.x_router'; |
|
| 324 | $expected = "$router.a:post"; |
|
| 325 | $this->decriptionMock |
|
| 326 | ->expects($this->any()) |
|
| 327 | ->method('getPaths') |
|
| 328 | ->willReturn([new Path('/a', [new Operation('/a:post', '/a', 'post')])]); |
|
| 329 | ||
| 330 | $this->decriptionMock |
|
| 331 | ->expects($this->atLeast(1)) |
|
| 332 | ->method('getExtension') |
|
| 333 | ->willReturnCallback( |
|
| 334 | function (string $name) use ($router) { |
|
| 335 | return $name == 'router' ? $router : null; |
|
| 336 | } |
|
| 337 | ); |
|
| 338 | ||
| 339 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 340 | ||
| 341 | $actual = $routes->get('swagger.path.a.post'); |
|
| 342 | $this->assertNotNull($actual); |
|
| 343 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 344 | } |
|
| 345 | ||