aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-26 00:30:20 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-26 00:31:43 -0500
commit02a1777fcbc550b4d91aaa585cffa9c052e4c525 (patch)
tree1e25f1e2b69eaa8c2945d60c808f5fc69a6794d5 /tests/test_framework
parentc701de695f33d78e99517b9213eb06a95e57f9a0 (diff)
downloadforums-02a1777fcbc550b4d91aaa585cffa9c052e4c525.tar
forums-02a1777fcbc550b4d91aaa585cffa9c052e4c525.tar.gz
forums-02a1777fcbc550b4d91aaa585cffa9c052e4c525.tar.bz2
forums-02a1777fcbc550b4d91aaa585cffa9c052e4c525.tar.xz
forums-02a1777fcbc550b4d91aaa585cffa9c052e4c525.zip
[ticket/11295] Drop tables rather than database for postgres in test suite.
Doing so allows: 1. User running the tests no longer needs create database privilege. 2. Test database may be located in a non-default tablespace and generally have site-specific options applied to it. PHPBB3-11295
Diffstat (limited to 'tests/test_framework')
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index d7c2804aa7..3b8c2e99ae 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -186,6 +186,16 @@ class phpbb_database_test_connection_manager
$this->purge_extras();
break;
+ case 'postgres':
+ $this->connect();
+ // Drop all of the tables
+ foreach ($this->get_tables() as $table)
+ {
+ $this->pdo->exec('DROP TABLE ' . $table . ' CASCADE');
+ }
+ $this->purge_extras();
+ break;
+
default:
$this->connect(false);
@@ -293,7 +303,7 @@ class phpbb_database_test_connection_manager
protected function load_schema_from_file($directory)
{
$schema = $this->dbms['SCHEMA'];
-
+
if ($this->config['dbms'] == 'mysql')
{
$sth = $this->pdo->query('SELECT VERSION() AS version');
@@ -313,7 +323,7 @@ class phpbb_database_test_connection_manager
$queries = file_get_contents($filename);
$sql = phpbb_remove_comments($queries);
-
+
$sql = split_sql_file($sql, $this->dbms['DELIM']);
foreach ($sql as $query)
@@ -419,6 +429,19 @@ class phpbb_database_test_connection_manager
$queries[] = 'DROP SEQUENCE ' . current($row);
}
break;
+
+ case 'postgres':
+ $sql = 'SELECT sequence_name
+ FROM information_schema.sequences';
+ $result = $this->pdo->query($sql);
+
+ while ($row = $result->fetch(PDO::FETCH_NUM))
+ {
+ $queries[] = 'DROP SEQUENCE ' . current($row);
+ }
+
+ $queries[] = 'DROP TYPE IF EXISTS varchar_ci CASCADE';
+ break;
}
foreach ($queries as $query)