Use getenv

This commit is contained in:
Bartek Fabiszewski 2021-04-22 21:44:03 +02:00
parent 72e89edd4d
commit d2fdf1d642
3 changed files with 10 additions and 10 deletions

View File

@ -55,14 +55,14 @@ abstract class BaseDatabaseTestCase extends PHPUnit\DbUnit\TestCase {
public static function setUpBeforeClass(): void { public static function setUpBeforeClass(): void {
if (file_exists(__DIR__ . '/../.env')) { if (file_exists(__DIR__ . '/../.env')) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..');
$dotenv->load(); $dotenv->load();
$dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']); $dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']);
} }
$db_dsn = $_ENV['DB_DSN']; $db_dsn = getenv('DB_DSN');
$db_user = $_ENV['DB_USER']; $db_user = getenv('DB_USER');
$db_pass = $_ENV['DB_PASS']; $db_pass = getenv('DB_PASS');
// pdo connection // pdo connection
if (self::$pdo == null) { if (self::$pdo == null) {

View File

@ -15,12 +15,12 @@ class UloggerAPITestCase extends BaseDatabaseTestCase {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();
if (file_exists(__DIR__ . '/../.env')) { if (file_exists(__DIR__ . '/../.env')) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..');
$dotenv->load(); $dotenv->load();
$dotenv->required(['ULOGGER_URL']); $dotenv->required(['ULOGGER_URL']);
} }
$url = $_ENV['ULOGGER_URL']; $url = getenv('ULOGGER_URL');
$this->http = new GuzzleHttp\Client([ 'base_uri' => $url, 'cookies' => true ]); $this->http = new GuzzleHttp\Client([ 'base_uri' => $url, 'cookies' => true ]);
} }

View File

@ -17,14 +17,14 @@ class UloggerDatabaseTestCase extends BaseDatabaseTestCase {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
if (file_exists(__DIR__ . '/../.env')) { if (file_exists(__DIR__ . '/../.env')) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__ . '/..');
$dotenv->load(); $dotenv->load();
$dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']); $dotenv->required(['DB_DSN', 'DB_USER', 'DB_PASS']);
} }
$db_dsn = $_ENV['DB_DSN']; $db_dsn = getenv('DB_DSN');
$db_user = $_ENV['DB_USER']; $db_user = getenv('DB_USER');
$db_pass = $_ENV['DB_PASS']; $db_pass = getenv('DB_PASS');
// uDb connection // uDb connection
if (self::$udb == null) { if (self::$udb == null) {