Index: drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/contributions/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.2.2.3
diff -u -p -r1.2.2.3 drupal_web_test_case.php
--- drupal_web_test_case.php	16 Jun 2008 21:09:13 -0000	1.2.2.3
+++ drupal_web_test_case.php	12 Jul 2008 00:46:54 -0000
@@ -17,6 +17,8 @@ class DrupalWebTestCase extends UnitTest
   // DrupalTestCase itself never sets this but always obeys whats set.
   protected $curl_options         = array();
   protected $original_file_directory;
+  protected $test_profile;
+  protected $profile_checked = FALSE;
 
   /**
    * Retrieve the test information from getInfo().
@@ -316,7 +318,7 @@ class DrupalWebTestCase extends UnitTest
     return $user;
   }
 
-  /*
+  /**
    * Logs a user out of the internal browser, then check the login page to confirm logout.
    */
   function drupalLogout() {
@@ -332,6 +334,53 @@ class DrupalWebTestCase extends UnitTest
   }
 
   /**
+   * 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 $profile
+   *   The name of an install profile.
+   */
+  function setInstallProfile($profile) {
+    $this->test_profile = $profile;
+    $this->profile_checked = FALSE;
+  }
+
+  /**
+   * Reset the install profile to be used during the test.
+   */
+  function resetInstallProfile() {
+    unset($this->test_profile);
+    $this->profile_checked = FALSE;
+  }
+
+  /**
+   * Get the install profile to be used during the test.
+   *
+   *  The most recently set name will be returned, or by default the value from
+   *  the variable 'web_test_case_profile' will be returned (defaults to 
+   *  'default'). If an invalid profile name was set (the profile does not
+   *  exist), the profile will be set to 'default'.
+   */
+  function getInstallProfile() {
+    // Use the variable if no name was set,.
+    if (empty($this->test_profile)) {
+      $this->test_profile = variable_get('web_test_case_profile', 'default');
+    }
+    // Check for this existance of the profile.
+    if (!$this->profile_checked) {
+      $profile = $this->test_profile;
+      if (!file_exists("./profiles/$profile/$profile.profile")) {
+        // Use the default profile if the specified one is missing.
+        $this->test_profile = 'default';
+      }
+      $this->profile_checked = TRUE;
+    }
+    return $this->test_profile;
+  }
+
+  /**
    * Generates a random database prefix and runs the install scripts on the prefixed database.
    * After installation many caches are flushed and the internal browser is setup so that the page
    * requests will run on the new prefix. A temporary files directory is created with the same name
@@ -344,19 +393,22 @@ class DrupalWebTestCase extends UnitTest
     if ($simpletest_ua_key) {
       $this->db_prefix_original = $db_prefix;
       $clean_url_original = variable_get('clean_url', 0);
+      $profile = $this->getInstallProfile();
+
       $db_prefix = 'simpletest'. mt_rand(1000, 1000000);
       include_once './includes/install.inc';
       drupal_install_system();
-      $modules = array_unique(array_merge(func_get_args(), drupal_verify_profile('default', 'en')));
+      // Add the arguments to the list of modules in the specified profile.
+      $modules = array_unique(array_merge(func_get_args(), drupal_verify_profile($profile, 'en')));
       drupal_install_modules($modules);
       $this->_modules = drupal_map_assoc($modules);
       $this->_modules['system'] = 'system';
       $task = 'profile';
-      default_profile_tasks($task, '');
+      call_user_func($profile .'_profile_tasks', $task, '');
       menu_rebuild();
       actions_synchronize();
       _drupal_flush_css_js();
-      variable_set('install_profile', 'default');
+      variable_set('install_profile', $profile);
       variable_set('install_task', 'profile-finished');
       variable_set('clean_url', $clean_url_original);
 
@@ -386,6 +438,9 @@ class DrupalWebTestCase extends UnitTest
       }
       $db_prefix = $this->db_prefix_original;
       $this->_logged_in = FALSE;
+      // Reset the install profile to be used for tests.
+      $this->resetInstallProfile();
+      // Close the CURL handler.
       $this->curlClose();
     }
     parent::tearDown();
