public function ToolbarAdminMenuTest::testModuleStatusChangeSubtreesHashCacheClear in Drupal 10
Same name and namespace in other branches
- 8 core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::testModuleStatusChangeSubtreesHashCacheClear()
- 9 core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::testModuleStatusChangeSubtreesHashCacheClear()
Tests the toolbar_modules_installed() and toolbar_modules_uninstalled() hook implementations.
File
- core/
modules/ toolbar/ tests/ src/ Functional/ ToolbarAdminMenuTest.php, line 117
Class
- ToolbarAdminMenuTest
- Tests the caching of the admin menu subtree items.
Namespace
Drupal\Tests\toolbar\FunctionalCode
public function testModuleStatusChangeSubtreesHashCacheClear() {
// Use an admin role to ensure the user has all available permissions. This
// results in the admin menu links changing as the taxonomy module is
// installed and uninstalled because the role will always have the
// 'administer taxonomy' permission if it exists.
$role = Role::load($this
->createRole([]));
$role
->setIsAdmin(TRUE);
$role
->save();
$this->adminUser
->addRole($role
->id());
$this->adminUser
->save();
// Uninstall a module.
$edit = [];
$edit['uninstall[taxonomy]'] = TRUE;
$this
->drupalGet('admin/modules/uninstall');
$this
->submitForm($edit, 'Uninstall');
// Confirm the uninstall form.
$this
->submitForm([], 'Uninstall');
$this
->rebuildContainer();
// Assert that the subtrees hash has been altered because the subtrees
// structure changed.
$this
->assertDifferentHash();
// Enable a module.
$edit = [];
$edit['modules[taxonomy][enable]'] = TRUE;
$this
->drupalGet('admin/modules');
$this
->submitForm($edit, 'Install');
$this
->rebuildContainer();
// Assert that the subtrees hash has been altered because the subtrees
// structure changed.
$this
->assertDifferentHash();
}