1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Added initial support for parallel testing

This commit is contained in:
Dan Brown
2022-09-26 21:25:32 +01:00
parent aec772c5eb
commit e18033ec1a
5 changed files with 23 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Env;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Testing\Assert as PHPUnit;
use Monolog\Handler\TestHandler;
@@ -299,6 +300,8 @@ abstract class TestCase extends BaseTestCase
/**
* Run a set test with the given env variable.
* Remembers the original and resets the value after test.
* 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)
{
@@ -311,7 +314,12 @@ abstract class TestCase extends BaseTestCase
$_SERVER[$name] = $value;
}
$database = config('database.connections.mysql_testing.database');
$this->refreshApplication();
DB::purge();
config()->set('database.connections.mysql_testing.database', $database);
$callback();
if (is_null($originalVal)) {