Index: profiles/standard/standard.info
===================================================================
RCS file: /cvs/drupal/drupal/profiles/standard/standard.info,v
retrieving revision 1.1
diff -u -r1.1 standard.info
--- profiles/standard/standard.info	4 Jan 2010 23:08:34 -0000	1.1
+++ profiles/standard/standard.info	21 Apr 2010 03:13:19 -0000
@@ -22,3 +22,4 @@
 dependencies[] = file
 dependencies[] = rdf
 files[] = standard.profile
+files[] = standard.test
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.921
diff -u -r1.921 system.module
--- modules/system/system.module	13 Apr 2010 15:23:03 -0000	1.921
+++ modules/system/system.module	21 Apr 2010 03:13:19 -0000
@@ -2201,18 +2201,12 @@
  *   An associative array of module information.
  */
 function _system_rebuild_module_data() {
-  // Find modules
-  $modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0);
+  // Load all profiles and keep a list of them.
+  $modules = drupal_system_listing('/\.profile$/', 'profiles', 'name', 0);
+  $profiles = array_keys($modules);
 
-  // Include the install profile in modules that are loaded.
-  $profile = drupal_get_profile();
-  $modules[$profile] = new stdClass;
-  $modules[$profile]->name = $profile;
-  $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
-  $modules[$profile]->filename = $profile . '.profile';
-
-  // Install profile hooks are always executed last.
-  $modules[$profile]->weight = 1000;
+  // Add all the modules to the list.
+  $modules += drupal_system_listing('/\.module$/', 'modules', 'name', 0);
 
   // Set defaults for module info.
   $defaults = array(
@@ -2244,13 +2238,19 @@
     // Merge in defaults and save.
     $modules[$key]->info = $module->info + $defaults;
 
+    // All profiles should be hidden.
+    if (in_array($key, $profiles)) {
+      $modules[$key]->info['hidden'] = TRUE;
+    }
+
     // Invoke hook_system_info_alter() to give installed modules a chance to
     // modify the data in the .info files if necessary.
     $type = 'module';
     drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);
   }
 
-  // The install profile is required.
+  // The active install profile is required.
+  $profile = drupal_get_profile();
   $modules[$profile]->info['required'] = TRUE;
 
   return $modules;
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.210
diff -u -r1.210 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	11 Apr 2010 18:33:44 -0000	1.210
+++ modules/simpletest/drupal_web_test_case.php	21 Apr 2010 03:13:19 -0000
@@ -712,6 +712,11 @@
   protected $redirect_count;
 
   /**
+   * The name of the profile to use for the test.
+   */
+  protected $install_profile = 'standard';
+
+  /**
    * Constructor for DrupalWebTestCase.
    */
   function __construct($test_id = NULL) {
@@ -1075,7 +1080,7 @@
     return md5($this->session_id . $value . $private_key);
   }
 
-  /*
+  /**
    * Logs a user out of the internal browser, then check the login page to confirm logout.
    */
   protected function drupalLogout() {
@@ -1155,11 +1160,16 @@
 
     $this->preloadRegistry();
 
-    // Include the default profile.
-    variable_set('install_profile', 'standard');
-    $profile_details = install_profile_info('standard', 'en');
+    // Include the install profile.
+    variable_set('install_profile', $this->install_profile);
+    if (!($profile_details = install_profile_info($this->install_profile, 'en'))) {
+      $this->fail('Install profile [' . $this->install_profile . '] not found');
 
-    // Install the modules specified by the default profile.
+      // Setup failed, skip test and proceed with tearDown().
+      return FALSE;
+    }
+
+    // Install the modules specified by the profile.
     module_enable($profile_details['dependencies'], FALSE);
 
     // Install modules needed for this test. This could have been passed in as
@@ -1174,8 +1184,8 @@
       module_enable($modules, TRUE);
     }
 
-    // Run default profile tasks.
-    module_enable(array('standard'), FALSE);
+    // Run profile tasks.
+    module_enable(array($this->install_profile), FALSE);
 
     // Rebuild caches.
     drupal_static_reset();
@@ -1201,6 +1211,7 @@
     $user = user_load(1);
 
     // Restore necessary variables.
+    variable_set('install_profile', $this->install_profile);
     variable_set('install_task', 'done');
     variable_set('clean_url', $clean_url_original);
     variable_set('site_mail', 'simpletest@example.com');
@@ -1218,6 +1229,9 @@
     variable_set('mail_system', array('default-system' => 'TestingMailSystem'));
 
     drupal_set_time_limit($this->timeLimit);
+
+    // Setup succeeded.
+    return TRUE;
   }
 
   /**
Index: profiles/minimal/minimal.info
===================================================================
RCS file: /cvs/drupal/drupal/profiles/minimal/minimal.info,v
retrieving revision 1.1
diff -u -r1.1 minimal.info
--- profiles/minimal/minimal.info	4 Jan 2010 23:08:34 -0000	1.1
+++ profiles/minimal/minimal.info	21 Apr 2010 03:13:19 -0000
@@ -6,3 +6,4 @@
 dependencies[] = block
 dependencies[] = dblog
 files[] = minimal.profile
+files[] = minimal.test
Index: profiles/minimal/minimal.test
===================================================================
RCS file: profiles/minimal/minimal.test
diff -N profiles/minimal/minimal.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ profiles/minimal/minimal.test	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,31 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ */
+
+class MinimalProfileTestCase extends InstallProfileTestCase {
+
+  protected $install_profile = 'minimal';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Minimal',
+      'description' => 'Ensure that the minimal install profile works as expected.',
+      'group' => 'Install profiles',
+    );
+  }
+
+  /**
+   * Ensure that the minimal install profile works as expected.
+   */
+  protected function testMinimalProfile() {
+    $this->assertInstalledModules($this->install_profile);
+
+    $this->assertFalse(module_exists('locale'), t('Locale module is disabled'));
+
+    // Test that no node types are defined.
+    $this->assertNodeTypesCreated();
+  }
+}
Index: profiles/standard/standard.test
===================================================================
RCS file: profiles/standard/standard.test
diff -N profiles/standard/standard.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ profiles/standard/standard.test	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,91 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Provide tests for the standard profile.
+ */
+
+class InstallProfileTestCase extends DrupalWebTestCase {
+
+  /**
+   * Assert that the required modules are installed and active.
+   */
+  protected function assertInstalledModules($profile = NULL, $locale = 'en') {
+    module_load_include('profile', $profile);
+
+    // Get a list of modules required by this profile.
+    $info = drupal_parse_info_file(drupal_get_path('module', $this->install_profile) . '/' . $this->install_profile . '.info');
+    $profile_modules = array_merge(drupal_required_modules(), $info['dependencies'], ($locale != 'en' ? array('locale') : array()));
+
+    $this->assertEqual($profile, drupal_get_profile(), t('The correct profile was used'));
+
+    $installed_modules = module_list(FALSE, FALSE);
+    $this->assertEqual(count($installed_modules), count($profile_modules), t('Expected number of modules are active'));
+
+    // Test that the modules are active.
+    foreach ($profile_modules as $name) {
+      $this->assertTrue(isset($installed_modules[$name]), t('%name module is active', array('%name' => $name)));
+    }
+  }
+
+  /**
+   * Assert that the expected node types were defined.
+   *
+   * @param ...
+   *   Each type expected to be created should be passed as a parameter.
+   */
+  protected function assertNodeTypesCreated() {
+    $expected_types = func_get_args();
+    $types = _node_types_build();
+    $diff = array_diff(array_keys($types->types), $expected_types);
+    $this->assertTrue(empty($diff), t('Node types defined correctly.'));
+  }
+}
+
+class StandardProfileTestCase extends InstallProfileTestCase {
+
+  protected $install_profile = 'standard';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Standard install profile tests',
+      'description' => 'Ensure that the standard install profile works as expected.',
+      'group' => 'Install profiles',
+    );
+  }
+
+  /**
+   * Ensure that the standard install profile works as expected.
+   */
+  function testStandardProfile() {
+    $this->assertInstalledModules($this->install_profile);
+
+    // Test that the expected node types are defined.
+    $this->assertNodeTypesCreated('page', 'article');
+
+    // Test if a default vocabulary named "Tags" is enabled for the 'article' content type.
+    $vocabularies = module_invoke('taxonomy', 'get_vocabularies');
+    $count = count($vocabularies);
+    $this->assertEqual(1, $count, t('1 vocabulary expected, !count found', array('!count' => $count)));
+    if ($count) {
+      $vocabulary = array_shift($vocabularies);
+      $values = taxonomy_vocabulary_load($vocabulary->vid);
+      $default_values = array(
+        'name' => 'Tags',
+        'relations' => 0,
+        'hierarchy' => 0,
+        'multiple' => 0,
+        'required' => 0,
+        'tags' => 1,
+        'module' => 'taxonomy',
+        'weight' => 0,
+      );
+      foreach($default_values as $key => $value) {
+        if (isset($values->$key)) {
+          $this->assertEqual($value, $values->$key, t('Checking vocabulary value of %key.', array('%key' => $key)));
+        }
+      }
+    }
+  }
+}
