diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:33 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:33 +0100 |
| commit | 12f31dd117754605c950e0b6866c84e9102bb8ac (patch) | |
| tree | 353edc58cc8504fc03be9e7fb1f289d2c787b9d8 /tests/Unit/RouterTest.php | |
| parent | 7978144408e0a8d2ec5375831fb2111ef08e4b27 (diff) | |
testing router creates routes with or without / prefix
Diffstat (limited to 'tests/Unit/RouterTest.php')
| -rw-r--r-- | tests/Unit/RouterTest.php | 22 |
1 files changed, 6 insertions, 16 deletions
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) |
