use Lead\Router\RouterException; use Lead\Router\Router; use Lead\Router\Route; use Lead\Net\Http\Cgi\Request; describe("Router", function () { beforeEach(function () { $this->router = new Router(); $this->export = function ($request) { return array_intersect_key($request, array_fill_keys(['path', 'method', 'host', 'scheme'], true)); }; }); describe("->__construct()", function () { it("formats the basePath", function () { $router = new Router(['basePath' => '/']); expect($router->basePath())->toBe(''); }); }); describe("->basePath()", function () { it("sets an empty basePath", function () { expect($this->router->basePath('/'))->toBe($this->router); expect($this->router->basePath())->toBe(''); expect($this->router->basePath(''))->toBe($this->router); expect($this->router->basePath())->toBe(''); }); it("adds an leading slash for non empty basePath", function () { expect($this->router->basePath('app'))->toBe($this->router); expect($this->router->basePath())->toBe('/app'); expect($this->router->basePath('/base'))->toBe($this->router); expect($this->router->basePath())->toBe('/base'); });