diff options
Diffstat (limited to 'tests/test_framework')
-rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index a7559e2183..7a45d87583 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -7,6 +7,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; + class phpbb_database_test_connection_manager { private $config; @@ -69,6 +71,11 @@ class phpbb_database_test_connection_manager default: $dsn .= 'host=' . $this->config['dbhost']; + if ($this->config['dbport']) + { + $dsn .= ';port=' . $this->config['dbport']; + } + if ($use_db) { $dsn .= ';dbname=' . $this->config['dbname']; @@ -234,7 +241,11 @@ class phpbb_database_test_connection_manager } $filename = $directory . $schema . '_schema.sql'; - $sql = $this->split_sql(file_get_contents($filename)); + + $queries = file_get_contents($filename); + $sql = remove_comments($queries); + + $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) { @@ -243,43 +254,6 @@ class phpbb_database_test_connection_manager } /** - * Split contents of an SQL file into an array of SQL statements - * - * Note: This method is not the same as split_sql_file from functions_install. - * - * @param string $sql Raw contents of an SQL file - * - * @return Array of runnable SQL statements - */ - protected function split_sql($sql) - { - $sql = str_replace("\r" , '', $sql); - $data = preg_split('/' . preg_quote($this->dbms['DELIM'], '/') . '$/m', $sql); - - $data = array_map('trim', $data); - - // The empty case - $end_data = end($data); - - if (empty($end_data)) - { - unset($data[key($data)]); - } - - if ($this->config['dbms'] == 'sqlite') - { - // remove comment lines starting with # - they are not proper sqlite - // syntax and break sqlite2 - foreach ($data as $i => $query) - { - $data[$i] = preg_replace('/^#.*$/m', "\n", $query); - } - } - - return $data; - } - - /** * Map a phpBB dbms driver name to dbms data array */ protected function get_dbms_data($dbms) |