function ToolbarCacheContextsTest::testToolbarCacheContextsCaller
Same name in other branches
- 9 core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php \Drupal\Tests\toolbar\Functional\ToolbarCacheContextsTest::testToolbarCacheContextsCaller()
- 8.9.x core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php \Drupal\Tests\toolbar\Functional\ToolbarCacheContextsTest::testToolbarCacheContextsCaller()
- 11.x core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php \Drupal\Tests\toolbar\Functional\ToolbarCacheContextsTest::testToolbarCacheContextsCaller()
Tests toolbar cache contexts.
File
-
core/
modules/ toolbar/ tests/ src/ Functional/ ToolbarCacheContextsTest.php, line 83
Class
- ToolbarCacheContextsTest
- Tests the cache contexts for toolbar.
Namespace
Drupal\Tests\toolbar\FunctionalCode
public function testToolbarCacheContextsCaller() : void {
// Test with default combination and permission to see toolbar.
$this->assertToolbarCacheContexts([
'user',
'session',
], 'Expected cache contexts found for default combination and permission to see toolbar.');
// Test without user toolbar tab. User module is a required module so we have to
// manually remove the user toolbar tab.
$this->installExtraModules([
'toolbar_disable_user_toolbar',
]);
$this->assertToolbarCacheContexts([
'user.permissions',
], 'Expected cache contexts found without user toolbar tab.');
// Test with the toolbar and contextual enabled.
$this->installExtraModules([
'contextual',
]);
$this->adminUser2 = $this->drupalCreateUser(array_merge($this->perms, [
'access contextual links',
]));
$this->assertToolbarCacheContexts([
'user.permissions',
], 'Expected cache contexts found with contextual module enabled.');
\Drupal::service('module_installer')->uninstall([
'contextual',
]);
// Test with the comment module enabled.
$this->installExtraModules([
'comment',
]);
$this->adminUser2 = $this->drupalCreateUser(array_merge($this->perms, [
'access comments',
]));
$this->assertToolbarCacheContexts([
'user.permissions',
], 'Expected cache contexts found with comment module enabled.');
\Drupal::service('module_installer')->uninstall([
'comment',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.