Skip to content

Instantly share code, notes, and snippets.

@kinglozzer
Created September 17, 2015 08:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinglozzer/4ce2822df233c6ee18fc to your computer and use it in GitHub Desktop.
Save kinglozzer/4ce2822df233c6ee18fc to your computer and use it in GitHub Desktop.
<?php
// If we're requesting a different database for testing
if(isset($_REQUEST['db'])) {
if(
class_exists('PHPUnit_Runner_Version') // If the PHPUnit runner is loaded
|| php_sapi_name() === "cli" // Or we're definitely in CLI mode
|| (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/dev/tests') !== false) // Or we're running tests in-browser
) {
global $databaseConfig;
switch ($_REQUEST['db']) {
case 'sqlite':
case 'sqlite3':
define('SS_DATABASE_CLASS', 'SQLite3Database');
define('SS_SQLITE_DATABASE_PATH', ':memory:');
$databaseConfig["path"] = ':memory:';
break;
default:
user_error('Unknown database type: ' . $_REQUEST['db'], E_USER_WARNING);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment