From d2fdf1d642068badae75fab04300f9a2eb044851 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Thu, 22 Apr 2021 21:44:03 +0200 Subject: [PATCH] Use getenv --- .tests/lib/BaseDatabaseTestCase.php | 8 ++++---- .tests/lib/UloggerAPITestCase.php | 4 ++-- .tests/lib/UloggerDatabaseTestCase.php | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.tests/lib/BaseDatabaseTestCase.php b/.tests/lib/BaseDatabaseTestCase.php index 71a1810..fcbb982 100644 --- a/.tests/lib/BaseDatabaseTestCase.php +++ b/.tests/lib/BaseDatabaseTestCase.php @@ -55,14 +55,14 @@ abstract class BaseDatabaseTestCase extends PHPUnit\DbUnit\TestCase { public static function setUpBeforeClass(): void { if (file_exists(__DIR__ . '/../.env')) { - $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); + $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..'); $dotenv->load(); $dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']); } - $db_dsn = $_ENV['DB_DSN']; - $db_user = $_ENV['DB_USER']; - $db_pass = $_ENV['DB_PASS']; + $db_dsn = getenv('DB_DSN'); + $db_user = getenv('DB_USER'); + $db_pass = getenv('DB_PASS'); // pdo connection if (self::$pdo == null) { diff --git a/.tests/lib/UloggerAPITestCase.php b/.tests/lib/UloggerAPITestCase.php index 0f5d7c8..e8fda69 100644 --- a/.tests/lib/UloggerAPITestCase.php +++ b/.tests/lib/UloggerAPITestCase.php @@ -15,12 +15,12 @@ class UloggerAPITestCase extends BaseDatabaseTestCase { public function setUp(): void { parent::setUp(); if (file_exists(__DIR__ . '/../.env')) { - $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); + $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..'); $dotenv->load(); $dotenv->required(['ULOGGER_URL']); } - $url = $_ENV['ULOGGER_URL']; + $url = getenv('ULOGGER_URL'); $this->http = new GuzzleHttp\Client([ 'base_uri' => $url, 'cookies' => true ]); } diff --git a/.tests/lib/UloggerDatabaseTestCase.php b/.tests/lib/UloggerDatabaseTestCase.php index c1b0c05..07a4bb3 100644 --- a/.tests/lib/UloggerDatabaseTestCase.php +++ b/.tests/lib/UloggerDatabaseTestCase.php @@ -17,14 +17,14 @@ class UloggerDatabaseTestCase extends BaseDatabaseTestCase { parent::setUpBeforeClass(); if (file_exists(__DIR__ . '/../.env')) { - $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); + $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..'); $dotenv->load(); $dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']); } - $db_dsn = $_ENV['DB_DSN']; - $db_user = $_ENV['DB_USER']; - $db_pass = $_ENV['DB_PASS']; + $db_dsn = getenv('DB_DSN'); + $db_user = getenv('DB_USER'); + $db_pass = getenv('DB_PASS'); // uDb connection if (self::$udb == null) {