1 module.test | ModuleUninstallTestCase::testUserPermsUninstalled() |
Tests the hook_modules_uninstalled() of the user module.
File
- core/
modules/ simpletest/ tests/ module.test, line 289 - Tests for the module API.
Class
- ModuleUninstallTestCase
- Unit tests for module uninstallation and related hooks.
Code
function testUserPermsUninstalled() {
// Grant the test permission to the authenticate user role.
user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, array('module_test perm'));
$role = user_role_load(BACKDROP_AUTHENTICATED_ROLE);
$this->assertTrue(in_array('module_test perm', $role->permissions), 'Test module permission enabled.');
// Uninstalls the module_test module, so hook_modules_uninstalled()
// is executed.
module_disable(array('module_test'));
backdrop_uninstall_modules(array('module_test'));
// Check the perms defined by module_test are removed from the role.
$role = user_role_load(BACKDROP_AUTHENTICATED_ROLE);
$this->assertFalse(in_array('module_test perm', $role->permissions), 'Test module permission removed upon uninstall.');
}