diff --git a/src/App.php b/src/App.php index a732f78..ec3bc61 100644 --- a/src/App.php +++ b/src/App.php @@ -472,7 +472,7 @@ class App return $this->logger; } - protected function loadAllRoutes(ServerRequestInterface $request): self + public function loadAllRoutes(ServerRequestInterface $request): self { $this->debugBar['time']->startMeasure('interrogateControllers', 'Time to interrogate controllers for routes'); $this->interrogateControllers(); diff --git a/tests/Traits/AppTestTrait.php b/tests/Traits/AppTestTrait.php index d1d3fa5..3289a56 100644 --- a/tests/Traits/AppTestTrait.php +++ b/tests/Traits/AppTestTrait.php @@ -10,6 +10,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UriInterface; use Slim\App as SlimApp; +use Slim\Factory\ServerRequestCreatorFactory; use Slim\Psr7\Factory\ServerRequestFactory; use UnexpectedValueException; @@ -41,7 +42,10 @@ trait AppTestTrait $this->container = $container; - $this->benzineApp->loadAllRoutes(); + $serverRequestCreator = ServerRequestCreatorFactory::create(); + $request = $serverRequestCreator->createServerRequestFromGlobals(); + + $this->benzineApp->loadAllRoutes($request); } /** @@ -67,6 +71,14 @@ trait AppTestTrait return $mock; } + protected function getResponse(ServerRequestInterface $request): ResponseInterface + { + $response = $this->slimApp->handle($request); + $response->getBody()->rewind(); + + return $response; + } + /** * Create a server request. * @@ -76,6 +88,8 @@ trait AppTestTrait */ protected function createRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface { + + $this->setupContainer(); return (new ServerRequestFactory())->createServerRequest($method, $uri, $serverParams); }