From d670ff13ef9211e09c21fd22116375e2051a92f7 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 18 Sep 2024 15:38:44 +1200 Subject: [PATCH] FIX Ensure primary connection is updated with temporary database --- src/TestSessionEnvironment.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TestSessionEnvironment.php b/src/TestSessionEnvironment.php index dcd1405..74ceac9 100644 --- a/src/TestSessionEnvironment.php +++ b/src/TestSessionEnvironment.php @@ -578,6 +578,10 @@ public function connectToDatabase($state = null) $this->oldDatabaseName = $databaseConfig['database']; $databaseConfig['database'] = $state->database; DB::connect($databaseConfig); + // This is required for CMS 5.4+ + if (method_exists(DB::class, 'hasConfig') && DB::hasConfig('primary')) { + DB::connect($databaseConfig, 'primary'); + } } } }