diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Unit/GroupTest.php | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/Unit/GroupTest.php b/tests/Unit/GroupTest.php index 6549295..a2f06b2 100644 --- a/tests/Unit/GroupTest.php +++ b/tests/Unit/GroupTest.php @@ -7,32 +7,32 @@ use Lightscale\Router\GroupDefinition; use Lightscale\Router\Router; use Lightscale\Router\Test\Utils\TestCallable; -$make = fn(?Group $parent = null) => new Group(new Router, $parent); +$make = fn (?Group $parent = null) => new Group(new Router(), $parent); it('initializes with null defaults') - ->expect(fn() => $make()) + ->expect(fn () => $make()) ->toBeInstanceOf(Group::class) ->getName()->toBeNull() ->getPrefix()->toBeNull(); it('initializes with values') - ->expect(new Group(new Router, null, '/test-path', 'test-name')) + ->expect(new Group(new Router(), null, '/test-path', 'test-name')) ->toBeInstanceOf(Group::class) ->getName()->toBe('test-name') ->getPrefix()->toBe('/test-path'); it('can set/get prefix') - ->expect(fn() => $make()->prefix('/test')) + ->expect(fn () => $make()->prefix('/test')) ->toBeInstanceOf(Group::class) ->getPrefix()->toBe('/test'); it('can set/get name') - ->expect(fn() => $make()->name('test')) + ->expect(fn () => $make()->name('test')) ->toBeInstanceOf(Group::class) ->getName()->toBe('test'); it('calls group call back with definition', function () use ($make) { - $cb = TestCallable::make(fn() => null); + $cb = TestCallable::make(fn () => null); $make()->group($cb); $cb->assertCalled(); @@ -55,7 +55,7 @@ it('can get all ancestors') ->toContainOnlyInstancesOf(Group::class) ->toHaveCount(2); -it('order all ancestors root first', function () use($make) { +it('order all ancestors root first', function () use ($make) { $g3 = $make($g2 = $make($g1 = $make())); expect($g3->getAncestors()) @@ -70,7 +70,7 @@ it('can get all ancestors and self') ->toContainOnlyInstancesOf(Group::class) ->toHaveCount(3); -it('order all ancestors and self root first', function () use($make) { +it('order all ancestors and self root first', function () use ($make) { $g3 = $make($g2 = $make($g1 = $make())); expect($g3->getAncestorsAndSelf()) @@ -81,17 +81,17 @@ it('order all ancestors and self root first', function () use($make) { }); it('gets the path with no prefix or parents') - ->expect(fn () => $make()->getPath()) + ->expect(fn () => $make()->getFullPrefix()) ->toBe('/'); it('gets the path without parents') - ->expect(fn () => $make()->prefix('/t1/t2')->getPath()) + ->expect(fn () => $make()->prefix('/t1/t2')->getFullPrefix()) ->toBe('/t1/t2'); it('gets the path with parent') ->expect(fn () => $make( $make()->prefix('hello/world') - )->prefix('/t1/t2')->getPath()) + )->prefix('/t1/t2')->getFullPrefix()) ->toBe('/hello/world/t1/t2'); it('gets the path with two ancestors') @@ -99,14 +99,13 @@ it('gets the path with two ancestors') $make( $make()->prefix('test') )->prefix('hello/world') - )->prefix('/t1/t2')->getPath()) + )->prefix('/t1/t2')->getFullPrefix()) ->toBe('/test/hello/world/t1/t2'); - it('gets the path with three ancestors, one without prefix') ->expect(fn () => $make( $make( $make($make()->prefix('test')) )->prefix('hello/world') - )->prefix('/t1/t2')->getPath()) + )->prefix('/t1/t2')->getFullPrefix()) ->toBe('/test/hello/world/t1/t2'); |
