diff --git includes/common.inc includes/common.inc index e749880..448da25 100644 --- includes/common.inc +++ includes/common.inc @@ -4756,6 +4756,62 @@ function drupal_cron_cleanup() { } /** + * Add directories to search for system object files (modules, themes, etc.). + * + * This function is used to add directories to be searched when we build + * the system table. Modules found in these locations will override objects in + * the /modules/ and /profiles/your_site_profile/modules/ directories, + * but modules in the /sites/all/modules/ and /sites/your_site_dir/modules/ + * directories will take precedence over them. + * + * @param $scope + * The directory type to be added. May be one of the following: + * - host_profile + * @param $directory + * The path to be added. + */ +function drupal_add_system_directory($scope = null, $directory = null) { + static $search_dirs = array(); + + // Pre-load the directory array with the know directory scopes. + if (!sizeof($search_dirs)) { + + // The active install profile directory for the host site from within a test. + // If no test is active no host profile directory will be set. + $search_dirs['host_profile'] = NULL; + } + + // Return the entire list of directories. + if (is_null($scope) && is_null($directory)) { + return $search_dirs; + } + + if (!is_null($directory) && !is_null($scope)) { + $search_dirs[$scope] = $directory; + } + + if (array_key_exists($scope, $search_dirs)) { + return $search_dirs[$scope]; + } + + return FALSE; +} + +/** + * Returns directories searched for system object files (modules, themes etc.). + * + * This function is used to return the directories that have been added with + * drupal_add_system_directory(). + * + * @return + * Array containing directory paths. + */ +function drupal_get_system_directory() { + return drupal_add_system_directory(); +} + + +/** * Returns information about system object files (modules, themes, etc.). * * This function is used to find all or some system object files (module files, @@ -4818,6 +4874,13 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) $searchdir[] = "profiles/$profile/$directory"; } + // Include directories from the drupal_add_system_directory() function. + foreach (drupal_get_system_directory() as $additional_dir) { + if (!is_null($additional_dir)) { + $searchdir[] = "$additional_dir/$directory"; + } + } + // Always search sites/all/* as well as the global directories $searchdir[] = 'sites/all/' . $directory; diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php index b32406c..1a4e92b 100644 --- modules/simpletest/drupal_web_test_case.php +++ modules/simpletest/drupal_web_test_case.php @@ -1188,6 +1188,11 @@ class DrupalWebTestCase extends DrupalTestCase { $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); + // The host profile's collection of modules or themes need to be included + // when running tests that use an alternate install profile but still reside + // in the host profile's directory. + drupal_add_system_directory('host_profile', 'profiles/' . $this->originalProfile); + // Save and clean shutdown callbacks array because it static cached and // will be changed by the test run. If we don't, then it will contain // callbacks from both environments. So testing environment will try