aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2011-12-03 22:07:34 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2011-12-03 22:07:34 -0500
commitbf6d501ab16f0557c0570faa2a6f45e588ff62fb (patch)
treec23957f4de0b3db5976d1e4dac15c69ecfb317de /tests/test_framework
parent138f123bd81bdd25bde28ca46a9ebf1673ffaecd (diff)
parentbaac9e5d150dab88ed6f1eca8ca61bc4468ab01c (diff)
downloadforums-bf6d501ab16f0557c0570faa2a6f45e588ff62fb.tar
forums-bf6d501ab16f0557c0570faa2a6f45e588ff62fb.tar.gz
forums-bf6d501ab16f0557c0570faa2a6f45e588ff62fb.tar.bz2
forums-bf6d501ab16f0557c0570faa2a6f45e588ff62fb.tar.xz
forums-bf6d501ab16f0557c0570faa2a6f45e588ff62fb.zip
Merge remote-tracking branch 'Noxwizard/ticket/10349' into develop-olympus
* Noxwizard/ticket/10349: [ticket/10349] Removed duplicated functions from schema loading in tests [ticket/10349] Update function comment [ticket/10349] Use new schema comment function in installer [ticket/10349] Unit tests: Consolidate schema comment removal functions [ticket/10349] Unit tests: Remove comments while loading schema files
Diffstat (limited to 'tests/test_framework')
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php45
1 files changed, 7 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 68e09add94..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;
@@ -239,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)
{
@@ -248,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)