public function RestfulHookMenuTestCase::testHttpHeadersAndStatus in RESTful 7.2
Same name and namespace in other branches
- 7 tests/RestfulHookMenuTestCase.test \RestfulHookMenuTestCase::testHttpHeadersAndStatus()
Test HTTP headers change according to the response.
File
- tests/
RestfulHookMenuTestCase.test, line 93 - Contains \RestfulHookMenuTestCase.
Class
Code
public function testHttpHeadersAndStatus() {
// Valid request (even though it's empty).
$result = $this
->httpRequest('api/v1.0/articles/', RequestInterface::METHOD_GET);
$this
->assertTrue(strpos($result['headers'], 'application/json;'), '"application/json" found in valid request.');
// Invalid request.
$result = $this
->httpRequest('api/v1.0/articles/invalid_id', RequestInterface::METHOD_GET);
$this
->assertTrue(strpos($result['headers'], 'application/problem+json;') !== FALSE, '"application/problem+json" found in invalid 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.');
}