aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework/phpbb_database_test_case.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_framework/phpbb_database_test_case.php')
-rw-r--r--tests/test_framework/phpbb_database_test_case.php41
1 files changed, 37 insertions, 4 deletions
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index b5076b92e9..c72ea5f765 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -11,6 +11,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
static private $already_connected;
+ private $db_connections;
+
protected $test_case_helpers;
protected $fixture_xml_data;
@@ -28,6 +30,22 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
'phpbb_database_test_case' => array('already_connected'),
);
+
+ $this->db_connections = array();
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+
+ // Close all database connections from this test
+ if (!empty($this->db_connections))
+ {
+ foreach ($this->db_connections as $db)
+ {
+ $db->sql_close();
+ }
+ }
}
protected function setUp()
@@ -44,12 +62,27 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
+ /**
+ * Performs synchronisations for a given table/column set on the database
+ *
+ * @param array $table_column_map Information about the tables/columns to synchronise
+ *
+ * @return null
+ */
+ protected function database_synchronisation($table_column_map)
+ {
+ $config = $this->get_database_config();
+ $manager = $this->create_connection_manager($config);
+ $manager->connect();
+ $manager->database_synchronisation($table_column_map);
+ }
+
public function createXMLDataSet($path)
{
$db_config = $this->get_database_config();
// Firebird requires table and column names to be uppercase
- if ($db_config['dbms'] == 'firebird')
+ if ($db_config['dbms'] == 'phpbb_db_driver_firebird')
{
$xml_data = file_get_contents($path);
$xml_data = preg_replace_callback('/(?:(<table name="))([a-z_]+)(?:(">))/', 'phpbb_database_test_case::to_upper', $xml_data);
@@ -118,11 +151,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$config = $this->get_database_config();
- require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
- $dbal = 'dbal_' . $config['dbms'];
- $db = new $dbal();
+ $db = new $config['dbms']();
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
+ $this->db_connections[] = $db;
+
return $db;
}