function BootstrapPageCacheTestCase::testPageCacheHeaders
Test page cache headers.
File
-
modules/
simpletest/ tests/ bootstrap.test, line 266
Class
Code
function testPageCacheHeaders() {
variable_set('cache', 1);
// First request should store a response in the page cache.
$this->drupalGet('system-test/page-cache-headers');
// The test callback should remove the query string leaving the same path
// as the previous request, which we'll try to retrieve from cache_page.
$this->drupalGet('system-test/page-cache-headers', array(
'query' => array(
'return_headers' => 'TRUE',
),
));
$headers = json_decode($this->drupalGetHeader('Page-Cache-Headers'), TRUE);
if (is_null($headers)) {
$this->fail('No headers were retrieved from the page cache.');
}
else {
$this->assertEqual($headers['X-Content-Type-Options'], 'nosniff', 'X-Content-Type-Options header retrieved from response in the page cache.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.