function KernelTestHttpDynamicCacheRequestTest::testRequestAuthenticated
Tests a request is cached and retrieved.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestHttpDynamicCacheRequestTest.php, line 49
Class
- KernelTestHttpDynamicCacheRequestTest
- Tests making HTTP requests with dynamic page cache in a kernel test.
Namespace
Drupal\KernelTestsCode
public function testRequestAuthenticated() : void {
$this->setUpCurrentUser();
$this->drupalGet('/system-test/main-content-handling');
$this->assertEquals(Response::HTTP_OK, $this->getSession()
->getStatusCode());
$this->assertSession()
->pageTextContains('Content to test main content fallback');
$this->assertEquals('MISS', $this->getSession()
->getResponseHeaders()['x-drupal-dynamic-cache'][0]);
$this->drupalGet('/system-test/main-content-handling');
$this->assertEquals(Response::HTTP_OK, $this->getSession()
->getStatusCode());
$this->assertSession()
->pageTextContains('Content to test main content fallback');
$this->assertEquals('HIT', $this->getSession()
->getResponseHeaders()['x-drupal-dynamic-cache'][0]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.