getDefaultCacheContexts example


  public function testEntityUri() {
    $entity_url = $this->entity->toUrl();
    $entity_type = $this->entity->getEntityTypeId();

    // Selects the view mode that will be used.     $view_mode = $this->selectViewMode($entity_type);

    // The default cache contexts for rendered entities.     $entity_cache_contexts = $this->getDefaultCacheContexts();

    // Generate the standardized entity cache tags.     $cache_tag = $this->entity->getCacheTags();
    $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type)->getCacheTags();
    $render_cache_tag = 'rendered';

    $this->verifyPageCache($entity_url, 'MISS');

    // Verify a cache hit, but also the presence of the correct cache tags.     $this->verifyPageCache($entity_url, 'HIT');

    
Home | Imprint | This part of the site doesn't use cookies.