? 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	8 Jul 2008 00:47:39 -0000
@@ -612,6 +612,58 @@ 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).
+   * @param $reset
+   *   If TRUE, rests the static variables.
+   *
+   * @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, $reset = FALSE) {
+    static $profile;
+    static $checked = FALSE;
+
+    if ($reset) {
+      unset($profile);
+      $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 +685,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 +703,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);
 
@@ -707,7 +760,8 @@ class DrupalWebTestCase {
 
       // Rebuild caches.
       $this->refreshVariables();
-
+      // Reset the install profile to be used for tests.
+      $this->setInstallProfile(NULL, TRUE);
       // Close the CURL handler.
       $this->curlClose();
       restore_error_handler();
Index: includes/tests/install.test
===================================================================
RCS file: includes/tests/install.test
diff -N includes/tests/install.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/tests/install.test	8 Jul 2008 00:47:39 -0000
@@ -0,0 +1,40 @@
+<?php
+// $Id$
+
+class ExpertProfileTestCase extends DrupalWebTestCase {
+
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Expert install profile tests'),
+      'description' => t('Check that the expert install profile works as expected.'),
+      'group' => t('Install profiles')
+    );
+  }
+
+  /**
+   * Implementation of setUp().
+   */
+  function setUp() {
+    $this->setInstallProfile('expert');
+    parent::setUp();
+  }
+
+  /**
+   * Test the expert profile
+   */
+  function testExpertProfile() {
+    $this->assertEqual('expert', $this->getInstallProfile(), t('The expert profile was used'));
+    $this->assertFalse(module_exists('locale'), t('Locale module was disabled'));
+    $modules = module_list(FALSE, FALSE);
+    $expert_modules = array('block', 'filter', 'node', 'system', 'user', 'dblog');
+    $this->assertEqual(count($modules), count($expert_modules), t('Expected number of modules are active'));
+    foreach ($expert_modules as $name) {
+      $this->assertTrue(isset($modules[$name]), t('%name module is active', array('%name' => $name)));
+    }
+    $types = node_get_types();
+    $this->assertTrue(empty($types), t('No node types are defined'));
+  }
+}
