Skip to content

Commit e6d36fe

Browse files
authored
Merge pull request #106 from thomascombe/fix/dotv5-cache
2 parents 01502be + 787a0eb commit e6d36fe

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"larapack/dd": "^1.0",
2727
"mockery/mockery": "^1.0",
2828
"orchestra/testbench": "~3.5|~3.8",
29-
"phpunit/phpunit": "^7.0",
29+
"phpunit/phpunit": "^7.0|^8.0",
3030
"predis/predis": "^1.1",
3131
"scrutinizer/ocular": "^1.5"
3232
},

src/Checks/ExampleEnvironmentVariablesAreSet.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public function name(array $config): string
2929
*/
3030
public function check(array $config): bool
3131
{
32+
if (method_exists(Dotenv::class, 'createUnsafeImmutable')) {
33+
return $this->checkForDotEnvV5();
34+
}
3235
if (method_exists(Dotenv::class, 'createImmutable')) {
3336
return $this->checkForDotEnvV4();
3437
}
@@ -67,6 +70,23 @@ private function checkForDotEnvV4(): bool
6770
return $this->envVariables->isEmpty();
6871
}
6972

73+
/**
74+
* Perform the verification of this check for DotEnv v5.
75+
*
76+
* @return bool
77+
*/
78+
private function checkForDotEnvV5(): bool
79+
{
80+
$examples = Dotenv::createMutable(base_path(), '.env.example');
81+
$actual = Dotenv::createMutable(base_path(), '.env');
82+
83+
$this->envVariables = Collection::make($examples->safeLoad())
84+
->diffKeys($actual->safeLoad())
85+
->keys();
86+
87+
return $this->envVariables->isEmpty();
88+
}
89+
7090
/**
7191
* The error message to display in case the check does not pass.
7292
*

tests/CorrectPhpVersionIsInstalledTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function it_accepts_version_with_asterix()
6060

6161
$data = file_get_contents(__DIR__ . '/fixtures/composer.json');
6262

63-
$data = str_replace('"php": "^7.1.3",', '"php": "7.*",', $data);
63+
$data = str_replace('"php": "^7.1.3",', '"php": "7.*|8.*",', $data);
6464

6565
$fileSystemMock->shouldReceive('get')
6666
->andReturn($data);

0 commit comments

Comments
 (0)