Skip to content
Snippets Groups Projects

Issue #3187770: Views Rendered Entity field adding unneeded entity display cache tags

1 file
+ 52
3
Compare changes
  • Side-by-side
  • Inline
@@ -65,6 +65,53 @@ protected function setUpFixtures() {
]);
$display->save();
// Cache tags for default display for entity_test bundle should not be
// included in rendered view cacheable metadata, because the foobar view d
// display for entity_test bundle exists.
$display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'label' => 'Default view mode',
'status' => TRUE,
]);
$display->save();
// Create entity display that is not configured to be used by the rendered
// entity plugin. The entity view display cache tags should not be included
// in the rendered view cacheable metadata.
EntityViewMode::create([
'id' => 'entity_test.unused',
'targetEntityType' => 'entity_test',
'status' => TRUE,
'enabled' => TRUE,
'label' => 'Unused view mode',
])->save();
$display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'unused',
'label' => 'Unused view mode display',
'status' => TRUE,
]);
$display->save();
// Create a separate entity bundle for entity_test entities and a default
// entity view display for the bundle. The cache tags for the view display
// should be included in the rendered view cacheable metadata because the
// foobar entity view display does not exist for this bundle.
entity_test_create_bundle('unused', 'Unused bundle');
$display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'unused',
'mode' => 'default',
'label' => 'Default display for unused bundle',
'status' => TRUE,
]);
$display->save();
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_field',
'entity_type' => 'entity_test',
@@ -84,6 +131,7 @@ protected function setUpFixtures() {
EntityTest::create([
'name' => "Article title $i",
'test_field' => "Test $i",
'type' => 'entity_test',
])->save();
}
@@ -131,8 +179,9 @@ public function testRenderedEntityWithoutField() {
* The render array
*/
protected function assertCacheabilityMetadata($build) {
$this->assertEqual([
$this->assertEquals([
'config:core.entity_view_display.entity_test.entity_test.foobar',
'config:core.entity_view_display.entity_test.unused.default',
'config:views.view.test_field_entity_test_rendered',
'entity_test:1',
'entity_test:2',
@@ -141,7 +190,7 @@ protected function assertCacheabilityMetadata($build) {
'entity_test_view',
], $build['#cache']['tags']);
$this->assertEqual([
$this->assertEquals([
'entity_test_view_grants',
'languages:language_interface',
'theme',
@@ -157,7 +206,7 @@ protected function assertCacheabilityMetadata($build) {
*/
protected function assertConfigDependencies(View $storage) {
$storage->calculateDependencies();
$this->assertEqual([
$this->assertEquals([
'config' => ['core.entity_view_mode.entity_test.foobar'],
'module' => ['entity_test'],
], $storage->getDependencies());
Loading