From 411d88e96c980c01068e043068504008f7643db2 Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Thu, 4 Nov 2010 10:22:12 -0500
Subject: [PATCH] remove connections on dbtng for simpletest compatibility issue

---
 tests/VersioncontrolTestCase.test |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git tests/VersioncontrolTestCase.test tests/VersioncontrolTestCase.test
index 69183f2..fcad4e1 100644
--- tests/VersioncontrolTestCase.test
+++ tests/VersioncontrolTestCase.test
@@ -51,7 +51,9 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase {
     call_user_func_array(array('VersioncontrolTestCase', 'parent::setUp'), $modules);
     // parent::setUp($modules);
 
-    // init dbtng so it actually works.
+    // hook_init() is needed to be able to use dbtng, simpletest do not
+    // call it, only a normal GET will call it automatically, but for
+    // these tests a GET is not really needed, so call it manually
     dbtng_init();
 
     if (!($this->useBackends & (self::BACKENDS_NONE))) {
@@ -60,6 +62,16 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase {
     }
   }
 
+  protected function tearDown() {
+    // For dbtng the prefix is part of the data associated with the
+    // connection, so, when simpletest makes a new prefix to run another
+    // test method, dbtng do not notice it is a _new_ connection, so
+    // removing by hand force it to open a new one with the right changed
+    // prefix.
+    Database::removeConnection('default');
+    parent::tearDown();
+  }
+
   /**
    * Set up the testing environment with the appropriate set of backends for the
    * current test run.
@@ -115,4 +127,4 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase {
       $this->testBackend = versioncontrol_get_backends('test');
     }
   }
-}
\ No newline at end of file
+}
-- 
1.7.2.3

