Commit f5c6bf01 authored by catch's avatar catch
Browse files

Issue #3132887 by mondrake, longwave, anmolgoyal74, kishor_kolekar: Deprecate...

Issue #3132887 by mondrake, longwave, anmolgoyal74, kishor_kolekar: Deprecate BrowserTestBase::drupalGetHeader()
parent 20895bdc
Loading
Loading
Loading
Loading
+2 −2
Changes for core/modules/big_pipe/tests/src/Functional/BigPipeTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ protected function assertBigPipeResponseHeadersPresent() {
   *   markup.
   */
  protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders) {
    $this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->drupalGetHeader('BigPipe-Test-No-Js-Placeholders'))));
    $this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->getSession()->getResponseHeader('BigPipe-Test-No-Js-Placeholders'))));
    foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
      // Checking whether the replacement for the BigPipe no-JS placeholder
      // $big_pipe_nojs_placeholder is present.
@@ -362,7 +362,7 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
   *   defined in the order that they are expected to be rendered & streamed.
   */
  protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order) {
    $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->drupalGetHeader('BigPipe-Test-Placeholders')));
    $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->getSession()->getResponseHeader('BigPipe-Test-Placeholders')));
    $placeholder_positions = [];
    $placeholder_replacement_positions = [];
    foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
+1 −1
Changes for core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ protected function verifyPageCacheContainsTags(Url $url, $hit_or_miss, $tags = F
    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', $hit_or_miss);

    if ($hit_or_miss === 'HIT' && is_array($tags)) {
      $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
      $cache_tags = explode(' ', $this->getSession()->getResponseHeader('X-Drupal-Cache-Tags'));
      $tags = array_unique($tags);
      $this->assertEmpty(array_diff($tags, $cache_tags), 'Page cache tags contains all expected tags.');
    }
+2 −2
Changes for core/modules/page_cache/tests/src/Functional/PageCacheTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -204,8 +204,8 @@ public function testConditionalRequests() {

    $this->drupalGet('');
    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
    $etag = $this->drupalGetHeader('ETag');
    $last_modified = $this->drupalGetHeader('Last-Modified');
    $etag = $this->getSession()->getResponseHeader('ETag');
    $last_modified = $this->getSession()->getResponseHeader('Last-Modified');

    // Ensure a conditional request returns 304 Not Modified.
    $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]);
+4 −9
Changes for core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php: 4 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -31,13 +31,8 @@ protected function enablePageCaching() {
   *   The header value, potentially exploded by spaces.
   */
  protected function getCacheHeaderValues($header_name) {
    $header_value = $this->drupalGetHeader($header_name);
    if (empty($header_value)) {
      return [];
    }
    else {
      return explode(' ', $header_value);
    }
    $header_value = $this->getSession()->getResponseHeader($header_name);
    return empty($header_value) ? [] : explode(' ', $header_value);
  }

  /**
@@ -47,7 +42,7 @@ protected function getCacheHeaderValues($header_name) {
   *   The expected cache context.
   */
  protected function assertCacheContext($expected_cache_context) {
    $cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
    $cache_contexts = explode(' ', $this->getSession()->getResponseHeader('X-Drupal-Cache-Contexts'));
    $this->assertContains($expected_cache_context, $cache_contexts, "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
  }

@@ -58,7 +53,7 @@ protected function assertCacheContext($expected_cache_context) {
   *   The expected cache context.
   */
  protected function assertNoCacheContext($not_expected_cache_context) {
    $cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
    $cache_contexts = explode(' ', $this->getSession()->getResponseHeader('X-Drupal-Cache-Contexts'));
    $this->assertNotContains($not_expected_cache_context, $cache_contexts, "'" . $not_expected_cache_context . "' is not present in the X-Drupal-Cache-Contexts header.");
  }

+2 −2
Changes for core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ public function testReferencedEntity() {
    // Verify a cache hit, but also the presence of the correct cache tags.
    $this->verifyPageCache($empty_entity_listing_url, 'HIT', $empty_entity_listing_cache_tags);
    // Verify the entity type's list cache contexts are present.
    $contexts_in_header = $this->drupalGetHeader('X-Drupal-Cache-Contexts');
    $contexts_in_header = $this->getSession()->getResponseHeader('X-Drupal-Cache-Contexts');
    $this->assertEqual(Cache::mergeContexts($page_cache_contexts, $this->getAdditionalCacheContextsForEntityListing()), empty($contexts_in_header) ? [] : explode(' ', $contexts_in_header));

    // Prime the page cache for the listing containing the referenced entity.
@@ -434,7 +434,7 @@ public function testReferencedEntity() {
    // Verify a cache hit, but also the presence of the correct cache tags.
    $this->verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags);
    // Verify the entity type's list cache contexts are present.
    $contexts_in_header = $this->drupalGetHeader('X-Drupal-Cache-Contexts');
    $contexts_in_header = $this->getSession()->getResponseHeader('X-Drupal-Cache-Contexts');
    $this->assertEqual(Cache::mergeContexts($page_cache_contexts, $this->getAdditionalCacheContextsForEntityListing()), empty($contexts_in_header) ? [] : explode(' ', $contexts_in_header));

    // Verify that after modifying the referenced entity, there is a cache miss
Loading