aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2010-10-22 19:50:43 +0200
committerNils Adermann <naderman@naderman.de>2010-10-25 19:39:12 +0200
commita397f81a2bc03019910c088376cf563d05dadf93 (patch)
tree153b0eb421e40ff873f6d92b7e4e3604dbe4dcf0
parent9dbbfea5fd31e40acc6fb4a195795b3e285a5b56 (diff)
downloadforums-a397f81a2bc03019910c088376cf563d05dadf93.tar
forums-a397f81a2bc03019910c088376cf563d05dadf93.tar.gz
forums-a397f81a2bc03019910c088376cf563d05dadf93.tar.bz2
forums-a397f81a2bc03019910c088376cf563d05dadf93.tar.xz
forums-a397f81a2bc03019910c088376cf563d05dadf93.zip
[task/mssql-db-tests] Allow test configuration with environment variables.
To allow execution of the tests with different configurations without having to use the test_config.php file, environment variables of the form PHPBB_TEST_<name> can now be used, e.g. PHPBB_TEST_DBMS to set the variables otherwise expected in test_config.php PHPBB3-9868
-rw-r--r--tests/RUNNING_TESTS.txt8
-rw-r--r--tests/test_framework/phpbb_database_test_case.php13
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt
index a5d3111242..74a0635c1a 100644
--- a/tests/RUNNING_TESTS.txt
+++ b/tests/RUNNING_TESTS.txt
@@ -36,13 +36,19 @@ 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:
+
+ $ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \
+ PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \
+ PHPBB_TEST_DBPASSWD='password' phpunit all_tests.php
Running
=======
Once the prerequisites are installed, run the tests from tests directory:
-$ phpunit all_tests.php
+ $ phpunit all_tests.php
More Information
================
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 33dbce709b..8b96298b6a 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -85,7 +85,18 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
static $show_error = true;
- if (file_exists('test_config.php'))
+ 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('test_config.php'))
{
include('test_config.php');