function EntityCacheTagsTestBase::setUp
Same name in other branches
- 8.9.x core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::setUp()
- 8.9.x core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::setUp()
- 10 core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::setUp()
- 11.x core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php \Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase::setUp()
Overrides PageCacheTagsTestBase::setUp
6 calls to EntityCacheTagsTestBase::setUp()
- CommentCacheTagsTest::setUp in core/
modules/ comment/ tests/ src/ Functional/ CommentCacheTagsTest.php - FeedCacheTagsTest::setUp in core/
modules/ aggregator/ tests/ src/ Functional/ FeedCacheTagsTest.php - ItemCacheTagsTest::setUp in core/
modules/ aggregator/ tests/ src/ Functional/ ItemCacheTagsTest.php - MediaCacheTagsTest::setUp in core/
modules/ media/ tests/ src/ Functional/ MediaCacheTagsTest.php - ShortcutCacheTagsTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutCacheTagsTest.php
6 methods override EntityCacheTagsTestBase::setUp()
- CommentCacheTagsTest::setUp in core/
modules/ comment/ tests/ src/ Functional/ CommentCacheTagsTest.php - FeedCacheTagsTest::setUp in core/
modules/ aggregator/ tests/ src/ Functional/ FeedCacheTagsTest.php - ItemCacheTagsTest::setUp in core/
modules/ aggregator/ tests/ src/ Functional/ ItemCacheTagsTest.php - MediaCacheTagsTest::setUp in core/
modules/ media/ tests/ src/ Functional/ MediaCacheTagsTest.php - ShortcutCacheTagsTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutCacheTagsTest.php
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityCacheTagsTestBase.php, line 53
Class
- EntityCacheTagsTestBase
- Provides helper methods for Entity cache tags tests.
Namespace
Drupal\Tests\system\Functional\EntityCode
protected function setUp() {
parent::setUp();
// Give anonymous users permission to view test entities, so that we can
// verify the cache tags of cached versions of test entity pages.
$user_role = Role::load(RoleInterface::ANONYMOUS_ID);
$user_role->grantPermission('view test entity');
$user_role->save();
// Create an entity.
$this->entity = $this->createEntity();
// If this is an entity with field UI enabled, then add a configurable
// field. We will use this configurable field in later tests to ensure that
// field configuration invalidate render cache entries.
if ($this->entity
->getEntityType()
->get('field_ui_base_route')) {
// Add field, so we can modify the field storage and field entities to
// verify that changes to those indeed clear cache tags.
FieldStorageConfig::create([
'field_name' => 'configurable_field',
'entity_type' => $this->entity
->getEntityTypeId(),
'type' => 'test_field',
'settings' => [],
])
->save();
FieldConfig::create([
'entity_type' => $this->entity
->getEntityTypeId(),
'bundle' => $this->entity
->bundle(),
'field_name' => 'configurable_field',
'label' => 'Configurable field',
'settings' => [],
])
->save();
// Reload the entity now that a new field has been added to it.
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entity
->getEntityTypeId());
$storage->resetCache();
$this->entity = $storage->load($this->entity
->id());
}
// Create a referencing and a non-referencing entity.
[
$this->referencingEntity,
$this->nonReferencingEntity,
] = $this->createReferenceTestEntities($this->entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.