Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2 from delatbabel/add-not-implemented
Browse files Browse the repository at this point in the history
add not implemented to base class
  • Loading branch information
Mario Bašić committed Dec 7, 2015
2 parents 9f8484f + 6145b35 commit f740a4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Syndra.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*
Expand Down
14 changes: 14 additions & 0 deletions tests/SyndraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit f740a4c

Please sign in to comment.