silverstripe-framework/tests/bootstrap/environment.php

36 lines
1.4 KiB
PHP
Raw Permalink Normal View History

<?php
// Bootstrap environment variables
use SilverStripe\Core\Environment;
if (!Environment::getEnv('SS_DATABASE_CLASS') && !Environment::getEnv('SS_DATABASE_USERNAME')) {
// The default settings let us define the database config via environment vars
2023-03-15 22:59:34 +01:00
// Database connection, including legacy ORM support
switch (Environment::getEnv('DB')) {
case "PGSQL";
2022-09-15 03:13:48 +02:00
$pgDatabaseClass = 'PostgreSQLDatabase';
Environment::setEnv('SS_DATABASE_CLASS', $pgDatabaseClass);
Environment::setEnv('SS_DATABASE_USERNAME', 'postgres');
Environment::setEnv('SS_DATABASE_PASSWORD', '');
break;
case "SQLITE":
2022-09-15 03:13:48 +02:00
$sqliteDatabaseClass = 'SQLite3Database';
Environment::setEnv('SS_DATABASE_CLASS', $sqliteDatabaseClass);
Environment::setEnv('SS_DATABASE_USERNAME', 'root');
Environment::setEnv('SS_DATABASE_PASSWORD', '');
Environment::setEnv('SS_SQLITE_DATABASE_PATH', ':memory:');
break;
default:
2022-09-15 03:13:48 +02:00
$mysqlDatabaseClass = 'MySQLDatabase';
Environment::setEnv('SS_DATABASE_CLASS', $mysqlDatabaseClass);
Environment::setEnv('SS_DATABASE_USERNAME', 'root');
Environment::setEnv('SS_DATABASE_PASSWORD', '');
}
Environment::setEnv('SS_DATABASE_CHOOSE_NAME', 'true');
Environment::setEnv('SS_DATABASE_SERVER', '127.0.0.1');
}