mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Update references to deprecated global
This commit is contained in:
parent
f5ef9f4fbf
commit
2868e6bd3e
28
_config.php
28
_config.php
@ -10,21 +10,21 @@ TestSessionEnvironment::singleton()->loadFromFile();
|
|||||||
* This closure will run every time a Resque_Event is forked (just before it is forked, so it applies to the parent
|
* This closure will run every time a Resque_Event is forked (just before it is forked, so it applies to the parent
|
||||||
* and child process).
|
* and child process).
|
||||||
*/
|
*/
|
||||||
if(class_exists('Resque_Event') && class_exists('SSResqueRun')) {
|
if (class_exists('Resque_Event') && class_exists('SSResqueRun')) {
|
||||||
Resque_Event::listen('beforeFork', function($data) {
|
Resque_Event::listen('beforeFork', function ($data) {
|
||||||
global $databaseConfig;
|
$databaseConfig = DB::getConfig();
|
||||||
|
|
||||||
// Reconnect to the database - this may connect to the old DB first, but is required because these processes
|
// Reconnect to the database - this may connect to the old DB first, but is required because these processes
|
||||||
// are long-lived, and MySQL connections often get closed in between worker runs. We need to connect before
|
// are long-lived, and MySQL connections often get closed in between worker runs. We need to connect before
|
||||||
// calling {@link TestSessionEnvironment::loadFromFile()}.
|
// calling {@link TestSessionEnvironment::loadFromFile()}.
|
||||||
DB::connect($databaseConfig);
|
DB::connect($databaseConfig);
|
||||||
|
|
||||||
$testEnv = TestSessionEnvironment::singleton();
|
$testEnv = TestSessionEnvironment::singleton();
|
||||||
|
|
||||||
if($testEnv->isRunningTests()) {
|
if ($testEnv->isRunningTests()) {
|
||||||
$testEnv->loadFromFile();
|
$testEnv->loadFromFile();
|
||||||
} else {
|
} else {
|
||||||
$testEnv->endTestSession();
|
$testEnv->endTestSession();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -450,9 +450,9 @@ class TestSessionEnvironment
|
|||||||
public function resetDatabaseName()
|
public function resetDatabaseName()
|
||||||
{
|
{
|
||||||
if ($this->oldDatabaseName) {
|
if ($this->oldDatabaseName) {
|
||||||
global $databaseConfig;
|
$databaseConfig = DB::getConfig();
|
||||||
|
|
||||||
$databaseConfig['database'] = $this->oldDatabaseName;
|
$databaseConfig['database'] = $this->oldDatabaseName;
|
||||||
|
DB::setConfig($databaseConfig);
|
||||||
|
|
||||||
$conn = DB::get_conn();
|
$conn = DB::get_conn();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TestSessionRequestFilter implements RequestFilter
|
|||||||
$file = $testState->stubfile;
|
$file = $testState->stubfile;
|
||||||
if (!Director::isLive() && $file && file_exists($file)) {
|
if (!Director::isLive() && $file && file_exists($file)) {
|
||||||
// Connect to the database so the included code can interact with it
|
// Connect to the database so the included code can interact with it
|
||||||
global $databaseConfig;
|
$databaseConfig = DB::getConfig();
|
||||||
if ($databaseConfig) {
|
if ($databaseConfig) {
|
||||||
DB::connect($databaseConfig);
|
DB::connect($databaseConfig);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user