Skip to content

Commit 20141d2

Browse files
committed
Upgrade to DotEnv 5.x
1 parent 7e628f2 commit 20141d2

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"yiisoft/yii2": "*",
14-
"vlucas/phpdotenv": "2.5.*"
14+
"vlucas/phpdotenv": "^5.0"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": ">4.0 <8"

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="true"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="tests/bootstrap.php"
1312
>
1413
<testsuites>

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static function bootstrap($directory, $vendor = null, $initEnv = true)
231231
public static function initEnv($directory = null)
232232
{
233233
if ($directory !== null && file_exists($directory . DIRECTORY_SEPARATOR . '.env')) {
234-
$dotenv = new \Dotenv\Dotenv($directory);
234+
$dotenv = \Dotenv\Dotenv::createImmutable($directory);
235235
$dotenv->load();
236236
}
237237

tests/EnvTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public function testCanGetEnvVarsFromEnvFile()
6161

6262
public function testEnvFileDoesNotClearEnvVars()
6363
{
64-
putenv('TEST1=654');
65-
putenv('TEST2=xyz');
64+
$_ENV['TEST1'] = '654';
65+
$_ENV['TEST2'] = 'xyz';
6666
Config::initEnv(__DIR__ . '/app');
6767

68-
$this->assertEquals(654, Config::env('TEST1'));
68+
$this->assertEquals('654', Config::env('TEST1'));
6969
$this->assertEquals('xyz', Config::env('TEST2'));
7070
$this->assertEquals('dotenv1', Config::env('VAR1'));
7171
$this->assertEquals(2, Config::env('VAR2'));
@@ -74,13 +74,13 @@ public function testEnvFileDoesNotClearEnvVars()
7474

7575
public function testEnvFileDoesNotOverrideEnvVars()
7676
{
77-
putenv('VAR1=654');
78-
putenv('VAR2=xyz');
77+
$_ENV['VAR1'] = '654';
78+
$_ENV['VAR2'] = 'xyz';
7979
Config::initEnv(__DIR__ . '/app');
8080

8181
$this->assertEquals(0, Config::env('YII_DEBUG'));
8282
$this->assertEquals('dev', Config::env('YII_ENV'));
83-
$this->assertEquals(654, Config::env('VAR1'));
83+
$this->assertEquals('654', Config::env('VAR1'));
8484
$this->assertEquals('xyz', Config::env('VAR2'));
8585
}
8686

0 commit comments

Comments
 (0)