diff options
author | Patrick Webster <noxwizard@phpbb.com> | 2011-10-29 17:10:10 -0500 |
---|---|---|
committer | Patrick Webster <noxwizard@phpbb.com> | 2011-10-29 17:10:10 -0500 |
commit | baac9e5d150dab88ed6f1eca8ca61bc4468ab01c (patch) | |
tree | 4d4d110488b644634dacada52643e20b9c5370dc /tests/test_framework | |
parent | b4dcd4193e7ea52753eb3957bb247b768dc48d12 (diff) | |
download | forums-baac9e5d150dab88ed6f1eca8ca61bc4468ab01c.tar forums-baac9e5d150dab88ed6f1eca8ca61bc4468ab01c.tar.gz forums-baac9e5d150dab88ed6f1eca8ca61bc4468ab01c.tar.bz2 forums-baac9e5d150dab88ed6f1eca8ca61bc4468ab01c.tar.xz forums-baac9e5d150dab88ed6f1eca8ca61bc4468ab01c.zip |
[ticket/10349] Removed duplicated functions from schema loading in tests
PHPBB3-10349
Diffstat (limited to 'tests/test_framework')
-rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 5feab16496..770cc84d7e 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; @@ -236,9 +238,9 @@ class phpbb_database_test_connection_manager $filename = $directory . $schema . '_schema.sql'; $queries = file_get_contents($filename); - $sql = $this->remove_comments($queries); + $sql = remove_comments($queries); - $sql = $this->split_sql($sql); + $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) { @@ -247,47 +249,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)]); - } - - return $data; - } - - /** - * Removes comments from schema files - */ - protected function remove_comments($sql) - { - // Remove /* */ comments (http://ostermiller.org/findcomment.html) - $sql = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $sql); - - // Remove # style comments - $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql)); - - return $sql; - } - - /** * Map a phpBB dbms driver name to dbms data array */ protected function get_dbms_data($dbms) |