summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2026-06-10 19:00:33 +0100
committerSam Light <sam@lightscale.co.uk>2026-06-10 19:00:33 +0100
commit12f31dd117754605c950e0b6866c84e9102bb8ac (patch)
tree353edc58cc8504fc03be9e7fb1f289d2c787b9d8 /tests
parent7978144408e0a8d2ec5375831fb2111ef08e4b27 (diff)
testing router creates routes with or without / prefix
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/RouterTest.php22
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)