@@ 240-264 (lines=25) @@ | ||
237 | * |
|
238 | * @param string $method |
|
239 | */ |
|
240 | public function testWillRespondWithNotFoundForRouteWithNoTrailingSlashWhenMountedFirst($method) |
|
241 | { |
|
242 | $app = new Application(); |
|
243 | ||
244 | $app->register(new TrailingSlashControllerProvider()); |
|
245 | $app->mount('/', new TrailingSlashControllerProvider()); |
|
246 | ||
247 | $app->match('/foo', function () { |
|
248 | return 'hunter42'; |
|
249 | })->method($method); |
|
250 | ||
251 | $app->match('/foo/bar', function () { |
|
252 | return 'hunter42'; |
|
253 | })->method($method); |
|
254 | ||
255 | $request = Request::create('/foo', $method); |
|
256 | $response = $app->handle($request); |
|
257 | ||
258 | $this->assertEquals(404, $response->getStatusCode()); |
|
259 | ||
260 | $request = Request::create('/foo/bar', $method); |
|
261 | $response = $app->handle($request); |
|
262 | ||
263 | $this->assertEquals(404, $response->getStatusCode()); |
|
264 | } |
|
265 | ||
266 | /** |
|
267 | * This is just to show when defining routes with no trailing slash before |
|
@@ 274-298 (lines=25) @@ | ||
271 | * |
|
272 | * @param string $method |
|
273 | */ |
|
274 | public function testWillRespondWithOkForRouteWithNoTrailingSlashWhenMountedLast($method) |
|
275 | { |
|
276 | $app = new Application(); |
|
277 | ||
278 | $app->match('/foo', function () { |
|
279 | return 'hunter42'; |
|
280 | })->method($method); |
|
281 | ||
282 | $app->match('/foo/bar', function () { |
|
283 | return 'hunter42'; |
|
284 | })->method($method); |
|
285 | ||
286 | $app->register(new TrailingSlashControllerProvider()); |
|
287 | $app->mount('/', new TrailingSlashControllerProvider()); |
|
288 | ||
289 | $request = Request::create('/foo', $method); |
|
290 | $response = $app->handle($request); |
|
291 | ||
292 | $this->assertEquals(200, $response->getStatusCode()); |
|
293 | ||
294 | $request = Request::create('/foo/bar', $method); |
|
295 | $response = $app->handle($request); |
|
296 | ||
297 | $this->assertEquals(200, $response->getStatusCode()); |
|
298 | } |
|
299 | ||
300 | /** |
|
301 | * Test the case in which a request should have both query |