Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Ensure TempDatabase->build() doesn't tear down the database #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/TestSessionEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SilverStripe\Control\Email\Email;
use SilverStripe\Control\Email\Mailer;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Extensible;
Expand Down Expand Up @@ -277,6 +278,9 @@ public function createDatabase($state)
$databaseConfig = DB::getConfig();
if (!$dbExists && $dbCreate) {
$this->oldDatabaseName = $databaseConfig['database'];
// Ensure we don't allow TempDatabase to immediately kill the newly created DB when the request finishes
Config::modify()->set(TempDatabase::class, 'teardown_on_exit', false);

// Create a new one with a randomized name
$tempDB = TempDatabase::create();
$dbName = $tempDB->build();
Expand Down