Skip to content

Commit

Permalink
Merge pull request #6 from kirschbaum-development/handle-boolean-conf…
Browse files Browse the repository at this point in the history
…ig-values

Properly handle boolean config values set to `false`
  • Loading branch information
victorsfleite authored Feb 20, 2024
2 parents c82edec + e407b34 commit f7cbb2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Checks/PreflightCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ protected function checkConfig(Result $result): Result
$missingKeys = [];

foreach ($this->requiredConfig as $configKey) {
if (! config()->has($configKey) || empty(config($configKey))) {
$configValue = config($configKey);

if (! is_bool($configValue) && empty($configValue)) {
$missingKeys[] = $configKey;
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Checks/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ public function testPassesWhenConfigIsSet()
$this->assertPassed($result);
}

/**
* @test
*/
public function testPassesWhenConfigIsBooleanAndSetToFalse()
{
$config = ['test1' => false];
config($config);
$preflightCheck = new Configuration(array_keys($config));

$result = $preflightCheck->check(new Result('Test\Test'));
$this->assertPassed($result);
}

/**
* @test
*/
Expand Down

0 comments on commit f7cbb2a

Please sign in to comment.