function RestfulHookMenuTestCase::testHttpHeadersAndStatus in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulHookMenuTestCase.test \RestfulHookMenuTestCase::testHttpHeadersAndStatus()
Test HTTP headers change according to the response.
File
- tests/
RestfulHookMenuTestCase.test, line 83 - Contains RestfulHookMenuTestCase
Class
- RestfulHookMenuTestCase
- @file Contains RestfulHookMenuTestCase
Code
function testHttpHeadersAndStatus() {
// Valid request (eventough it's empty).
$result = $this
->httpRequest('api/v1.0/articles/', \RestfulInterface::GET);
$this
->assertTrue(strpos($result['headers'], 'application/json;'), '"application/json" found in valid request.');
// Invalid request.
$result = $this
->httpRequest('api/v1.0/articles/', \RestfulInterface::GET, array(
'sort' => 'invalid_key',
));
$this
->assertTrue(strpos($result['headers'], 'application/problem+json;'), '"application/problem+json" found in valid request.');
// Switch site to offline mode.
variable_set('maintenance_mode', TRUE);
$this->httpauth_credentials = NULL;
$result = $this
->httpRequest('api/login');
$this
->assertEqual($result['code'], '503', '503 status code sent for site in offline mode.');
}