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'); + } } } }