### Eclipse Workspace Patch 1.0
#P simpletest
Index: tests/functional/system.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/functional/system.test,v
retrieving revision 1.10
diff -u -r1.10 system.test
--- tests/functional/system.test	8 Apr 2008 17:56:09 -0000	1.10
+++ tests/functional/system.test	8 Apr 2008 18:15:07 -0000
@@ -100,15 +100,12 @@
    * @return boolean Tables with specified base table.
    */
   function assertTableCount($base_table, $count) {
-    global $db_url, $db_prefix;
-    $url = parse_url($db_url);
-    $database = substr($url['path'], 1);
-    $result = db_query("SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema = '". $database ."' AND table_name LIKE '". $db_prefix . $base_table ."%'");
+    $match_count = simpletest_get_like_tables($base_table, TRUE);
 
     if ($count) {
-      return $this->assertTrue(db_result($result) == $count, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
+      return $this->assertTrue($match_count, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
     }
-    return $this->assertTrue(db_result($result) == $count, t('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
+    return $this->assertFalse($match_count, t('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
   }
 
   /**
Index: simpletest.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v
retrieving revision 1.44
diff -u -r1.44 simpletest.module
--- simpletest.module	8 Apr 2008 00:57:19 -0000	1.44
+++ simpletest.module	8 Apr 2008 18:15:07 -0000
@@ -223,13 +223,10 @@
  * Removed prefixed talbes from the database that are left over from crashed tests.
  */
 function simpletest_clean_database() {
-  global $db_url;
-  $url = parse_url($db_url);
-  $database = substr($url['path'], 1);
-  $result = db_query("SELECT table_name FROM information_schema.TABLES WHERE table_schema = '". $database ."' AND table_name LIKE 'simpletest%'");
+  $tables = simpletest_get_like_tables();
 
   $ret = array();
-  while ($table = db_result($result)) {
+  foreach ($tables as $table) {
     db_drop_table($ret, $table);
   }
 
@@ -242,6 +239,30 @@
 }
 
 /**
+ * Find all tables that are like the specified base table name.
+ *
+ * @param string $base_table Base table name.
+ * @param boolean $count Return the table count instead of list of tables.
+ * @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;
+  $url = parse_url($db_url);
+  $database = substr($url['path'], 1);
+  $select = $count ? 'COUNT(table_name)' : 'table_name';
+  $result = db_query("SELECT $select FROM information_schema.tables WHERE table_schema = '$database' AND table_name LIKE '$db_prefix$base_table%'");
+  
+  if ($count) {
+    return db_result($result);
+  }
+  $tables = array();
+  while ($table = db_result($result)) {
+    $tables[] = $table;
+  }
+  return $tables;
+}
+
+/**
  * Actually runs tests
  * @param array $testlist list of tests to run or DEFAULT NULL run all tests
  * @param boolean $html_reporter true if you want results in simple html, FALSE for full drupal page
