From 12f31dd117754605c950e0b6866c84e9102bb8ac Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:33 +0100 Subject: testing router creates routes with or without / prefix --- tests/Unit/RouterTest.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php index a2ed18f..a7e7a21 100644 --- a/tests/Unit/RouterTest.php +++ b/tests/Unit/RouterTest.php @@ -218,22 +218,6 @@ it('make a route with parameter', function () { ->parameters->toBe(['test1' => 'hello']); }); -it('makes a get route', function () { - $router = new Router(); - $router->get('/test1/test2', fn () => null); - - expect($router->findRoute(HttpMethod::Get, '/test1/test2')) - ->toBeInstanceOf(RouteMatch::class); -}); - -it('makes a post route', function () { - $router = new Router(); - $router->post('/test1/test2', fn () => null); - - expect($router->findRoute(HttpMethod::Post, '/test1/test2')) - ->toBeInstanceOf(RouteMatch::class); -}); - it('makes a :dataset route') ->with('http-methods') ->expect(function (HttpMethod $m) { @@ -244,6 +228,12 @@ it('makes a :dataset route') }) ->toBeInstanceOf(RouteMatch::class); +it('makes route with or without / prefix', function(string $path) { + $router = new Router; + $r = $router->get($path, fn() => null)->getRoute(); + expect($router->findRoute(HttpMethod::Get, '/test')?->route)->toBe($r); +})->with(['/test', 'test']); + it('returns RouteDefinition when making route') ->expect(fn () => (new Router()) ->make(HttpMethod::Get, '/test', fn () => null) -- cgit v1.2.3