Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295277

EntityCacheTagsTestBase doesn't allow a module to interact with page tags and test entity cache tags at the same time

$
0
0

Problem/Motivation

While investigating #2914110 I came to the realization that EntityCacheTagsTestBase::testReferencedEntity() is very complicated and sort of breaks shortcuts ability to use the class for its test.

There is a lot going on in this test. Cache::mergeContexts for days but you don't really need to understand those if we look very closely at the code failing for shortcut.module to get to the root of the problem.

$this->verifyPageCache($referencing_entity_url, 'HIT', $expected_tags);

Two pieces of context, first $referencing_entity_url = $this->referencingEntity->toUrl('canonical');
Additional $this->referencingEntity is a \Drupal\entity_test\Entity\EntityTest that in setUp dynamically creates a reference and stores a reference the entity being tested. In this case a shortcut entity.

So now the assertion, verifyPageCache(), makes a request to the canonical url and checks the cache tags on the full page render. It seems the logic being tested is that the tags from the reference entity are bubbled up as part of the entity and those should bubble all the way to the full page. Kinda ugly but you can sort of follow it.

The complexity of testing the _entire_ render process instead of just the entity cache tag reference logic directly is what's causing the problem though. By varying the cache tags through the page_title on every page we're changing the base cache tags for every page. That breaks this assertion(and dozens of later assertions) because the test can't handle that and assumes all pages will have the same base set of tags. Any interaction with that from a module breaks the test.

Proposed resolution

?

Remaining tasks

?

User interface changes

n/a

API changes

?

Data model changes

n/a

Release notes snippet

?


Viewing all articles
Browse latest Browse all 295277

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>