You are here

public function RestfulExceptionHandleTestCase::testEntityNotFoundDelivery in RESTful 7.2

Same name and namespace in other branches
  1. 7 tests/RestfulExceptionHandleTestCase.test \RestfulExceptionHandleTestCase::testEntityNotFoundDelivery()

Test when an entity is not found that a 4XX is returned instead of 500.

File

tests/RestfulExceptionHandleTestCase.test, line 53
Contains RestfulExceptionHandleTestCase.

Class

RestfulExceptionHandleTestCase
Class RestfulExceptionHandleTestCase.

Code

public function testEntityNotFoundDelivery() {
  $url = 'api/v1.0/articles/1';
  $result = $this
    ->httpRequest($url);
  $body = drupal_json_decode($result['body']);
  $this
    ->assertEqual($result['code'], '422', format_string('422 status code sent for @url url.', array(
    '@url' => $url,
  )));
  $this
    ->assertTrue(strpos($result['headers'], 'application/problem+json;') !== FALSE, '"application/problem+json" found in invalid request.');
  $this
    ->assertEqual($body['title'], 'The entity ID 1 does not exist.', 'Correct error message.');
}