# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /Users/dave/Sites/democrats/trunk/modules/simpletest
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: drupal_web_test_case.php
--- drupal_web_test_case.php Base (BASE)
+++ drupal_web_test_case.php Locally Modified (Based On LOCAL)
@@ -1079,7 +1079,7 @@
 
     // Generate temporary prefixed database to ensure that tests have a clean starting point.
 //    $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
-    $db_prefix_new = $db_prefix . 'simpletest' . mt_rand(1000, 1000000);
+    $db_prefix_new = _simpletest_build_table_prefix() . mt_rand(1000, 1000000);
 
     // Workaround to insure we init the theme layer before going into prefixed
     // environment. (Drupal 6)
Index: simpletest.module
--- simpletest.module Base (BASE)
+++ simpletest.module Locally Modified (Based On LOCAL)
@@ -421,10 +421,11 @@
  * @return mixed Array of matching tables or count of tables.
  */
 function simpletest_get_like_tables($base_table = 'simpletest', $count = FALSE) {
-  global $db_url, $db_prefix;
+  global $db_url;
+  $db_prefix_new = _simpletest_build_table_prefix();
   $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
   $database = substr($url['path'], 1);
-  $result = db_query("SELECT table_name FROM information_schema.tables WHERE (table_schema = '$database' OR table_catalog = '$database') AND table_name LIKE '$db_prefix$base_table%'");
+  $result = db_query("SELECT table_name FROM information_schema.tables WHERE (table_schema = '$database' OR table_catalog = '$database') AND table_name LIKE '$db_prefix_new$base_table%'");
   $schema = drupal_get_schema_unprocessed('simpletest');
 
   $tables = array();
@@ -437,6 +438,23 @@
 }
 
 /**
+ * Build a string for prefixing simpletest's tables.
+ *
+ * @return string
+ *  The prefix.
+ */
+function _simpletest_build_table_prefix() {
+  global $db_prefix;
+
+  if (is_array($db_prefix)) {
+    return (isset($db_prefix['default']) ? $db_prefix['default'] : array_shift($db_prefix)) .'simpletest';
+  }
+  else {
+    return $db_prefix .'simpletest';
+  }
+}
+
+/**
  * Find all leftover temporary directories and remove them.
  */
 function simpletest_clean_temporary_directories() {
