function ShortcutCacheTagsTest::testEntityCreation
Same name in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php \Drupal\Tests\shortcut\Functional\ShortcutCacheTagsTest::testEntityCreation()
- 10 core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php \Drupal\Tests\shortcut\Functional\ShortcutCacheTagsTest::testEntityCreation()
- 11.x core/modules/shortcut/tests/src/Kernel/ShortcutCacheTagsTest.php \Drupal\Tests\shortcut\Kernel\ShortcutCacheTagsTest::testEntityCreation()
Tests that when creating a shortcut, the shortcut set tag is invalidated.
File
-
core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutCacheTagsTest.php, line 64
Class
- ShortcutCacheTagsTest
- Tests the Shortcut entity's cache tags.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testEntityCreation() {
// Create a cache entry that is tagged with a shortcut set cache tag.
$cache_tags = [
'config:shortcut.set.default',
];
\Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $cache_tags);
// Verify a cache hit.
$this->verifyRenderCache('foo', $cache_tags);
// Now create a shortcut entity in that shortcut set.
$this->createEntity();
// Verify a cache miss.
$this->assertFalse(\Drupal::cache('render')->get('foo'), 'Creating a new shortcut invalidates the cache tag of the shortcut set.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.