public function ShortcutCacheTagsTest::testEntityCreation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Tests/ShortcutCacheTagsTest.php \Drupal\shortcut\Tests\ShortcutCacheTagsTest::testEntityCreation()
Tests that when creating a shortcut, the shortcut set tag is invalidated.
File
- core/
modules/ shortcut/ src/ Tests/ ShortcutCacheTagsTest.php, line 60 - Contains \Drupal\shortcut\Tests\ShortcutCacheTagsTest.
Class
- ShortcutCacheTagsTest
- Tests the Shortcut entity's cache tags.
Namespace
Drupal\shortcut\TestsCode
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', \Drupal\Core\Cache\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.');
}