diff options
Diffstat (limited to 'tests/Unit/RouterTest.php')
| -rw-r--r-- | tests/Unit/RouterTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php index 421cc7c..2f8960a 100644 --- a/tests/Unit/RouterTest.php +++ b/tests/Unit/RouterTest.php @@ -144,3 +144,29 @@ it('calls strategy runRoute with dispatch on match', function () { $result = $router->dispatch($request); expect($result)->toBe($response); }); + +it('matches an any method route', function() { + $router = new Router(); + $factory = new Psr17Factory(); + $response = $factory->createResponse(); + $router->root()->child('testing')->addRoute(new Route( + HttpMethod::Any, + fn() => $response + )); + + $result = $router->dispatch($factory->createServerRequest(HttpMethod::Get->value, '/testing')); + expect($result)->toBe($response); +}); + +it('matches route method case insenitively', function() { + $router = new Router(); + $factory = new Psr17Factory(); + $response = $factory->createResponse(); + $router->root()->child('testing')->addRoute(new Route( + HttpMethod::Get, + fn() => $response + )); + + $result = $router->dispatch($factory->createServerRequest('GeT', '/testing')); + expect($result)->toBe($response); +}); |
