Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Initial commit

  • Loading branch information...
commit d938708e3e87aea0077c0492f7c5dc1e7ef5a6b7 0 parents
@chillu chillu authored
Showing with 70 additions and 0 deletions.
  1. +38 −0 README.md
  2. +32 −0 _config.php
38 README.md
@@ -0,0 +1,38 @@
+## Overview
+
+Allows to specify the database through a query parameter,
+which is useful when testing different databases on the same SilverStripe instance, mainly for compatibility and regression checks.
+
+**IMPORTANT: Not intended for production usage** Vital system configuration is set by user input in this module, so it should be used on internal testing instances only.
+
+It is technically part of the [frameworktest](https://github.com/silverstripe-labs/silverstripe-frameworktest) module. Due to the lacking module inclusion priorities, the module has to alphabetically appear after "mysite", where the `$databaseConfig` is initially set.
+
+## Usage
+
+To run tests on a specific database, simply add the `db` query parameter:
+
+ sake dev/tests/all db=sqlite3
+
+Note that when executing through the `phpunit` binary,
+an empty parameter has to be forced.
+
+ phpunit sapphire/tests/ "" db=sqlite3
+
+## Configuration
+
+Relies on constants being defined in an `_ss_environment.php` file:
+
+ // mysql
+ define('SS_DATABASE_SERVER','');
+ define('SS_DATABASE_USERNAME','');
+ define('SS_DATABASE_PASSWORD','');
+
+ // postgresql
+ define('SS_PGSQL_DATABASE_SERVER','');
+ define('SS_PGSQL_DATABASE_USERNAME','');
+ define('SS_PGSQL_DATABASE_PASSWORD','');
+
+ // mssql
+ define('SS_MSSQL_DATABASE_SERVER', '');
+ define('SS_MSSQL_DATABASE_USERNAME', '');
+ define('SS_MSSQL_DATABASE_PASSWORD', '');
32 _config.php
@@ -0,0 +1,32 @@
+<?php
+Session::start();
+if(@$_GET['db']) {
+ $db = $_GET['db'];
+} elseif(@$_SESSION['db']) {
+ $db = $_SESSION['db'];
+} else {
+ $db = null;
+}
+if($db) {
+ global $databaseConfig;
+ if($db == 'mysql') {
+ $databaseConfig['type'] = 'MySQLDatabase';
+ $databaseConfig['server'] = SS_MYSQL_DATABASE_SERVER;
+ $databaseConfig['username'] = SS_MYSQL_DATABASE_USERNAME;
+ $databaseConfig['password'] = SS_MYSQL_DATABASE_PASSWORD;
+ } else if($db == 'postgresql') {
+ $databaseConfig['type'] = 'PostgreSQLDatabase';
+ $databaseConfig['server'] = SS_PGSQL_DATABASE_SERVER;
+ $databaseConfig['username'] = SS_PGSQL_DATABASE_USERNAME;
+ $databaseConfig['password'] = SS_PGSQL_DATABASE_PASSWORD;
+ } else if($db == 'mssql') {
+ $databaseConfig['type'] = 'MSSQLDatabase';
+ $databaseConfig['server'] = SS_MSSQL_DATABASE_SERVER;
+ $databaseConfig['username'] = SS_MSSQL_DATABASE_USERNAME;
+ $databaseConfig['password'] = SS_MSSQL_DATABASE_PASSWORD;
+ } else if($db == 'sqlite3') {
+ $databaseConfig['type'] = 'SQLite3Database';
+ } else {
+ // stick with default settings set through ConfigureFromEnv
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.