Skip to content

Commit

Permalink
Merge pull request #106 from thomascombe/fix/dotv5-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot authored Nov 25, 2021
2 parents 01502be + 787a0eb commit e6d36fe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"larapack/dd": "^1.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "~3.5|~3.8",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.0|^8.0",
"predis/predis": "^1.1",
"scrutinizer/ocular": "^1.5"
},
Expand Down
20 changes: 20 additions & 0 deletions src/Checks/ExampleEnvironmentVariablesAreSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function name(array $config): string
*/
public function check(array $config): bool
{
if (method_exists(Dotenv::class, 'createUnsafeImmutable')) {
return $this->checkForDotEnvV5();
}
if (method_exists(Dotenv::class, 'createImmutable')) {
return $this->checkForDotEnvV4();
}
Expand Down Expand Up @@ -67,6 +70,23 @@ private function checkForDotEnvV4(): bool
return $this->envVariables->isEmpty();
}

/**
* Perform the verification of this check for DotEnv v5.
*
* @return bool
*/
private function checkForDotEnvV5(): bool
{
$examples = Dotenv::createMutable(base_path(), '.env.example');
$actual = Dotenv::createMutable(base_path(), '.env');

$this->envVariables = Collection::make($examples->safeLoad())
->diffKeys($actual->safeLoad())
->keys();

return $this->envVariables->isEmpty();
}

/**
* The error message to display in case the check does not pass.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/CorrectPhpVersionIsInstalledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_accepts_version_with_asterix()

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

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

$fileSystemMock->shouldReceive('get')
->andReturn($data);
Expand Down

0 comments on commit e6d36fe

Please sign in to comment.