diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Unit/RouterTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php index dc78f56..c6d5163 100644 --- a/tests/Unit/RouterTest.php +++ b/tests/Unit/RouterTest.php @@ -183,3 +183,42 @@ it('calls strategy runRoute with dispatch on match', function () { $result = $router->dispatch($request); expect($result)->toBe($response); }); + +it('make a route', function () { + $router = new Router(); + + $router->route(HttpMethod::Get, '/test1/test2/test3', fn () => null); + + expect($router->findRoute(HttpMethod::Get, '/test1/test2/test3')) + ->toBeInstanceOf(RouteMatch::class); +}); + +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(function (): Generator { + foreach (HttpMethod::cases() as $m) { + yield $m->value => $m; + } + }) + ->expect(function (HttpMethod $m) { + $router = new Router(); + $router->{$m->value}($p = '/test1/test2', fn () => null); + + return $router->findRoute($m, $p); + }) + ->toBeInstanceOf(RouteMatch::class); |
