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 | 7d76684ad6cd0182545489d7ed54ae9823d94ffa (patch) | |
| tree | beb2f79d2ff695a1dd467d95276947f655adaffb /tests/Unit/GroupDefinitionTest.php | |
| parent | 968662ee16a1efc7cb7c176a42af91f36eecc9ca (diff) | |
Testing the creating routes on a group definition and code format
Diffstat (limited to 'tests/Unit/GroupDefinitionTest.php')
| -rw-r--r-- | tests/Unit/GroupDefinitionTest.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/Unit/GroupDefinitionTest.php b/tests/Unit/GroupDefinitionTest.php index b8e8063..f11cb87 100644 --- a/tests/Unit/GroupDefinitionTest.php +++ b/tests/Unit/GroupDefinitionTest.php @@ -6,6 +6,7 @@ use Lightscale\Router\Enums\HttpMethod; use Lightscale\Router\Group; use Lightscale\Router\GroupDefinition; use Lightscale\Router\PathSegmentMatch; +use Lightscale\Router\RouteDefinition; use Lightscale\Router\Router; $make = fn () => new GroupDefinition(new Group(new Router(), null)); @@ -25,7 +26,7 @@ it('creates group with name') ->getName()->toBe('name'); it('can make a route', function () { - $router = new Router; + $router = new Router(); $group = (new Group($router, null))->prefix('/test'); $groupDef = new GroupDefinition($group); $groupDef->make(HttpMethod::Get, '/hello/world', fn () => null); @@ -33,3 +34,10 @@ it('can make a route', function () { expect($router->findSegment('/test/hello/world')) ->toBeInstanceOf(PathSegmentMatch::class); }); + +it('returns RouteDefinition when making :dataset route') + ->with('http-methods') + ->expect(fn (HttpMethod $m) => (new GroupDefinition((new Group(new Router(), null))->prefix('/test'))) + ->{$m->value}('/hello', fn () => null) + ) + ->toBeInstanceOf(RouteDefinition::class); |
