|
@@ 287-309 (lines=23) @@
|
| 284 |
|
$this->assertInstanceOf(JsonResponse::class, $response2); |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
public function testExtendedController() |
| 288 |
|
{ |
| 289 |
|
$container = new Picotainer([ |
| 290 |
|
'controller' => function () { |
| 291 |
|
return new TestExtendedController2(); |
| 292 |
|
}, |
| 293 |
|
]); |
| 294 |
|
$parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
| 295 |
|
$controllerAnalyzer = new ControllerAnalyzer($container, $parameterFetcherRegistry, new AnnotationReader()); |
| 296 |
|
$controllerRegistry = new ControllerRegistry($controllerAnalyzer, ['controller']); |
| 297 |
|
$defaultRouter = new SplashDefaultRouter($container, [ |
| 298 |
|
$controllerRegistry, |
| 299 |
|
], $parameterFetcherRegistry, new ArrayCachePool()); |
| 300 |
|
|
| 301 |
|
$request = new ServerRequest([], [], '/url/42/foo/52', 'GET', 'php://input', |
| 302 |
|
[], |
| 303 |
|
[], |
| 304 |
|
[] |
| 305 |
|
); |
| 306 |
|
$response = new HtmlResponse(''); |
| 307 |
|
$response = $defaultRouter($request, $response); |
| 308 |
|
$this->assertInstanceOf(JsonResponse::class, $response); |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
public function testBadParam() |
| 312 |
|
{ |
|
@@ 311-334 (lines=24) @@
|
| 308 |
|
$this->assertInstanceOf(JsonResponse::class, $response); |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
public function testBadParam() |
| 312 |
|
{ |
| 313 |
|
$container = new Picotainer([ |
| 314 |
|
'controller' => function () { |
| 315 |
|
return new TestBadParamController(); |
| 316 |
|
}, |
| 317 |
|
]); |
| 318 |
|
$parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
| 319 |
|
$controllerAnalyzer = new ControllerAnalyzer($container, $parameterFetcherRegistry, new AnnotationReader()); |
| 320 |
|
$controllerRegistry = new ControllerRegistry($controllerAnalyzer, ['controller']); |
| 321 |
|
$defaultRouter = new SplashDefaultRouter($container, [ |
| 322 |
|
$controllerRegistry, |
| 323 |
|
], $parameterFetcherRegistry, new ArrayCachePool()); |
| 324 |
|
|
| 325 |
|
$request = new ServerRequest([], [], '/notexistparam/42', 'GET', 'php://input', |
| 326 |
|
[], |
| 327 |
|
[], |
| 328 |
|
[] |
| 329 |
|
); |
| 330 |
|
$response = new HtmlResponse(''); |
| 331 |
|
$this->expectException(\InvalidArgumentException::class); |
| 332 |
|
$response = $defaultRouter($request, $response); |
| 333 |
|
|
| 334 |
|
} |
| 335 |
|
} |
| 336 |
|
|