diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/module.test | 30 | ||||
-rw-r--r-- | modules/simpletest/tests/module_test.info | 8 | ||||
-rw-r--r-- | modules/simpletest/tests/module_test.module | 11 | ||||
-rw-r--r-- | modules/system/system.test | 6 | ||||
-rw-r--r-- | modules/user/user.admin.inc | 15 |
5 files changed, 70 insertions, 0 deletions
diff --git a/modules/simpletest/tests/module.test b/modules/simpletest/tests/module.test index 9d3673673..da12b5504 100644 --- a/modules/simpletest/tests/module.test +++ b/modules/simpletest/tests/module.test @@ -77,3 +77,33 @@ class ModuleUnitTest extends DrupalWebTestCase { $this->assertIdentical($expected_values, module_list(FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition))); } } + +/** + * Unit tests for module uninstallation and related hooks. + */ +class ModuleUninstallTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => t('Module uninstallation'), + 'description' => t('Checks module uninstallation'), + 'group' => t('Module'), + ); + } + + function setUp() { + parent::setUp('module_test', 'user'); + } + + /** + * Tests the hook_modules_uninstalled() of the user module. + */ + function testUserPermsUninstalled() { + // Uninstalls the module_test module, so hook_modules_uninstalled() + // is executed. + drupal_uninstall_modules(array('module_test')); + + // Are the perms defined by module_test removed from {role_permission}. + $count = db_query("SELECT COUNT(rid) FROM {role_permission} WHERE permission = :perm", array(':perm' => 'module_test perm'))->fetchField(); + $this->assertEqual(0, $count, t('Permissions were all removed.')); + } +} diff --git a/modules/simpletest/tests/module_test.info b/modules/simpletest/tests/module_test.info new file mode 100644 index 000000000..09a2afa67 --- /dev/null +++ b/modules/simpletest/tests/module_test.info @@ -0,0 +1,8 @@ +; $Id$ +name = "Module test" +description = "Support module for module system testing." +package = Testing +version = VERSION +core = 7.x +files[] = module_test.module +hidden = TRUE diff --git a/modules/simpletest/tests/module_test.module b/modules/simpletest/tests/module_test.module new file mode 100644 index 000000000..33dd979c1 --- /dev/null +++ b/modules/simpletest/tests/module_test.module @@ -0,0 +1,11 @@ +<?php +// $Id$ + +/** + * Implement hook_perm(). + */ +function module_test_perm() { + return array( + 'module_test perm' => t('example perm for module_test module'), + ); +} diff --git a/modules/system/system.test b/modules/system/system.test index b62a6c74b..b68d31dcc 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -149,6 +149,12 @@ class EnableDisableTestCase extends ModuleTestCase { $this->assertModules(array('aggregator'), FALSE); $this->assertTableCount('aggregator', FALSE); $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => 'aggregator'), WATCHDOG_INFO); + + // Reinstall (and enable) aggregator module. + $edit = array(); + $edit['modules[Core][aggregator][enable]'] = 'aggregator'; + $this->drupalPost('admin/build/modules', $edit, t('Save configuration')); + $this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.')); } } diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index b81f1d6e9..b5b3e5330 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -945,3 +945,18 @@ function user_modules_installed($modules) { } } } + +/** + * Implement hook_modules_uninstalled(). + */ +function user_modules_uninstalled($modules) { + $permissions = array(); + foreach ($modules as $module) { + $permissions = array_merge($permissions, array_keys(module_invoke($module, 'perm'))); + } + if (!empty($permissions)) { + db_delete('role_permission') + ->condition('permission', $permissions, 'IN') + ->execute(); + } +} |