/**
* Tests cache headers.
*/
public function testPageCache() { $config =
$this->
config('system.performance'
);
$config->
set('cache.page.max_age', 300
);
$config->
save();
// Fill the cache.
$this->
drupalGet('system-test/set-header',
['query' =>
['name' => 'Foo', 'value' => 'bar'
]]);
$this->
assertSession()->
responseHeaderEquals('X-Drupal-Cache', 'MISS'
);
$this->
assertSession()->
responseHeaderContains('Vary', 'cookie'
);
// Symfony's Response logic determines a specific order for the subvalues
// of the Cache-Control header, even if they are explicitly passed in to
// the response header bag in a different order.
$this->
assertSession()->
responseHeaderEquals('Cache-Control', 'max-age=300, public'
);
$this->
assertSession()->
responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT'
);
$this->
assertSession()->
responseHeaderEquals('Foo', 'bar'
);
// Check cache.
$this->
drupalGet('system-test/set-header',
['query' =>
['name' => 'Foo', 'value' => 'bar'
]]);
$this->
assertSession()->
responseHeaderEquals('X-Drupal-Cache', 'HIT'
);
$this->
assertSession()->
responseHeaderContains('Vary', 'cookie'
);