diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
| commit | b1b5696cf2fa0b2050d5b0387c4d819d2f41e4d4 (patch) | |
| tree | d59e87ac5b0e39cb98ef6169faf6b73be0fda690 /tests/Unit | |
| parent | 2086ed04a52597b20309233c35de9d8023b963f3 (diff) | |
Wrote tests for any route and insensitive match
Diffstat (limited to 'tests/Unit')
| -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); +}); |
