clean up team db after test session run

This commit is contained in:
Jeffrey Guo 2015-12-18 15:32:20 +13:00
parent 5167be8d96
commit 2b21b068ce

View File

@ -362,6 +362,15 @@ class TestSessionEnvironment extends Object
$this->extend('onBeforeEndTestSession'); $this->extend('onBeforeEndTestSession');
if (SapphireTest::using_temp_db()) { if (SapphireTest::using_temp_db()) {
$state = $this->getState();
$dbConn = DB::getConn();
$dbExists = $dbConn->databaseExists($state->database);
if($dbExists) {
// Clean up temp database
$dbConn->dropDatabase();
file_put_contents('php://stdout', "Deleted temp database: $state->database" . PHP_EOL);
}
// End test session mode
$this->resetDatabaseName(); $this->resetDatabaseName();
SapphireTest::set_is_running_test(false); SapphireTest::set_is_running_test(false);