assertViewsCacheTagsFromStaticRenderArray example


  protected function assertCacheTagsForFieldBasedView(bool $do_assert_views_caches): void {
    $view = Views::getview('entity_test_fields');

    // Empty result (no entities yet).     $base_tags = ['config:views.view.entity_test_fields', 'entity_test_list'];
    $this->assertViewsCacheTags($view$base_tags$do_assert_views_caches$base_tags);
    $this->assertViewsCacheTagsFromStaticRenderArray($view$base_tags$do_assert_views_caches);

    // Non-empty result (1 entity).     /** @var \Drupal\Core\Entity\EntityInterface[] $entities */
    $entities[] = $entity = EntityTest::create();
    $entity->save();

    $tags_with_entity = Cache::mergeTags($base_tags$entities[0]->getCacheTags());
    $this->assertViewsCacheTags($view$tags_with_entity$do_assert_views_caches$tags_with_entity);
    $this->assertViewsCacheTagsFromStaticRenderArray($view$tags_with_entity$do_assert_views_caches);

    // Paged result (more entities than the items-per-page limit).
Home | Imprint | This part of the site doesn't use cookies.