diff --git a/src/Response.php b/src/Response.php index 45104b5..56709f8 100644 --- a/src/Response.php +++ b/src/Response.php @@ -92,6 +92,16 @@ public static function redirect($uri, int $status = 303): self return new self($status, null, ['Location' => (string) $uri]); } + public static function badRequest(StreamInterface $body = null): self + { + return new self(400, $body); + } + + public static function unauthorized(StreamInterface $body = null): self + { + return new self(401, $body); + } + public static function notFound(StreamInterface $body = null): self { return new self(404, $body); diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 5b3835d..a6e8419 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -138,10 +138,9 @@ public function testNamedConstructors() new Response(301, null, ['Location' => '/foo/bar/baz']), Response::redirect('/foo/bar/baz', 301) ); - $this->equivalentConstructs( - new Response(404), - Response::notFound() - ); + $this->equivalentConstructs(new Response(400), Response::badRequest()); + $this->equivalentConstructs(new Response(401), Response::unauthorized()); + $this->equivalentConstructs(new Response(404), Response::notFound()); $this->equivalentConstructs( new Response(404, new FakeStream('Not Found. Sorry.')), Response::notFound(new FakeStream('Not Found. Sorry.'))