From 56219bfa2b7a28a365e6330d928d522a1d63c320 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 29 May 2012 13:27:08 +0900
Subject: [PATCH] Issue #1541958 by sun, alexpott, tim.plunkett, Berdir: Fixed
 Split setUp() into specific sub-methods.

---
 .../simpletest/lib/Drupal/simpletest/WebTestBase.php     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index db0f09f10f43..33b26e32bd01 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -857,9 +857,14 @@ protected function tearDown() {
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
 
     // Remove all prefixed tables.
-    $tables = db_find_tables($this->databasePrefix . '%');
+    $connection_info = Database::getConnectionInfo('default');
+    $tables = db_find_tables($connection_info['default']['prefix']['default'] . '%');
+    if (empty($tables)) {
+      $this->fail('Failed to find test tables to drop.');
+    }
+    $prefix_length = strlen($connection_info['default']['prefix']['default']);
     foreach ($tables as $table) {
-      if (db_drop_table(substr($table, strlen($this->databasePrefix)))) {
+      if (db_drop_table(substr($table, $prefix_length))) {
         unset($tables[$table]);
       }
     }
-- 
GitLab