X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/05f7f4cb17470b2bdc898cf7e99781d0509c0bf8..refs/pull/5721/head:/tests/TestCase.php diff --git a/tests/TestCase.php b/tests/TestCase.php index 0fb899ea9..a8636fb15 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -118,15 +118,18 @@ abstract class TestCase extends BaseTestCase * Database config is juggled so the value can be restored when * parallel testing are used, where multiple databases exist. */ - protected function runWithEnv(string $name, $value, callable $callback, bool $handleDatabase = true) + protected function runWithEnv(array $valuesByKey, callable $callback, bool $handleDatabase = true): void { Env::disablePutenv(); - $originalVal = $_SERVER[$name] ?? null; - - if (is_null($value)) { - unset($_SERVER[$name]); - } else { - $_SERVER[$name] = $value; + $originals = []; + foreach ($valuesByKey as $key => $value) { + $originals[$key] = $_SERVER[$key] ?? null; + + if (is_null($value)) { + unset($_SERVER[$key]); + } else { + $_SERVER[$key] = $value; + } } $database = config('database.connections.mysql_testing.database'); @@ -144,10 +147,12 @@ abstract class TestCase extends BaseTestCase DB::rollBack(); } - if (is_null($originalVal)) { - unset($_SERVER[$name]); - } else { - $_SERVER[$name] = $originalVal; + foreach ($originals as $key => $value) { + if (is_null($value)) { + unset($_SERVER[$key]); + } else { + $_SERVER[$key] = $value; + } } }