From 4a1ebbc06513613db745620d9715e1df650f0e6b Mon Sep 17 00:00:00 2001 From: Marco Deleu Date: Mon, 10 Jul 2023 16:05:35 -0300 Subject: [PATCH 1/2] Fix parallel testing without any database connection --- .../Testing/Concerns/TestDatabases.php | 4 +++ .../TestWithoutDatabaseParallelTest.php | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/Integration/Testing/TestWithoutDatabaseParallelTest.php diff --git a/src/Illuminate/Testing/Concerns/TestDatabases.php b/src/Illuminate/Testing/Concerns/TestDatabases.php index 3b429a2937ec..d347c336c7de 100644 --- a/src/Illuminate/Testing/Concerns/TestDatabases.php +++ b/src/Illuminate/Testing/Concerns/TestDatabases.php @@ -141,6 +141,10 @@ protected function usingDatabase($database, $callable) */ protected function whenNotUsingInMemoryDatabase($callback) { + if (ParallelTesting::option('without_databases')) { + return; + } + $database = DB::getConfig('database'); if ($database !== ':memory:') { diff --git a/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php new file mode 100644 index 000000000000..b8fffb98a79d --- /dev/null +++ b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php @@ -0,0 +1,29 @@ +app['config']->set('database.default', null); + + // When we run parallel testing with `without-databases` option + $_SERVER['LARAVEL_PARALLEL_TESTING'] = 1; + $_SERVER['LARAVEL_PARALLEL_TESTING_WITHOUT_DATABASES'] = 1; + $_SERVER['TEST_TOKEN'] = '1'; + + // We should not create a database connection to check if it's SQLite or not. + ParallelTesting::callSetUpProcessCallbacks(); + } + +} From 15dd5f700ac5e4965f4121fa77a6a7dfa767ae73 Mon Sep 17 00:00:00 2001 From: Marco Deleu Date: Mon, 10 Jul 2023 16:28:41 -0300 Subject: [PATCH 2/2] StyleCI --- .../Integration/Testing/TestWithoutDatabaseParallelTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php index b8fffb98a79d..4735083bdea5 100644 --- a/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php +++ b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php @@ -1,4 +1,4 @@ -