diff --git a/.travis.yml b/.travis.yml index f3b5e35..34f3c2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: php +dist: trusty php: + - "7.4" + - "7.3" + - "7.2" - "7.1" - - "7.0" - - "5.6" - - "5.5" - - "5.4" install: - sudo apt-get update diff --git a/composer.json b/composer.json index f2afa34..2dd69e9 100644 --- a/composer.json +++ b/composer.json @@ -1,21 +1,30 @@ { - "name": "codemix/yii2-configloader", - "description": "Build configuration arrays from config files and env vars.", - "keywords": ["yii2", "config", "environment"], - "license": "MIT", - "authors": [ - { - "name": "Michael Härtl", - "email": "haertl.mike@gmail.com" - } - ], - "require": { - "yiisoft/yii2": "*", - "vlucas/phpdotenv": "2.5.*" - }, - "autoload": { - "psr-4": { - "codemix\\yii2confload\\": "src/" - } + "name": "codemix/yii2-configloader", + "description": "Build configuration arrays from config files and env vars.", + "keywords": ["yii2", "config", "environment"], + "license": "MIT", + "authors": [ + { + "name": "Michael Härtl", + "email": "haertl.mike@gmail.com" } + ], + "require": { + "php": "^7.1.3 || ^8.0", + "yiisoft/yii2": "*", + "vlucas/phpdotenv": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": ">4.0 <8" + }, + "autoload": { + "psr-4": { + "codemix\\yii2confload\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "tests\\": "tests" + } + } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 79b8204..a814c26 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="true" stopOnFailure="false" - syntaxCheck="false" bootstrap="tests/bootstrap.php" > diff --git a/src/Config.php b/src/Config.php index c2b8ec4..99ea28b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -231,7 +231,7 @@ public static function bootstrap($directory, $vendor = null, $initEnv = true) public static function initEnv($directory = null) { if ($directory !== null && file_exists($directory . DIRECTORY_SEPARATOR . '.env')) { - $dotenv = new \Dotenv\Dotenv($directory); + $dotenv = \Dotenv\Dotenv::createImmutable($directory); $dotenv->load(); } diff --git a/tests/BootstrapTest.php b/tests/BootstrapTest.php index 8b4ebec..42c21e6 100644 --- a/tests/BootstrapTest.php +++ b/tests/BootstrapTest.php @@ -1,7 +1,10 @@ assertEquals(654, Config::env('TEST1')); + $this->assertEquals('654', Config::env('TEST1')); $this->assertEquals('xyz', Config::env('TEST2')); $this->assertEquals('dotenv1', Config::env('VAR1')); $this->assertEquals(2, Config::env('VAR2')); @@ -71,13 +74,13 @@ public function testEnvFileDoesNotClearEnvVars() public function testEnvFileDoesNotOverrideEnvVars() { - putenv('VAR1=654'); - putenv('VAR2=xyz'); + $_ENV['VAR1'] = '654'; + $_ENV['VAR2'] = 'xyz'; Config::initEnv(__DIR__ . '/app'); $this->assertEquals(0, Config::env('YII_DEBUG')); $this->assertEquals('dev', Config::env('YII_ENV')); - $this->assertEquals(654, Config::env('VAR1')); + $this->assertEquals('654', Config::env('VAR1')); $this->assertEquals('xyz', Config::env('VAR2')); } diff --git a/tests/WebConfigTest.php b/tests/WebConfigTest.php index 75438b4..67b9a49 100644 --- a/tests/WebConfigTest.php +++ b/tests/WebConfigTest.php @@ -1,7 +1,10 @@