From 5985650e90a323133d1de8f3d632bf0c45703dc6 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 11 Jul 2023 15:06:49 +0800 Subject: [PATCH] [10.x] Test Improvements (#47709) * [10.x] Test Improvements fixes failing tests. Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki --------- Signed-off-by: Mior Muhammad Zaki --- .../TestWithoutDatabaseParallelTest.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php index 4735083bdea5..3e24bf2f51a7 100644 --- a/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php +++ b/tests/Integration/Testing/TestWithoutDatabaseParallelTest.php @@ -13,16 +13,33 @@ protected function getPackageProviders($app) return [ParallelTestingServiceProvider::class]; } - public function testRunningParallelTestWithoutDatabaseShouldNotCrashOnDefaultConnection() + /** + * Define the test environment. + * + * @param \Illuminate\Foundation\Application $app + * @return void + */ + protected function defineEnvironment($app) { // Given an application that does not use database connections at all - $this->app['config']->set('database.default', null); + $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'; + $this->beforeApplicationDestroyed(function () { + unset( + $_SERVER['LARAVEL_PARALLEL_TESTING'], + $_SERVER['LARAVEL_PARALLEL_TESTING_WITHOUT_DATABASES'], + $_SERVER['TEST_TOKEN'], + ); + }); + } + + public function testRunningParallelTestWithoutDatabaseShouldNotCrashOnDefaultConnection() + { // We should not create a database connection to check if it's SQLite or not. ParallelTesting::callSetUpProcessCallbacks(); }