function EntityReferenceFormatterTest::testCustomCacheTagFormatter

Same name and namespace in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testCustomCacheTagFormatter()
  2. 10 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testCustomCacheTagFormatter()
  3. 11.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceFormatterTest::testCustomCacheTagFormatter()

Tests the merging of cache metadata.

File

core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php, line 173

Class

EntityReferenceFormatterTest
Tests the formatters functionality.

Namespace

Drupal\Tests\field\Kernel\EntityReference

Code

public function testCustomCacheTagFormatter() {
    
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container
        ->get('renderer');
    $formatter = 'entity_reference_custom_cache_tag';
    $build = $this->buildRenderArray([
        $this->referencedEntity,
    ], $formatter);
    $renderer->renderRoot($build);
    $this->assertContains('custom_cache_tag', $build['#cache']['tags']);
}

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