diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php index 68ed384c86..6bc8cc3abf 100644 --- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php +++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php @@ -51,7 +51,7 @@ public function testBasicAuth() { $this->assertText($account->getAccountName(), 'Account name is displayed.'); $this->assertSession()->statusCodeEquals(200); $this->mink->resetSessions(); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check that Cache-Control is not set to public. $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public'); @@ -85,7 +85,7 @@ public function testBasicAuth() { $this->drupalGet($url); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check that Cache-Control is not set to public. $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public'); } diff --git a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php index 5ff2651a95..d539a3babf 100644 --- a/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php +++ b/core/modules/dynamic_page_cache/tests/src/Functional/DynamicPageCacheIntegrationTest.php @@ -56,22 +56,31 @@ public function testDynamicPageCache() { // Cache. $url = Url::fromUri('route:dynamic_page_cache_test.response'); $this->drupalGet($url); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that response object is returned: Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); // Controllers returning CacheableResponseInterface (cacheable response) // objects are handled by Dynamic Page Cache. $url = Url::fromUri('route:dynamic_page_cache_test.cacheable_response'); $this->drupalGet($url); + // Verify that cacheable response object is returned: Dynamic Page Cache is active, + // Dynamic Page Cache MISS. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS'); $this->drupalGet($url); + // Verify that cacheable response object is returned: Dynamic Page Cache is active, + // Dynamic Page Cache HIT. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); // Controllers returning render arrays, rendered as HTML responses, are // handled by Dynamic Page Cache. $url = Url::fromUri('route:dynamic_page_cache_test.html'); $this->drupalGet($url); + // Verify that 'render array is returned, rendered as HTML response: + // Dynamic Page Cache is active, Dynamic Page Cache MISS. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS'); $this->drupalGet($url); + // Verify that 'render array is returned, rendered as HTML response: + // Dynamic Page Cache is active, Dynamic Page Cache HIT. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); // The above is the simple case, where the render array returned by the @@ -82,9 +91,13 @@ public function testDynamicPageCache() { $url = Url::fromUri('route:dynamic_page_cache_test.html.with_cache_contexts', ['query' => ['animal' => $animal]]); $this->drupalGet($url); $this->assertRaw($animal); + // Verify that 'render array is returned, rendered as HTML response: + // Dynamic Page Cache is active, Dynamic Page Cache MISS. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS'); $this->drupalGet($url); $this->assertRaw($animal); + // Verify that 'render array is returned, rendered as HTML response: + // Dynamic Page Cache is active, Dynamic Page Cache HIT. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); // Finally, let's also verify that the 'dynamic_page_cache_test.html' @@ -93,6 +106,8 @@ public function testDynamicPageCache() { // Cache hits. $url = Url::fromUri('route:dynamic_page_cache_test.html', ['query' => ['animal' => 'piglet']]); $this->drupalGet($url); + // Verify that 'render array is returned, rendered as HTML response: + // Dynamic Page Cache is active, Dynamic Page Cache HIT. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); } @@ -100,31 +115,48 @@ public function testDynamicPageCache() { // response, are ignored by Dynamic Page Cache (but only because those // wrapper formats' responses do not implement CacheableResponseInterface). $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a Render array is returned, rendered as AJAX response: + // Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']]); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a Render array is returned, rendered as drupal_dialog response: + // Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a Render array is returned, rendered as modal response: + // Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); // Admin routes are ignored by Dynamic Page Cache. $this->drupalGet('dynamic-page-cache-test/html/admin'); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a response is returned, rendered as HTML response, admin + // route: Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); $this->drupalGet('dynamic-page-cache-test/response/admin'); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a response is returned, plain response, admin route: Dynamic + // Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); $this->drupalGet('dynamic-page-cache-test/cacheable-response/admin'); - $this->assertNull($this->getSession()->getResponseHeader(DynamicPageCacheSubscriber::HEADER)); + // Verify that a response is returned, cacheable response, admin route: + // Dynamic Page Cache is ignoring. + $this->assertSession()->responseHeaderDoesNotExist(DynamicPageCacheSubscriber::HEADER); // Max-age = 0 responses are ignored by Dynamic Page Cache. $this->drupalGet('dynamic-page-cache-test/html/uncacheable/max-age'); + // Verify that a render array is returned, rendered as HTML response, + // but uncacheable: Dynamic Page Cache is running, but not caching. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE'); // 'user' cache context responses are ignored by Dynamic Page Cache. $this->drupalGet('dynamic-page-cache-test/html/uncacheable/contexts'); + // Verify that a render array is returned, rendered as HTML response, + // but uncacheable: Dynamic Page Cache is running, but not caching. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE'); // 'current-temperature' cache tag responses are ignored by Dynamic Page // Cache. $this->drupalGet('dynamic-page-cache-test/html/uncacheable/tags'); + // Verify that by default, Drupal has no auto-placeholdering cache tags. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS'); } diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php index 8cd0734852..503e41c0e6 100644 --- a/core/modules/file/tests/src/Functional/DownloadTest.php +++ b/core/modules/file/tests/src/Functional/DownloadTest.php @@ -75,7 +75,9 @@ protected function doPrivateFileTransferTest() { file_test_reset(); file_test_set_return('download', ['x-foo' => 'Bar']); $this->drupalGet($url); + // Verify that header is set by file_test module on private download. $this->assertSession()->responseHeaderEquals('x-foo', 'Bar'); + // Verify that page cache is disabled on private file download. $this->assertSession()->responseHeaderDoesNotExist('x-drupal-cache'); $this->assertSession()->statusCodeEquals(200); // Ensure hook_file_download is fired correctly. diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index 62b8a1c26b..147a79b847 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -141,6 +141,7 @@ public function _testImageFieldFormatters($scheme) { $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]); // @todo Remove in https://www.drupal.org/node/2646744. $this->assertCacheContext('url.site'); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); $this->assertRaw($default_output, 'Image linked to file formatter displaying correctly on full node view.'); // Verify that the image can be downloaded. @@ -171,7 +172,8 @@ public function _testImageFieldFormatters($scheme) { '#height' => 20, ]; $this->drupalGet('node/' . $nid); - $this->assertCacheTag($file->getCacheTags()[0]); + $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); $elements = $this->xpath( '//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]', @@ -366,6 +368,7 @@ public function testImageFieldDefaultImage() { // Verify that no image is displayed on the page by checking for the class // that would be used on the image field. $this->assertSession()->responseNotMatches('
', 'No image displayed when no image is attached and no default image specified.'); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); // Add a default image to the public image field. @@ -395,7 +398,8 @@ public function testImageFieldDefaultImage() { ]; $default_output = str_replace("\n", NULL, $renderer->renderRoot($image)); $this->drupalGet('node/' . $node->id()); - $this->assertCacheTag($file->getCacheTags()[0]); + $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); $this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.'); @@ -419,7 +423,8 @@ public function testImageFieldDefaultImage() { ]; $image_output = str_replace("\n", NULL, $renderer->renderRoot($image)); $this->drupalGet('node/' . $nid); - $this->assertCacheTag($file->getCacheTags()[0]); + $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); $this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.'); $this->assertRaw($image_output, 'User supplied image is displayed.'); @@ -469,7 +474,8 @@ public function testImageFieldDefaultImage() { ]; $default_output = str_replace("\n", NULL, $renderer->renderRoot($image)); $this->drupalGet('node/' . $node->id()); - $this->assertCacheTag($file->getCacheTags()[0]); + $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]); + // Verify that no image style cache tags are found. $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'image_style:'); $this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.'); } diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php index db3870a4e2..869cc4ade3 100644 --- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php +++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php @@ -84,32 +84,32 @@ public function testAcceptLanguageEmptyDefault() { $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en']); $this->assertSession()->responseHeaderEquals('Content-Language', 'en'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with UK browser. $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en-UK,en']); $this->assertSession()->responseHeaderEquals('Content-Language', 'en'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with french browser. $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'fr-FR,fr']); $this->assertSession()->responseHeaderEquals('Content-Language', 'fr'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with browser without language settings - should return fallback language. $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => NULL]); $this->assertSession()->responseHeaderEquals('Content-Language', 'en'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with french browser again. $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'fr-FR,fr']); $this->assertSession()->responseHeaderEquals('Content-Language', 'fr'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with UK browser. $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => 'en-UK,en']); $this->assertSession()->responseHeaderEquals('Content-Language', 'en'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check if prefixed URLs are still cached. $this->drupalGet('/en/system-test/echo/language test', [], ['Accept-Language' => 'en']); diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index 0d1a91865d..1732faa80a 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -131,14 +131,18 @@ public function testQueryParameterFormatRequests() { $accept_header_cache_url_with_json = Url::fromRoute('system_test.page_cache_accept_header', ['_format' => 'json']); $this->drupalGet($accept_header_cache_url); + // Verify that HTML page was not yet cached. $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); $this->drupalGet($accept_header_cache_url); + // Verify that HTML page was cached. $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); $this->assertRaw('

oh hai this is html.

', 'The correct HTML response was returned.'); $this->drupalGet($accept_header_cache_url_with_json); + // Verify that JSON response was not yet cached. $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); $this->drupalGet($accept_header_cache_url_with_json); + // Verify that JSON response was cached. $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); $this->assertRaw('{"content":"oh hai this is json"}', 'The correct Json response was returned.'); @@ -242,6 +246,7 @@ public function testConditionalRequests() { $this->drupalLogin($user); $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]); $this->assertSession()->statusCodeEquals(200); + // Verify that absence of Page was not cached. $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); } @@ -282,7 +287,7 @@ public function testPageCache() { $user = $this->drupalCreateUser(); $this->drupalLogin($user); $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); $this->assertSession()->responseHeaderNotContains('Vary', 'cookie'); $this->assertSession()->responseHeaderEquals('Cache-Control', 'must-revalidate, no-cache, private'); $this->assertSession()->responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT'); @@ -373,7 +378,7 @@ public function testPageCacheAnonymous403404() { $this->drupalGet($content_url); $this->assertSession()->statusCodeEquals($code); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); - $this->assertCacheTag('4xx-response'); + $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', '4xx-response'); $this->drupalGet($content_url); $this->assertSession()->statusCodeEquals($code); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); @@ -511,12 +516,12 @@ public function testCacheableResponseResponses() { // GET a URL, which would be marked as a cache miss if it were cacheable. $this->drupalGet('/system-test/respond-public-response'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=60, public'); // GET it again, verify it's still not cached. $this->drupalGet('/system-test/respond-public-response'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); $this->assertSession()->responseHeaderEquals('Cache-Control', 'max-age=60, public'); // GET a URL, which should be marked as a cache miss. diff --git a/core/modules/system/tests/src/Functional/Form/ResponseTest.php b/core/modules/system/tests/src/Functional/Form/ResponseTest.php index df42e9237c..c316a7625e 100644 --- a/core/modules/system/tests/src/Functional/Form/ResponseTest.php +++ b/core/modules/system/tests/src/Functional/Form/ResponseTest.php @@ -36,7 +36,9 @@ public function testFormResponse() { $content = Json::decode($this->getSession()->getPage()->getContent()); $this->assertSession()->statusCodeEquals(200); $this->assertIdentical($edit['content'], $content, 'Response content matches'); + // Verify that response was handled by kernel response subscriber. $this->assertSession()->responseHeaderEquals('X-Form-Test-Response-Event', 'invoked'); + // Verify that response was handled by kernel middleware. $this->assertSession()->responseHeaderEquals('X-Form-Test-Stack-Middleware', 'invoked'); $edit = [ @@ -47,7 +49,9 @@ public function testFormResponse() { $content = Json::decode($this->getSession()->getPage()->getContent()); $this->assertSession()->statusCodeEquals(418); $this->assertIdentical($edit['content'], $content, 'Response content matches'); + // Verify that response was handled by kernel response subscriber. $this->assertSession()->responseHeaderEquals('X-Form-Test-Response-Event', 'invoked'); + // Verify that response was handled by kernel middleware. $this->assertSession()->responseHeaderEquals('X-Form-Test-Stack-Middleware', 'invoked'); } diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index 1819c006fb..97f85ea24d 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -46,7 +46,7 @@ public function testFinishResponseSubscriber() { $this->assertEquals($headers['Content-language'], ['en']); $this->assertEquals($headers['X-Content-Type-Options'], ['nosniff']); $this->assertEquals($headers['X-Frame-Options'], ['SAMEORIGIN']); - $this->assertNull($this->getSession()->getResponseHeader('Vary')); + $this->assertSession()->responseHeaderDoesNotExist('Vary'); $this->drupalGet('router_test/test2'); $this->assertRaw('test2', 'The correct string was returned because the route was successful.'); diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php index 3fb08af1aa..4c8ca3c9c3 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php @@ -51,6 +51,7 @@ public function testSessionSaveRegenerate() { // Start a new session by setting a message. $this->drupalGet('session-test/set-message'); $this->assertSessionCookie(TRUE); + // Verify that the session cookie is set as HttpOnly. $this->assertSession()->responseHeaderMatches('Set-Cookie', '/HttpOnly/i'); // Verify that the session is regenerated if a module calls exit @@ -199,8 +200,10 @@ public function testEmptyAnonymousSession() { $this->drupalGet(''); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(FALSE); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + // Verify that caching was bypassed. + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); $this->assertText(t('This is a dummy message.'), 'Message was displayed.'); + // Verify that session cookie was deleted. $this->assertSession()->responseHeaderMatches('Set-Cookie', '/SESS\w+=deleted/'); // Verify that session was destroyed. @@ -210,7 +213,7 @@ public function testEmptyAnonymousSession() { // $this->assertSessionEmpty(TRUE); $this->assertNoText(t('This is a dummy message.'), 'Message was not cached.'); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); - $this->assertNull($this->getSession()->getResponseHeader('Set-Cookie')); + $this->assertSession()->responseHeaderDoesNotExist('Set-Cookie'); // Verify that no session is created if drupal_save_session(FALSE) is called. $this->drupalGet('session-test/set-message-but-do-not-save'); diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php index f87b058daf..6416a486a6 100644 --- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php @@ -143,7 +143,7 @@ public function testExceptionHandler() { ->save(); $this->drupalGet('error-test/trigger-exception'); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public'); $this->assertSession()->statusCodeEquals(500); $this->assertNoErrorMessage($error_exception); diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index bab17dcf2f..fe51266b8a 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -96,11 +96,11 @@ public function testUserPasswordReset() { // Ensure that the current url does not contain the hash and timestamp. $this->assertUrl(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()])); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Ensure the password reset URL is not cached. $this->drupalGet($resetURL); - $this->assertNull($this->getSession()->getResponseHeader('X-Drupal-Cache')); + $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check the one-time login page. $this->assertText($this->account->getAccountName(), 'One-time login page contains the correct username.'); diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php index 2dfab83053..20b3c1d600 100644 --- a/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -180,21 +180,26 @@ public function testStandard() { $this->drupalLogin($this->adminUser); $url = Url::fromRoute('contact.site_page'); $this->drupalGet($url); + // Verify that site-wide contact page cannot be cached by Dynamic Page + // Cache. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'UNCACHEABLE'); $url = Url::fromRoute(''); $this->drupalGet($url); $this->drupalGet($url); + // Verify that frontpage is cached by Dynamic Page Cache. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); $url = Url::fromRoute('entity.node.canonical', ['node' => 1]); $this->drupalGet($url); $this->drupalGet($url); + // Verify that full node page is cached by Dynamic Page Cache. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); $url = Url::fromRoute('entity.user.canonical', ['user' => 1]); $this->drupalGet($url); $this->drupalGet($url); + // Verify that user profile page is cached by Dynamic Page Cache. $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT'); // Make sure the editorial workflow is installed after enabling the