Make 'database' state optional

This commit is contained in:
Ingo Schommer 2014-02-27 14:46:23 +13:00
parent add47cb625
commit 2c12cde90a

View File

@ -128,6 +128,7 @@ class TestSessionEnvironment extends Object {
}
}
if(isset($state->database) && $state->database) {
if(!DB::getConn()) {
// No connection, so try and connect to tmpdb if it exists
if(isset($state->database)) {
@ -146,6 +147,7 @@ class TestSessionEnvironment extends Object {
DB::connect($databaseConfig);
}
}
}
// Database
if(!$this->isRunningTests() && (@$state->createDatabase || @$state->database)) {
@ -246,11 +248,6 @@ class TestSessionEnvironment extends Object {
$contents = file_get_contents(Director::getAbsFile($this->config()->test_state_file));
$json = json_decode($contents);
if(!isset($json->database)) {
throw new \LogicException('The test session file ('
. Director::getAbsFile($this->config()->test_state_file) . ') doesn\'t contain a database name.');
}
$this->applyState($json);
} catch(Exception $e) {
throw new \Exception("A test session appears to be in progress, but we can't retrieve the details. "