Skip to content

Commit 4ae5893

Browse files
authored
[12.x] Fix WithCachedConfig to work with parallel test runs (laravel#57785)
* Update TestCase.php * test * Update TestCase.php
1 parent ee3af91 commit 4ae5893

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Illuminate/Testing/Concerns/TestDatabases.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ trait TestDatabases
1919
*/
2020
protected static $schemaIsUpToDate = false;
2121

22+
/**
23+
* The root database name prior to concatenating the token.
24+
*
25+
* @var null|string
26+
*/
27+
protected static $originalDatabaseName = null;
28+
2229
/**
2330
* Boot a test database.
2431
*
@@ -186,6 +193,12 @@ protected function switchToDatabase($database)
186193
*/
187194
protected function testDatabase($database)
188195
{
196+
if (! isset(self::$originalDatabaseName)) {
197+
self::$originalDatabaseName = $database;
198+
} else {
199+
$database = self::$originalDatabaseName;
200+
}
201+
189202
$token = ParallelTesting::token();
190203

191204
return "{$database}_test_{$token}";

0 commit comments

Comments
 (0)