Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.185
diff -u -r1.185 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	28 Dec 2009 12:06:49 -0000	1.185
+++ modules/simpletest/drupal_web_test_case.php	28 Dec 2009 21:40:07 -0000
@@ -415,6 +415,7 @@
 
     // HTTP auth settings (<username>:<password>) for the simpletest browser
     // when sending requests to the test site.
+    $this->httpauth_method = variable_get('simpletest_method', CURLAUTH_BASIC);
     $username = variable_get('simpletest_username', NULL);
     $password = variable_get('simpletest_password', NULL);
     if ($username && $password) {
@@ -676,6 +677,11 @@
   protected $originalUser = NULL;
 
   /**
+   * HTTP authentication method
+   */
+  protected $httpauth_method = CURLAUTH_BASIC;
+
+  /**
    * HTTP authentication credentials (<username>:<password>).
    */
   protected $httpauth_credentials = NULL;
@@ -1305,6 +1311,7 @@
         CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
       );
       if (isset($this->httpauth_credentials)) {
+        $curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method;
         $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
       }
       curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
@@ -2714,7 +2721,100 @@
       $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice');
     }
   }
+}
+
+/**
+ * Clone an existing database and use it for testing.
+ */
+class DrupalCloneTestCase extends DrupalWebTestCase {
+
+  /**
+   * The prefix to use as the source of the cloning.
+   *
+   * @var string
+   */
+  private $clonePrefix = '';
+
+  /**
+   * Tables to exlude during data cloning, only their structure will be cloned.
+   *
+   * @var array
+   */
+  protected $excludeTables = array(
+    'cache',
+    'cache_block',
+    'cache_bootstrap',
+    'cache_field',
+    'cache_filter',
+    'cache_form',
+    'cache_image',
+    'cache_menu',
+    'cache_page',
+    'cache_path',
+    'cache_update',
+    'watchdog',
+  );
+
+  /**
+   * New database prefix created by SimpleTest.
+   *
+   * @var string
+   */
+  protected $db_prefix_new = '';
+
+  public function __construct($test_id = NULL) {
+    parent::__construct($test_id);
+
+    $this->clonePrefix = variable_get('simpletest_clone_prefix', '');
+  }
+
+  protected function setUpInstall() {
+    global $db_prefix;
+
+    // Store new database prefix.
+    $this->db_prefix_new = $db_prefix;
+    $db_prefix = $this->clonePrefix;
+
+    // Rebuild schema based on prefixed database and such.
+    $schemas = drupal_get_schema(NULL, TRUE);
+
+    // Create a list of prefixed source table names.
+    $sources = array();
+    foreach ($schemas as $name => $schema) {
+      $sources[$name] = Database::getConnection()->prefixTables('{' . $name . '}');
+    }
+
+    // Return to new prefix before performing cloning.
+    $db_prefix = $this->db_prefix_new;
+
+    // Clone each table into the new database.
+    foreach ($schemas as $name => $schema) {
+      $this->cloneTable($name, $sources[$name], $schema);
+    }
+  }
+
+  protected function setUpVariables() {
+    // Do nothing.
+  }
 
+  /**
+   * Clone an existing table structure and data.
+   *
+   * @param $name
+   *   Table name.
+   * @param $source
+   *   Source table name.
+   * @param $schema
+   *   A Schema API definition array.
+   */
+  protected function cloneTable($name, $source, $schema) {
+    db_create_table($name, $schema);
+
+    $target = Database::getConnection()->prefixTables('{' . $name . '}');
+    if (!in_array($name, $this->excludeTables)) {
+      db_query('INSERT INTO ' . $target . ' SELECT * FROM ' . $source);
+    }
+  }
 }
 
 /**
Index: modules/simpletest/simpletest.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.pages.inc,v
retrieving revision 1.20
diff -u -r1.20 simpletest.pages.inc
--- modules/simpletest/simpletest.pages.inc	8 Nov 2009 13:23:41 -0000	1.20
+++ modules/simpletest/simpletest.pages.inc	28 Dec 2009 21:40:08 -0000
@@ -442,8 +442,23 @@
 
   $form['httpauth'] = array(
     '#type' => 'fieldset',
-    '#title' => t('HTTP authentication credentials'),
+    '#title' => t('HTTP authentication'),
     '#description' => t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['httpauth']['simpletest_method'] = array(
+    '#type' => 'select',
+    '#title' => t('Method'),
+    '#options' => array(
+      CURLAUTH_BASIC => t('Basic'),
+      CURLAUTH_DIGEST => t('Digest'),
+      CURLAUTH_GSSNEGOTIATE => t('GSS negotiate'),
+      CURLAUTH_NTLM => t('NTLM'),
+      CURLAUTH_ANY => t('Any'),
+      CURLAUTH_ANYSAFE => t('Any safe'),
+    ),
+    '#default_value' => variable_get('simpletest_method', CURLAUTH_BASIC),
   );
   $form['httpauth']['simpletest_username'] = array(
     '#type' => 'textfield',
Index: modules/simpletest/simpletest.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v
retrieving revision 1.29
diff -u -r1.29 simpletest.install
--- modules/simpletest/simpletest.install	28 Dec 2009 12:06:49 -0000	1.29
+++ modules/simpletest/simpletest.install	28 Dec 2009 21:40:08 -0000
@@ -17,6 +17,7 @@
   variable_del('simpletest_password');
   variable_del('simpletest_clear_results');
   variable_del('simpletest_verbose');
+  variable_del('simpletest_clone_prefix');
 
   // Remove generated files.
   $path = file_directory_path() . '/simpletest';
