function KernelTestHttpCacheRequestTest::testRequestAnonymous
Tests a request is cached and retrieved.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestHttpCacheRequestTest.php, line 48
Class
- KernelTestHttpCacheRequestTest
- Tests making HTTP requests with page cache in a kernel test.
Namespace
Drupal\KernelTestsCode
public function testRequestAnonymous() : void {
// Test the page cache by making request without a current user.
$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-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-cache'][0]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.