function RestfulExceptionHandleTestCase::testEntityNotFoundDelivery in RESTful 7
Same name and namespace in other branches
- 7.2 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 44 - Contains RestfulExceptionHandleTestCase
Class
- RestfulExceptionHandleTestCase
- @file Contains RestfulExceptionHandleTestCase
Code
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;'), '"application/problem+json" found in invalid request.');
$this
->assertEqual($body['title'], 'The entity ID 1 for Articles does not exist.', 'Correct error message.');
}