diff -u b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php --- b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -583,46 +583,31 @@ foreach ($tests as list($url_raw, $url_normalized)) { // Initialize cache on raw URL. - $this->assertResponseHeader('X-Drupal-Cache', 'MISS', $url_raw); + $headers = $this->getHeaders($url_raw); + $this->assertEquals('MISS', $headers['X-Drupal-Cache']); + // Ensure cache was set. - $this->assertResponseHeader('X-Drupal-Cache', 'HIT', $url_raw, "Cache was set for {$url_raw} URL."); + $headers = $this->getHeaders($url_raw); + $this->assertEquals('HIT', $headers['X-Drupal-Cache'], "Cache was set for {$url_raw} URL."); + // Check if the normalized URL is not cached. - $this->assertResponseHeader('X-Drupal-Cache', 'MISS', $url_normalized, "Cache is missing for {$url_normalized} URL."); + $headers = $this->getHeaders($url_normalized); + $this->assertEquals('MISS', $headers['X-Drupal-Cache'], "Cache is missing for {$url_normalized} URL."); } } /** - * Asserts that the response header has the expected value. - * - * @param string $header - * Header name. - * @param string $expected - * Expected value of the header. - * @param string $url - * The url to test. - * @param string $message - * (optional) A message to display with the assertion. - */ - protected function assertResponseHeader($header, $expected, $url, $message = '') { - $headers = $this->getHeaders($url); - $this->assertSame($expected, $headers[$header], $message); - } - - /** * Retrieves only the headers for an absolute path. * - * This is a simplified re-implementation of a drupalHead() that - * executes a cURL request without any URL modifications (Guzzle always - * normalizes URLs and therefore doesn't allow to test all possible edge - * cases). + * Executes a cURL request without any modifications to the given URL. + * Note that the Guzzle always normalizes URLs which prevents testing all + * possible edge cases. * * @param string $url * The URL to load into internal browser. * * @return array * Array of headers. - * - * @see \Drupal\simpletest\WebTestBase::drupalHead() */ protected function getHeaders($url) { $ch = curl_init();