From 15db8e47538c642592972c41b2da0ae710bd4213 Mon Sep 17 00:00:00 2001 From: Ron Northrip Date: Thu, 14 Mar 2024 18:01:16 -0400 Subject: [PATCH] Cleanup connection in env setup --- tests/TestCase.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index e574938..1bf4b1c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -28,15 +28,18 @@ protected function getPackageProviders($app) public function getEnvironmentSetUp($app) { - config()->set('database.connections.testing', [ - 'driver' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'dbpull_test', - 'username' => 'root', - 'password' => '', - ]); + $connection = [ + 'driver' => env('DB_CONNECTION','mysql'), + 'host' => env('DB_HOST','127.0.0.1'), + 'port' => env('DB_PORT','3306'), + 'database' => env('DB_DATABASE','dbpull_test'), + 'username' => env('DB_USERNAME','root'), + ]; + if (env('DB_PASSWORD')) { + $connection['password'] = env('DB_PASSWORD'); + } + config()->set('database.connections.testing', $connection); config()->set('database.default', 'testing'); /*