|
@@ 229-253 (lines=25) @@
|
| 226 |
|
* |
| 227 |
|
* @dataProvider requestMethodProvider |
| 228 |
|
*/ |
| 229 |
|
public function testWillRespondWithNotFoundForRouteWithNoTrailingSlashWhenMountedFirst($method) |
| 230 |
|
{ |
| 231 |
|
$app = new Application(); |
| 232 |
|
|
| 233 |
|
$app->register(new TrailingSlashControllerProvider()); |
| 234 |
|
$app->mount('/', new TrailingSlashControllerProvider()); |
| 235 |
|
|
| 236 |
|
$app->match('/foo', function () { |
| 237 |
|
return 'hunter42'; |
| 238 |
|
})->method($method); |
| 239 |
|
|
| 240 |
|
$app->match('/foo/bar', function () { |
| 241 |
|
return 'hunter42'; |
| 242 |
|
})->method($method); |
| 243 |
|
|
| 244 |
|
$request = Request::create('/foo', $method); |
| 245 |
|
$response = $app->handle($request); |
| 246 |
|
|
| 247 |
|
$this->assertEquals(404, $response->getStatusCode()); |
| 248 |
|
|
| 249 |
|
$request = Request::create('/foo/bar', $method); |
| 250 |
|
$response = $app->handle($request); |
| 251 |
|
|
| 252 |
|
$this->assertEquals(404, $response->getStatusCode()); |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
/** |
| 256 |
|
* This is just to show when defining routes with no trailing slash before |
|
@@ 261-285 (lines=25) @@
|
| 258 |
|
* |
| 259 |
|
* @dataProvider requestMethodProvider |
| 260 |
|
*/ |
| 261 |
|
public function testWillRespondWithOkForRouteWithNoTrailingSlashWhenMountedLast($method) |
| 262 |
|
{ |
| 263 |
|
$app = new Application(); |
| 264 |
|
|
| 265 |
|
$app->match('/foo', function () { |
| 266 |
|
return 'hunter42'; |
| 267 |
|
})->method($method); |
| 268 |
|
|
| 269 |
|
$app->match('/foo/bar', function () { |
| 270 |
|
return 'hunter42'; |
| 271 |
|
})->method($method); |
| 272 |
|
|
| 273 |
|
$app->register(new TrailingSlashControllerProvider()); |
| 274 |
|
$app->mount('/', new TrailingSlashControllerProvider()); |
| 275 |
|
|
| 276 |
|
$request = Request::create('/foo', $method); |
| 277 |
|
$response = $app->handle($request); |
| 278 |
|
|
| 279 |
|
$this->assertEquals(200, $response->getStatusCode()); |
| 280 |
|
|
| 281 |
|
$request = Request::create('/foo/bar', $method); |
| 282 |
|
$response = $app->handle($request); |
| 283 |
|
|
| 284 |
|
$this->assertEquals(200, $response->getStatusCode()); |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
/** |
| 288 |
|
* Test the case in which a request should have both query |