public function ToolbarCacheContextsTest::testToolbarCacheContextsCaller in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php \Drupal\toolbar\Tests\ToolbarCacheContextsTest::testToolbarCacheContextsCaller()
Tests toolbar cache contexts.
File
- core/
modules/ toolbar/ src/ Tests/ ToolbarCacheContextsTest.php, line 70 - Contains \Drupal\toolbar\Tests\ToolbarCacheContextsTest.
Class
- ToolbarCacheContextsTest
- Tests the cache contexts for toolbar.
Namespace
Drupal\toolbar\TestsCode
public function testToolbarCacheContextsCaller() {
// Test with default combination and permission to see toolbar.
$this
->assertToolbarCacheContexts([
'user',
], '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 tour module enabled.
$this
->installExtraModules([
'tour',
]);
$this->adminUser2 = $this
->drupalCreateUser(array_merge($this->perms, [
'access tour',
]));
$this
->assertToolbarCacheContexts([
'user.permissions',
], 'Expected cache contexts found with tour module enabled.');
\Drupal::service('module_installer')
->uninstall([
'tour',
]);
// Test with shortcut module enabled.
$this
->installExtraModules([
'shortcut',
]);
$this->adminUser2 = $this
->drupalCreateUser(array_merge($this->perms, [
'access shortcuts',
'administer shortcuts',
]));
$this
->assertToolbarCacheContexts([
'user',
], 'Expected cache contexts found with shortcut module enabled.');
}