function PageCacheTest::testCacheabilityOfRedirectResponses
Same name in other branches
- 11.x core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testCacheabilityOfRedirectResponses()
Tests that the Cache-Control header is added by FinishResponseSubscriber.
1 call to PageCacheTest::testCacheabilityOfRedirectResponses()
- PageCacheTest::testPageCache in core/
modules/ page_cache/ tests/ src/ Functional/ PageCacheTest.php - Tests page caching.
File
-
core/
modules/ page_cache/ tests/ src/ Functional/ PageCacheTest.php, line 582
Class
- PageCacheTest
- Enables the page cache and tests it with various HTTP requests.
Namespace
Drupal\Tests\page_cache\FunctionalCode
protected function testCacheabilityOfRedirectResponses() : void {
$this->enablePageCaching();
$this->getSession()
->getDriver()
->getClient()
->followRedirects(FALSE);
$this->maximumMetaRefreshCount = 0;
foreach ([
301,
302,
303,
307,
308,
] as $status_code) {
foreach ([
'local',
'cacheable',
'trusted',
] as $type) {
$this->drupalGet("/system-test/redirect/{$type}/{$status_code}");
$this->assertSession()
->statusCodeEquals($status_code);
$this->assertCacheMaxAge(300);
}
}
$this->getSession()
->getDriver()
->getClient()
->followRedirects(TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.