From de70b17b1dc19e19faa0d56395a1aba8868c9624 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Fri, 20 Apr 2012 23:50:49 -0500 Subject: [ticket/10492] Separate config generation from the installer PHPBB3-10492 --- tests/test_framework/phpbb_database_test_case.php | 42 +++-------------------- 1 file changed, 5 insertions(+), 37 deletions(-) (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index fdb662b284..e742b543b0 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -40,46 +40,14 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test public function get_database_config() { - if (isset($_SERVER['PHPBB_TEST_DBMS'])) - { - return array( - 'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '', - 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '', - 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '', - 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '', - 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '', - 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', - ); - } - else if (file_exists(dirname(__FILE__) . '/../test_config.php')) - { - include(dirname(__FILE__) . '/../test_config.php'); - - return array( - 'dbms' => $dbms, - 'dbhost' => $dbhost, - 'dbport' => $dbport, - 'dbname' => $dbname, - 'dbuser' => $dbuser, - 'dbpasswd' => $dbpasswd, - ); - } - else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) - { - // Silently use sqlite - return array( - 'dbms' => 'sqlite', - 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename - 'dbport' => '', - 'dbname' => '', - 'dbuser' => '', - 'dbpasswd' => '', - ); - } - else + $config = phpbb_test_case_helpers::get_test_config(); + + if (!isset($config['dbms'])) { $this->markTestSkipped('Missing test_config.php: See first error.'); } + + return $config; } public function getConnection() -- cgit v1.2.1 From d578eff712b6376e3568965afec7054bff317127 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 28 Feb 2012 06:18:24 -0600 Subject: [ticket/10678] Add better support for Firebird, Oracle, and MSSQL Allow ODBC connections for Firebird Capitalize fixture tables and columns for Firebird On database drop failure, drop all tables Provide cleanup utilities for databases that cannot be dropped PHPBB3-10678 --- tests/test_framework/phpbb_database_test_case.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index e742b543b0..0e5518fef8 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -28,6 +28,28 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test ); } + public function createXMLDataSet($path) + { + $db_config = $this->get_database_config(); + + //Firebird requires table and column names to be uppercase + if($db_config['dbms'] == 'firebird') + { + $xml_data = file_get_contents($path); + $xml_data = preg_replace_callback('/(?:())/', 'phpbb_database_test_case::to_upper', $xml_data); + $xml_data = preg_replace_callback('/(?:())([a-z_]+)(?:(<\/column>))/', 'phpbb_database_test_case::to_upper', $xml_data); + + $temp = tmpfile(); + fwrite($temp, $xml_data); + fseek($temp, 0); + + $meta_data = stream_get_meta_data($temp); + $path = $meta_data['uri']; + } + + return parent::createXMLDataSet($path); + } + public function get_test_case_helpers() { if (!$this->test_case_helpers) @@ -106,4 +128,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test { return new phpbb_database_test_connection_manager($config); } + + public static function to_upper($matches) + { + return $matches[1] . strtoupper($matches[2]) . $matches[3]; + } } -- cgit v1.2.1 From 5cbe919256a0046a896a88c47b96276b6d7c05d0 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 28 Feb 2012 13:47:15 -0600 Subject: [ticket/10678] Fix formatting PHPBB3-10678 --- tests/test_framework/phpbb_database_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 0e5518fef8..b8be6a852a 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -33,7 +33,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $db_config = $this->get_database_config(); //Firebird requires table and column names to be uppercase - if($db_config['dbms'] == 'firebird') + if ($db_config['dbms'] == 'firebird') { $xml_data = file_get_contents($path); $xml_data = preg_replace_callback('/(?:(
))/', 'phpbb_database_test_case::to_upper', $xml_data); -- cgit v1.2.1 From 9bb2785da0c84bcc4a95f737b7da14c58c5d4380 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Mon, 2 Apr 2012 05:57:48 -0500 Subject: [ticket/10678] More formatting and docblocks PHPBB3-10678 --- tests/test_framework/phpbb_database_test_case.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index b8be6a852a..53c3702aa6 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -32,7 +32,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test { $db_config = $this->get_database_config(); - //Firebird requires table and column names to be uppercase + // Firebird requires table and column names to be uppercase if ($db_config['dbms'] == 'firebird') { $xml_data = file_get_contents($path); @@ -129,6 +129,14 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test return new phpbb_database_test_connection_manager($config); } + /** + * Converts a match in the middle of a string to uppercase. + * This is necessary for tranforming the fixture information for Firebird tests + * + * @param $matches The array of matches from a regular expression + * + * @return string The string with the specified match converted to uppercase + */ public static function to_upper($matches) { return $matches[1] . strtoupper($matches[2]) . $matches[3]; -- cgit v1.2.1 From 29b36b214a809b6ae49f941a4e3965ffba2b8741 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sun, 13 May 2012 16:56:07 -0500 Subject: [ticket/10678] Typo and formatting PHPBB3-10678 --- tests/test_framework/phpbb_database_test_case.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/test_framework/phpbb_database_test_case.php') diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 53c3702aa6..bb86df0ef0 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -39,11 +39,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $xml_data = preg_replace_callback('/(?:(
))/', 'phpbb_database_test_case::to_upper', $xml_data); $xml_data = preg_replace_callback('/(?:())([a-z_]+)(?:(<\/column>))/', 'phpbb_database_test_case::to_upper', $xml_data); - $temp = tmpfile(); - fwrite($temp, $xml_data); - fseek($temp, 0); + $new_fixture = tmpfile(); + fwrite($new_fixture, $xml_data); + fseek($new_fixture, 0); - $meta_data = stream_get_meta_data($temp); + $meta_data = stream_get_meta_data($new_fixture); $path = $meta_data['uri']; } @@ -131,7 +131,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test /** * Converts a match in the middle of a string to uppercase. - * This is necessary for tranforming the fixture information for Firebird tests + * This is necessary for transforming the fixture information for Firebird tests * * @param $matches The array of matches from a regular expression * -- cgit v1.2.1