summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/upgrade/upgrade.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-07-30 01:28:00 +0000
committerDries Buytaert <dries@buytaert.net>2010-07-30 01:28:00 +0000
commit382d8f26140ae08f94f2fa0349c07c62c2e28433 (patch)
tree0c9ae4221b7192cb80b0d83a66d030c28c44cfc6 /modules/simpletest/tests/upgrade/upgrade.test
parent7d3e58292fbfe78cd87c382339809336bf1e4536 (diff)
downloadbrdo-382d8f26140ae08f94f2fa0349c07c62c2e28433.tar.gz
brdo-382d8f26140ae08f94f2fa0349c07c62c2e28433.tar.bz2
- Patch #848368 by Stevel, Damien Tournoud: test updating for poll.module.
Diffstat (limited to 'modules/simpletest/tests/upgrade/upgrade.test')
-rw-r--r--modules/simpletest/tests/upgrade/upgrade.test35
1 files changed, 33 insertions, 2 deletions
diff --git a/modules/simpletest/tests/upgrade/upgrade.test b/modules/simpletest/tests/upgrade/upgrade.test
index 2f9b497ed..d0a3bc885 100644
--- a/modules/simpletest/tests/upgrade/upgrade.test
+++ b/modules/simpletest/tests/upgrade/upgrade.test
@@ -22,6 +22,11 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
var $upgradeErrors = array();
/**
+ * Array of modules loaded when the test starts.
+ */
+ var $loadedModules = array();
+
+ /**
* Override of DrupalWebTestCase::setUp() specialized for upgrade testing.
*/
protected function setUp() {
@@ -31,6 +36,8 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
$this->upgradedSite = FALSE;
$this->upgradeErrors = array();
+ $this->loadedModules = module_list();
+
// Generate a temporary prefixed database to ensure that tests have a clean starting point.
$this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
db_update('simpletest_test_id')
@@ -258,8 +265,14 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
// of the child site directly from this request.
$this->upgradedSite = TRUE;
- // Reload module list and implementations.
- module_list(TRUE);
+ // Reload module list. For modules that are enabled in the test database,
+ // but not on the test client, we need to load the code here.
+ $new_modules = array_diff(module_list(TRUE), $this->loadedModules);
+ foreach ($new_modules as $module) {
+ drupal_load('module', $module);
+ }
+
+ // Reload hook implementations
module_implements('', FALSE, TRUE);
// Rebuild caches.
@@ -276,6 +289,24 @@ abstract class UpgradePathTestCase extends DrupalWebTestCase {
return TRUE;
}
+ /**
+ * Force uninstall all modules from a test database, except those listed.
+ *
+ * @param $modules
+ * The list of modules to keep installed. Required core modules will
+ * always be kept.
+ */
+ protected function uninstallModulesExcept(array $modules) {
+ $required_modules = array('block', 'dblog', 'filter', 'node', 'system', 'update', 'user');
+
+ $modules = array_merge($required_modules, $modules);
+
+ db_delete('system')
+ ->condition('type', 'module')
+ ->condition('name', $modules, 'NOT IN')
+ ->execute();
+ }
+
}
/**