function FieldRenderedEntityTest::assertCacheabilityMetadata

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::assertCacheabilityMetadata()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::assertCacheabilityMetadata()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::assertCacheabilityMetadata()

Ensures that the expected cacheability metadata is applied.

@internal

Parameters

array $build: The render array

2 calls to FieldRenderedEntityTest::assertCacheabilityMetadata()
FieldRenderedEntityTest::testRenderedEntityWithField in core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php
Tests the rendered entity output with the test field configured to show.
FieldRenderedEntityTest::testRenderedEntityWithoutField in core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php
Tests the default rendered entity output.

File

core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php, line 148

Class

FieldRenderedEntityTest
Tests the core Drupal\views\Plugin\views\field\RenderedEntity handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function assertCacheabilityMetadata(array $build) : void {
    $this->assertEqualsCanonicalizing([
        'config:core.entity_view_display.entity_test.entity_test.foobar',
        'config:views.view.test_field_entity_test_rendered',
        'entity_test:1',
        'entity_test:2',
        'entity_test:3',
        'entity_test_list',
        'entity_test_view',
    ], $build['#cache']['tags']);
    $this->assertEqualsCanonicalizing([
        'entity_test_view_grants',
        'languages:language_interface',
        'theme',
        'url.query_args',
        'user.permissions',
    ], $build['#cache']['contexts']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.