From e03b1d1be1ef8a1b9815196baba4ebcbf5e61eeb Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Thu, 4 Nov 2010 10:22:12 -0500
Subject: [PATCH] bug #893010 by marvil07, neclimdul: Fix tests.

- Add recently views dependency.
- remove connections at tearDown() for simpletest dbtng compatibility
issue. Prefixes are not the right ones after the first test in a test
class.
- removing dbtng_init() call since we can rely on dbtng to do
inizialization after http://drupal.org/node/914392#comment-3688738
---
 tests/VersioncontrolTestCase.test |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git tests/VersioncontrolTestCase.test tests/VersioncontrolTestCase.test
index 69183f2..f82e06f 100644
--- tests/VersioncontrolTestCase.test
+++ tests/VersioncontrolTestCase.test
@@ -47,12 +47,8 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase {
     $magic_modules = $this->determineBackends();
     // load crucial required modules in addition to requested ones.
     $arg_modules = func_get_args();
-    $modules = array_merge(array('dbtng', 'autoload', 'versioncontrol'), $arg_modules, $magic_modules);
+    $modules = array_merge(array('autoload', 'dbtng', 'views', 'versioncontrol'), $arg_modules, $magic_modules);
     call_user_func_array(array('VersioncontrolTestCase', 'parent::setUp'), $modules);
-    // parent::setUp($modules);
-
-    // init dbtng so it actually works.
-    dbtng_init();
 
     if (!($this->useBackends & (self::BACKENDS_NONE))) {
       // If the test requested it, init and attach backends.
@@ -60,6 +56,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 +121,4 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase {
       $this->testBackend = versioncontrol_get_backends('test');
     }
   }
-}
\ No newline at end of file
+}
-- 
1.7.2.3

