? modules/simpletest/variable-profile-279455-1.patch
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.25
diff -u -p -r1.25 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	5 Jul 2008 07:19:31 -0000	1.25
+++ modules/simpletest/drupal_web_test_case.php	7 Jul 2008 23:17:29 -0000
@@ -612,6 +612,51 @@ class DrupalWebTestCase {
   }
 
   /**
+   * Set the install profile to be used during the test.
+   *
+   * This method is primarily for use in testing install profiles, and should be
+   * called in the class's setUp() function before calling parent::setUp().
+   *
+   * @param $name
+   *   The name of an install profile (optional).
+   *
+   * @return
+   *  If $profile is NULL, the most recently set name will be returned, or if no
+   *  profile has been set, the value from the variable 'web_test_case_profile'
+   *  will be returned (defaults to 'default').  If an invalid profile name is
+   *  passed (the profile does not exist), the name will be set to 'default'.
+   */
+  function setInstallProfile($name = NULL) {
+    static $profile;
+    static $checked = FALSE;
+
+    if (isset($name)) {
+      $profile = $name;
+      $checked = FALSE;
+    }
+    // Use the variable if no name was passed in,.
+    if (!isset($profile)) {
+      $profile = variable_get('web_test_case_profile', 'default');
+    }
+    // Check for this existance of the profile.
+    if (!$checked) {
+      if (!file_exists("./profiles/$profile/$profile.profile")) {
+        // Use the default profile if the specified one is missing.
+        $profile = 'default';
+      }
+      $checked = TRUE;
+    }
+    return $profile;
+  }
+
+  /**
+   * Get the install profile to be used during the test.
+   */
+  function getInstallProfile() {
+    return $this->setInstallProfile();
+  }
+
+  /**
    * Generates a random database prefix, runs the install scripts on the
    * prefixed database and enable the specified modules. After installation
    * many caches are flushed and the internal browser is setup so that the
@@ -633,14 +678,15 @@ class DrupalWebTestCase {
     include_once './includes/install.inc';
     drupal_install_system();
 
-    // Add the specified modules to the list of modules in the default profile.
+    $profile = $this->getInstallProfile();
+    // Add the specified modules to the list of modules in the specified profile.
     $args = func_get_args();
-    $modules = array_unique(array_merge(drupal_verify_profile('default', 'en'), $args));
+    $modules = array_unique(array_merge(drupal_verify_profile($profile, 'en'), $args));
     drupal_install_modules($modules);
 
-    // Run default profile tasks.
+    // Run the specified profile's tasks.
     $task = 'profile';
-    default_profile_tasks($task, '');
+    call_user_func($profile .'_profile_tasks', $task, '');
 
     // Rebuild caches.
     menu_rebuild();
@@ -650,7 +696,7 @@ class DrupalWebTestCase {
     $this->checkPermissions(array(), TRUE);
 
     // Restore necessary variables.
-    variable_set('install_profile', 'default');
+    variable_set('install_profile', $profile);
     variable_set('install_task', 'profile-finished');
     variable_set('clean_url', $clean_url_original);
 
