diff --git a/src/Syndra.php b/src/Syndra.php index ba0425d..c545cfb 100644 --- a/src/Syndra.php +++ b/src/Syndra.php @@ -191,6 +191,18 @@ public function respondInternalError($message) ->respondWithError($message); } + /** + * Use this for HTTP not implemented errors (501). + * + * @param string $message + * @return mixed + */ + public function respondNotImplemented($message) + { + return $this->setStatusCode(Response::HTTP_NOT_IMPLEMENTED) + ->respondWithError($message); + } + /** * Use this when the validation fails (422). * diff --git a/tests/SyndraTest.php b/tests/SyndraTest.php index 7deb602..feb501a 100644 --- a/tests/SyndraTest.php +++ b/tests/SyndraTest.php @@ -157,6 +157,20 @@ public function it_responds_with_internal_error() $this->assertEquals('{"error":{"message":"something","status_code":500}}', json_encode($response->getData())); } + /** @test */ + public function it_responds_with_not_implemented() + { + $response = $this->syndra->respondNotImplemented('something'); + + $this->assertInstanceOf('Illuminate\Http\JsonResponse', $response); + + $this->assertEquals(501, $response->getStatusCode()); + + $this->assertEquals([], $this->syndra->getHeaders()); + + $this->assertEquals('{"error":{"message":"something","status_code":501}}', json_encode($response->getData())); + } + /** @test */ public function it_responds_with_validation_error() {