From d578eff712b6376e3568965afec7054bff317127 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 28 Feb 2012 06:18:24 -0600 Subject: [PATCH 1/9] [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/RUNNING_TESTS.txt | 19 ++++ .../phpbb_database_connection_helper.php | 24 ++++ .../phpbb_database_test_case.php | 27 +++++ ...phpbb_database_test_connection_manager.php | 106 +++++++++++++++++- 4 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 tests/test_framework/phpbb_database_connection_helper.php diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 59197acc0f..705fb28d07 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -43,6 +43,25 @@ will run phpunit with the same parameters as in the shown test_config.php file: PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \ PHPBB_TEST_DBPASSWD='password' phpunit +Special Database Cases +---------------------- +In order to run tests on some of the databases that we support, it will be +necessary to provide a custom DSN string in test_config.php. This is only needed for +MSSQL 2000+ (PHP module), MSSQL via ODBC, and Firebird when PDO_Firebird does not work +on your system (https://bugs.php.net/bug.php?id=61183). The variable must be named $custom_dsn. + +Examples: +Firebird using http://www.firebirdsql.org/en/odbc-driver/ +$custom_dsn = "Driver={Firebird/InterBase(r) driver};dbname=$dbhost:$dbname"; + +MSSQL +$custom_dsn = "Driver={SQL Server Native Client 10.0};Server=$dbhost;Database=$dbname"; + +The other fields in test_config.php should be filled out as you would normally to connect +to that database in phpBB. + +Additionally, you will need to be running the DbUnit fork from https://github.com/phpbb/dbunit/tree/phpbb. + Running ======= diff --git a/tests/test_framework/phpbb_database_connection_helper.php b/tests/test_framework/phpbb_database_connection_helper.php new file mode 100644 index 0000000000..e1c50655ed --- /dev/null +++ b/tests/test_framework/phpbb_database_connection_helper.php @@ -0,0 +1,24 @@ +driver = $dbms; + $this->version = (double)$version; + + parent::__construct($dsn, $user, $pass); + } +} \ No newline at end of file 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]; + } } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index c734c90a1a..328d90fca9 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -8,6 +8,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; +require_once 'phpbb_database_connection_helper.php'; class phpbb_database_test_connection_manager { @@ -83,9 +84,37 @@ class phpbb_database_test_connection_manager break; } + //These require different connection strings on the phpBB side than they do in PDO + //so you must provide a DSN string for ODBC separately + if($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird') + { + if(!empty($this->config['custom_dsn'])) + { + $dsn = 'odbc:' . $this->config['custom_dsn']; + } + } + try { - $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']); + switch($this->config['dbms']) + { + case 'mssql': + case 'mssql_odbc': + $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); + break; + + case 'firebird': + if(!empty($this->config['custom_dsn'])) + { + $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); + break; + } + //Fall through if they're using the firebird PDO driver and not the generic ODBC driver + + default: + $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']); + break; + } } catch (PDOException $e) { @@ -93,8 +122,7 @@ class phpbb_database_test_connection_manager throw new Exception("Unable do connect to $cleaned_dsn using PDO with error: {$e->getMessage()}"); } - // good for debug - // $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } /** @@ -125,12 +153,41 @@ class phpbb_database_test_connection_manager } break; + case 'firebird': + $this->connect(); + // Drop all of the tables + foreach ($this->get_tables() as $table) + { + $this->pdo->exec('DROP TABLE ' . $table); + } + $this->purge_extras(); + break; + + case 'oracle': + $this->connect(); + // Drop all of the tables + foreach ($this->get_tables() as $table) + { + $this->pdo->exec('DROP TABLE ' . $table . ' CASCADE CONSTRAINTS'); + } + $this->purge_extras(); + break; + default: $this->connect(false); try { $this->pdo->exec('DROP DATABASE ' . $this->config['dbname']); + + try + { + $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']); + } + catch (PDOException $e) + { + throw new Exception("Unable to re-create database: {$e->getMessage()}"); + } } catch (PDOException $e) { @@ -139,9 +196,8 @@ class phpbb_database_test_connection_manager { $this->pdo->exec('DROP TABLE ' . $table); } + $this->purge_extras(); } - - $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']); break; } } @@ -317,4 +373,44 @@ class phpbb_database_test_connection_manager throw new Exception($message); } } + + /** + * Removes extra objects from a database. This is for cases where dropping the database fails. + */ + public function purge_extras() + { + $this->ensure_connected(__METHOD__); + $queries = array(); + + switch ($this->config['dbms']) + { + case 'firebird': + $sql = 'SELECT RDB$GENERATOR_NAME + FROM RDB$GENERATORS + WHERE RDB$SYSTEM_FLAG = 0'; + $result = $this->pdo->query($sql); + + while ($row = $result->fetch(PDO::FETCH_NUM)) + { + $queries[] = 'DROP GENERATOR ' . current($row); + } + break; + + case 'oracle': + $sql = 'SELECT sequence_name + FROM USER_SEQUENCES'; + $result = $this->pdo->query($sql); + + while ($row = $result->fetch(PDO::FETCH_NUM)) + { + $queries[] = 'DROP SEQUENCE ' . current($row); + } + break; + } + + foreach($queries as $query) + { + $this->pdo->exec($query); + } + } } From 5cbe919256a0046a896a88c47b96276b6d7c05d0 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 28 Feb 2012 13:47:15 -0600 Subject: [PATCH 2/9] [ticket/10678] Fix formatting PHPBB3-10678 --- .../phpbb_database_connection_helper.php | 10 +++++++++- tests/test_framework/phpbb_database_test_case.php | 2 +- .../phpbb_database_test_connection_manager.php | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/test_framework/phpbb_database_connection_helper.php b/tests/test_framework/phpbb_database_connection_helper.php index e1c50655ed..6ba527b5d9 100644 --- a/tests/test_framework/phpbb_database_connection_helper.php +++ b/tests/test_framework/phpbb_database_connection_helper.php @@ -1,4 +1,12 @@ 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); diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 328d90fca9..6e3f602ab7 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -86,9 +86,9 @@ class phpbb_database_test_connection_manager //These require different connection strings on the phpBB side than they do in PDO //so you must provide a DSN string for ODBC separately - if($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird') + if ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird') { - if(!empty($this->config['custom_dsn'])) + if (!empty($this->config['custom_dsn'])) { $dsn = 'odbc:' . $this->config['custom_dsn']; } @@ -96,7 +96,7 @@ class phpbb_database_test_connection_manager try { - switch($this->config['dbms']) + switch ($this->config['dbms']) { case 'mssql': case 'mssql_odbc': @@ -104,7 +104,7 @@ class phpbb_database_test_connection_manager break; case 'firebird': - if(!empty($this->config['custom_dsn'])) + if (!empty($this->config['custom_dsn'])) { $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; @@ -408,7 +408,7 @@ class phpbb_database_test_connection_manager break; } - foreach($queries as $query) + foreach ($queries as $query) { $this->pdo->exec($query); } From 0a596c4b8c4d003d0c8af79af65cb5264e9754fe Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sun, 4 Mar 2012 17:19:33 -0600 Subject: [PATCH 3/9] [ticket/10678] More formatting requests PHPBB3-10678 --- .../test_framework/phpbb_database_connection_helper.php | 4 ++-- .../phpbb_database_test_connection_manager.php | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/test_framework/phpbb_database_connection_helper.php b/tests/test_framework/phpbb_database_connection_helper.php index 6ba527b5d9..fbb85784f8 100644 --- a/tests/test_framework/phpbb_database_connection_helper.php +++ b/tests/test_framework/phpbb_database_connection_helper.php @@ -16,10 +16,10 @@ */ class phpbb_database_connection_ODBC_PDO_wrapper extends PDO { - //Name of the driver being used (i.e. mssql, firebird) + // Name of the driver being used (i.e. mssql, firebird) public $driver = ''; - //Version number of driver since PDO::getAttribute(PDO::ATTR_CLIENT_VERSION) is pretty useless for this + // Version number of driver since PDO::getAttribute(PDO::ATTR_CLIENT_VERSION) is pretty useless for this public $version = 0; function __construct($dbms, $version, $dsn, $user, $pass) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 6e3f602ab7..2334e08f78 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -8,7 +8,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; -require_once 'phpbb_database_connection_helper.php'; +require_once dirname(__FILE__) . '/phpbb_database_connection_helper.php'; class phpbb_database_test_connection_manager { @@ -86,12 +86,9 @@ class phpbb_database_test_connection_manager //These require different connection strings on the phpBB side than they do in PDO //so you must provide a DSN string for ODBC separately - if ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird') + if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird')) { - if (!empty($this->config['custom_dsn'])) - { - $dsn = 'odbc:' . $this->config['custom_dsn']; - } + $dsn = 'odbc:' . $this->config['custom_dsn']; } try From 9bb2785da0c84bcc4a95f737b7da14c58c5d4380 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Mon, 2 Apr 2012 05:57:48 -0500 Subject: [PATCH 4/9] [ticket/10678] More formatting and docblocks PHPBB3-10678 --- tests/test_framework/phpbb_database_test_case.php | 10 +++++++++- .../phpbb_database_test_connection_manager.php | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) 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]; diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 2334e08f78..3c4a112d0d 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -84,8 +84,8 @@ class phpbb_database_test_connection_manager break; } - //These require different connection strings on the phpBB side than they do in PDO - //so you must provide a DSN string for ODBC separately + // These require different connection strings on the phpBB side than they do in PDO + // so you must provide a DSN string for ODBC separately if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird')) { $dsn = 'odbc:' . $this->config['custom_dsn']; @@ -106,7 +106,7 @@ class phpbb_database_test_connection_manager $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; } - //Fall through if they're using the firebird PDO driver and not the generic ODBC driver + // Fall through if they're using the firebird PDO driver and not the generic ODBC driver default: $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']); From ceacb63abfdc8144ce88c0d9ce763ccc74836be5 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Thu, 12 Apr 2012 20:10:20 -0500 Subject: [PATCH 5/9] [ticket/10678] Lowercase class name, adjust comment width PHPBB3-10678 --- tests/RUNNING_TESTS.txt | 26 +++++++++++-------- .../phpbb_database_connection_helper.php | 2 +- ...phpbb_database_test_connection_manager.php | 4 +-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 705fb28d07..487320f736 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -36,8 +36,9 @@ found on the wiki (see below). $dbuser = 'user'; $dbpasswd = 'password'; -Alternatively you can specify parameters in the environment, so e.g. the following -will run phpunit with the same parameters as in the shown test_config.php file: +Alternatively you can specify parameters in the environment, so e.g. the +following will run phpunit with the same parameters as in the shown +test_config.php file: $ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \ PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \ @@ -46,9 +47,10 @@ will run phpunit with the same parameters as in the shown test_config.php file: Special Database Cases ---------------------- In order to run tests on some of the databases that we support, it will be -necessary to provide a custom DSN string in test_config.php. This is only needed for -MSSQL 2000+ (PHP module), MSSQL via ODBC, and Firebird when PDO_Firebird does not work -on your system (https://bugs.php.net/bug.php?id=61183). The variable must be named $custom_dsn. +necessary to provide a custom DSN string in test_config.php. This is only +needed for MSSQL 2000+ (PHP module), MSSQL via ODBC, and Firebird when +PDO_Firebird does not work on your system +(https://bugs.php.net/bug.php?id=61183). The variable must be named $custom_dsn. Examples: Firebird using http://www.firebirdsql.org/en/odbc-driver/ @@ -57,15 +59,17 @@ $custom_dsn = "Driver={Firebird/InterBase(r) driver};dbname=$dbhost:$dbname"; MSSQL $custom_dsn = "Driver={SQL Server Native Client 10.0};Server=$dbhost;Database=$dbname"; -The other fields in test_config.php should be filled out as you would normally to connect -to that database in phpBB. +The other fields in test_config.php should be filled out as you would normally +to connect to that database in phpBB. -Additionally, you will need to be running the DbUnit fork from https://github.com/phpbb/dbunit/tree/phpbb. +Additionally, you will need to be running the DbUnit fork from +https://github.com/phpbb/dbunit/tree/phpbb. Running ======= -Once the prerequisites are installed, run the tests from the project root directory (above phpBB): +Once the prerequisites are installed, run the tests from the project root +directory (above phpBB): $ phpunit @@ -73,8 +77,8 @@ Slow tests -------------- Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow. Thus these tests are in the `slow` group, which is excluded by default. You can -enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you only -want the slow tests, run: +enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you +only want the slow tests, run: $ phpunit --group slow diff --git a/tests/test_framework/phpbb_database_connection_helper.php b/tests/test_framework/phpbb_database_connection_helper.php index fbb85784f8..5eba2e7a2e 100644 --- a/tests/test_framework/phpbb_database_connection_helper.php +++ b/tests/test_framework/phpbb_database_connection_helper.php @@ -14,7 +14,7 @@ * * This is used in the custom PHPUnit ODBC driver */ -class phpbb_database_connection_ODBC_PDO_wrapper extends PDO +class phpbb_database_connection_odbc_pdo_wrapper extends PDO { // Name of the driver being used (i.e. mssql, firebird) public $driver = ''; diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 3c4a112d0d..8e214121f3 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -97,13 +97,13 @@ class phpbb_database_test_connection_manager { case 'mssql': case 'mssql_odbc': - $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); + $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; case 'firebird': if (!empty($this->config['custom_dsn'])) { - $this->pdo = new phpbb_database_connection_ODBC_PDO_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); + $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; } // Fall through if they're using the firebird PDO driver and not the generic ODBC driver From 3cdcd44c4b056211f3e3291a4e58beddbb81e25d Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Fri, 13 Apr 2012 01:40:55 -0500 Subject: [PATCH 6/9] [ticket/10678] Rename helper class file PHPBB3-10678 --- ...elper.php => phpbb_database_connection_odbc_pdo_wrapper.php} | 0 tests/test_framework/phpbb_database_test_connection_manager.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/test_framework/{phpbb_database_connection_helper.php => phpbb_database_connection_odbc_pdo_wrapper.php} (100%) diff --git a/tests/test_framework/phpbb_database_connection_helper.php b/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php similarity index 100% rename from tests/test_framework/phpbb_database_connection_helper.php rename to tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 8e214121f3..0335c0de36 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -8,7 +8,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; -require_once dirname(__FILE__) . '/phpbb_database_connection_helper.php'; +require_once dirname(__FILE__) . '/phpbb_database_connection_odbc_pdo_wrapper.php'; class phpbb_database_test_connection_manager { From 711d09633a17ef40e9efe67433f2285fa11f0608 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 8 May 2012 04:34:19 -0500 Subject: [PATCH 7/9] [ticket/10678] Move config changes to new location PHPBB3-10678 --- tests/test_framework/phpbb_test_case_helpers.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index b46c36efaa..3622fb1b1a 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -69,6 +69,7 @@ class phpbb_test_case_helpers 'dbname' => $dbname, 'dbuser' => $dbuser, 'dbpasswd' => $dbpasswd, + 'custom_dsn' => isset($custom_dsn) ? $custom_dsn : '', )); if (isset($phpbb_functional_url)) @@ -85,7 +86,8 @@ class phpbb_test_case_helpers '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'] : '' + 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', + 'custom_dsn' => isset($_SERVER['PHPBB_TEST_CUSTOM_DSN']) ? $_SERVER['PHPBB_TEST_CUSTOM_DSN'] : '', )); } From 1496a4198a930e3f9412f6beb6c0307ddeeb6dda Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Tue, 8 May 2012 04:35:47 -0500 Subject: [PATCH 8/9] [ticket/10678] Add port handling for MSSQL tests PHPBB3-10678 --- .../phpbb_database_test_connection_manager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 0335c0de36..2e93b6799c 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -63,6 +63,13 @@ class phpbb_database_test_connection_manager // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress; $dsn .= $this->config['dbhost']; + // Primarily for MSSQL Native/Azure as ODBC needs it in $dbhost, attached to the Server param + if ($this->config['dbport']) + { + $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; + $dsn .= $port_delimiter . $this->config['dbport']; + } + if ($use_db) { $dsn .= ';Database=' . $this->config['dbname']; From 29b36b214a809b6ae49f941a4e3965ffba2b8741 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sun, 13 May 2012 16:56:07 -0500 Subject: [PATCH 9/9] [ticket/10678] Typo and formatting PHPBB3-10678 --- .../phpbb_database_connection_odbc_pdo_wrapper.php | 2 +- tests/test_framework/phpbb_database_test_case.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php b/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php index 5eba2e7a2e..cb5956be9f 100644 --- a/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php +++ b/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php @@ -25,7 +25,7 @@ class phpbb_database_connection_odbc_pdo_wrapper extends PDO function __construct($dbms, $version, $dsn, $user, $pass) { $this->driver = $dbms; - $this->version = (double)$version; + $this->version = (double) $version; parent::__construct($dsn, $user, $pass); } 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 *