| @@ 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 |
|
| @@ 226-248 (lines=23) @@ | ||
| 223 | /** |
|
| 224 | * @test |
|
| 225 | */ |
|
| 226 | public function canUseXRouterControllerForDiKeyInOperation() |
|
| 227 | { |
|
| 228 | $diKey = 'my.x_router.controller'; |
|
| 229 | $expected = "$diKey:post"; |
|
| 230 | $pathDefinitions = (object)[ |
|
| 231 | '/a' => (object)[ |
|
| 232 | 'get' => (object)[], |
|
| 233 | 'post' => (object)['x-router-controller' => $diKey] |
|
| 234 | ], |
|
| 235 | '/b' => (object)['get' => (object)[]], |
|
| 236 | ]; |
|
| 237 | ||
| 238 | $this->documentMock |
|
| 239 | ->expects($this->any()) |
|
| 240 | ->method('getPathDefinitions') |
|
| 241 | ->willReturn($pathDefinitions); |
|
| 242 | ||
| 243 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 244 | ||
| 245 | $actual = $routes->get('swagger.path.a.post'); |
|
| 246 | $this->assertNotNull($actual); |
|
| 247 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 248 | } |
|
| 249 | ||
| 250 | /** |
|
| 251 | * @test |
|
| @@ 253-276 (lines=24) @@ | ||
| 250 | /** |
|
| 251 | * @test |
|
| 252 | */ |
|
| 253 | public function canUseXRouterControllerForDiKeyInPath() |
|
| 254 | { |
|
| 255 | $diKey = 'my.x_router.controller'; |
|
| 256 | $expected = "$diKey:post"; |
|
| 257 | $pathDefinitions = (object)[ |
|
| 258 | '/a' => (object)[ |
|
| 259 | 'x-router-controller' => $diKey, |
|
| 260 | 'get' => (object)[], |
|
| 261 | 'post' => (object)[] |
|
| 262 | ], |
|
| 263 | '/b' => (object)['get' => (object)[]], |
|
| 264 | ]; |
|
| 265 | ||
| 266 | $this->documentMock |
|
| 267 | ->expects($this->any()) |
|
| 268 | ->method('getPathDefinitions') |
|
| 269 | ->willReturn($pathDefinitions); |
|
| 270 | ||
| 271 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 272 | ||
| 273 | $actual = $routes->get('swagger.path.a.post'); |
|
| 274 | $this->assertNotNull($actual); |
|
| 275 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 276 | } |
|
| 277 | ||
| 278 | /** |
|
| 279 | * @test |
|
| @@ 281-304 (lines=24) @@ | ||
| 278 | /** |
|
| 279 | * @test |
|
| 280 | */ |
|
| 281 | public function canUseXRouterForDiKeyInPath() |
|
| 282 | { |
|
| 283 | $router = 'my.x_router'; |
|
| 284 | $expected = "$router.a:post"; |
|
| 285 | $pathDefinitions = (object)[ |
|
| 286 | 'x-router' => $router, |
|
| 287 | '/a' => (object)[ |
|
| 288 | 'get' => (object)[], |
|
| 289 | 'post' => (object)[] |
|
| 290 | ], |
|
| 291 | '/b' => (object)['get' => (object)[]], |
|
| 292 | ]; |
|
| 293 | ||
| 294 | $this->documentMock |
|
| 295 | ->expects($this->any()) |
|
| 296 | ->method('getPathDefinitions') |
|
| 297 | ->willReturn($pathDefinitions); |
|
| 298 | ||
| 299 | $routes = $this->loader->load(self::DOCUMENT_PATH); |
|
| 300 | ||
| 301 | $actual = $routes->get('swagger.path.a.post'); |
|
| 302 | $this->assertNotNull($actual); |
|
| 303 | $this->assertSame($expected, $actual->getDefault('_controller')); |
|
| 304 | } |
|
| 305 | ||
| 306 | /** |
|
| 307 | * @test |
|