expect(fn () => new Route( HttpMethod::Get, fn () => null, new PathSegment(type: PathSegmentType::Root), )) ->toBeInstanceOf(Route::class); it('gets segment') ->expect(fn () => (new Route( HttpMethod::Get, fn () => null, new PathSegment(type: PathSegmentType::Root), ))->getSegment()) ->toBeInstanceOf(PathSegment::class); it('throws getting segment without being set', function () { $r = new Route(HttpMethod::Get, fn () => null); $r->getSegment(); })->throws(Error::class); it('can set segment') ->expect(function () { $r = new Route(HttpMethod::Get, fn () => null); $r->setSegment(new PathSegment('test')); return $r->getSegment(); }) ->toBeInstanceOf(PathSegment::class) ->getValue()->toBe('test'); it('gets method') ->expect(fn () => (new Route( HttpMethod::Get, fn () => null, ))->getMethod()) ->toBe(HttpMethod::Get); it('can call handler') ->expect(fn () => (new Route( HttpMethod::Get, fn (RequestInterface $req) => $req->getUri()->getPath() ))( (new Psr17Factory())->createRequest(HttpMethod::Get->value, '/testing') ) ) ->toBe('/testing');