From 94af2adcc729f9a0c347cba0eb5fc3be643a4603 Mon Sep 17 00:00:00 2001 From: madmatt Date: Wed, 11 Sep 2019 23:30:10 +1200 Subject: [PATCH] FIX: Ensure TempDatabase->build() doesn't tear down the database after the testsession start request --- src/TestSessionEnvironment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TestSessionEnvironment.php b/src/TestSessionEnvironment.php index e8e8bf0..ae7af83 100644 --- a/src/TestSessionEnvironment.php +++ b/src/TestSessionEnvironment.php @@ -277,6 +277,9 @@ class TestSessionEnvironment $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();