getCacheHeaderValues example


  protected function assertCacheTags(array $expected_tags$include_default_tags = TRUE) {
    // The anonymous role cache tag is only added if the user is anonymous.     if ($include_default_tags) {
      if (\Drupal::currentUser()->isAnonymous()) {
        $expected_tags = Cache::mergeTags($expected_tags['config:user.role.anonymous']);
      }
      $expected_tags[] = 'http_response';
    }
    $actual_tags = $this->getCacheHeaderValues('X-Drupal-Cache-Tags');
    $expected_tags = array_unique($expected_tags);
    sort($expected_tags);
    sort($actual_tags);
    $this->assertSame($expected_tags$actual_tags);
  }

  /** * Ensures that some cache contexts are present in the current response. * * @param string[] $expected_contexts * The expected cache contexts. * @param string $message * (optional) A verbose message to output. * @param bool $include_default_contexts * (optional) Whether the default contexts should automatically be included. * * @return bool * Always returns TRUE. */
Home | Imprint | This part of the site doesn't use cookies.