diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php new file mode 100644 index 0000000..3ddbe39 --- /dev/null +++ b/app/tests/TestCase.php @@ -0,0 +1,76 @@ +build(); + $app = AppFactory::setContainer($container); + + // add middleware + + // add routes + + return $app; + } + + /** + * @param string $method + * @param string path + * @param array $headers + * @param array $cookies + * @param array $serverParams + */ + protected function createRequest( + string $method, + string $path, + array $headers = [], + array $cookies = [], + array $serverParams = [] + ): Request { + $uri = new Uri('', '', 80, $path); + $handle = fopen('php://temp', 'w+'); + $stream = (new StreamFactory())->createStreamFromResource($handle); + + $h = new Headers(); + foreach ($headers as $name => $value) { + $h->addHeader($name, $value); + } + + return new SlimRequest( + $method, + $uri, + $h, + $cookies, + $serverParams, + $stream + ); + } +} diff --git a/app/tests/bootstrap.php b/app/tests/bootstrap.php new file mode 100644 index 0000000..a4abe2d --- /dev/null +++ b/app/tests/bootstrap.php @@ -0,0 +1,2 @@ +