From a28bee86ba1b980db6b76a01e804e51d240c4e3b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 14 Mar 2024 16:33:49 -0700 Subject: [PATCH] Extract method --- tests/TestCase.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 9bb7f56e17..f9f4dbae58 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,11 +24,7 @@ abstract class TestCase extends BaseTestCase protected function setUp(): void { - if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) { - throw new RuntimeException( - '.env.testing file does not exist. Aborting to avoid wiping your local database' - ); - } + $this->guardAgainstMissingEnv(); parent::setUp(); @@ -38,4 +34,13 @@ abstract class TestCase extends BaseTestCase $this->initializeSettings(); } + + private function guardAgainstMissingEnv(): void + { + if (!file_exists(realpath(__DIR__ . '/../') . '/.env.testing')) { + throw new RuntimeException( + '.env.testing file does not exist. Aborting to avoid wiping your local database.' + ); + } + } }