public function ApeTest::testApeHeaders in Advanced Page Expiration 8
File
- src/Tests/ApeTest.php, line 56
- Contains \Drupal\ape\Tests\ApeTest.
Class
- ApeTest
- Test cache-control header is set correctly after configuration.
Namespace
Drupal\ape\Tests
Code
public function testApeHeaders() {
$this
->drupalGet('user/register');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'max-age=2592000, public', 'Global Cache-Control header set.');
$this
->drupalGet('/ape_alternative');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'max-age=60, public', 'Alternative Cache-Control header set.');
$this
->drupalGet('/ape_exclude');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Page successfully excluded from caching.');
$user = $this
->drupalCreateUser();
$this
->drupalLogin($user);
$this
->drupalGet('user');
$this
->assertNull($this
->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Cache-Control header was sent.');
$this
->drupalLogout();
$this
->drupalGet('admin/structure');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, private', 'Forbidden page was not cached.');
$this
->drupalGet('notfindingthat');
$this
->assertEqual($this
->drupalGetHeader('Cache-Control'), 'max-age=3600, public', '404 Page Not Found Cache-Control header set.');
}