Skip to content

Commit 12831c5

Browse files
Merge branch '3.6'
2 parents 939dfda + e9a7fac commit 12831c5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Validator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public function allowedValues(array $choices)
128128
{
129129
return $this->assertCallback(
130130
function ($value) use ($choices) {
131+
if ($value === null) {
132+
return true;
133+
}
134+
131135
return in_array($value, $choices, true);
132136
},
133137
sprintf('is not one of [%s]', implode(', ', $choices))

tests/Dotenv/ValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ public function testDotenvAllowedValuesIfPresent()
4141
$this->assertTrue(true);
4242
}
4343

44+
public function testDotenvAllowedValuesIfNotPresent()
45+
{
46+
$dotenv = Dotenv::create($this->fixturesFolder);
47+
$dotenv->load();
48+
$dotenv->ifPresent('FOOQWERTYOOOOOO')->allowedValues(['bar', 'baz']);
49+
$this->assertTrue(true);
50+
}
51+
4452
/**
4553
* @expectedException \Dotenv\Exception\ValidationException
4654
* @expectedExceptionMessage One or more environment variables failed assertions: FOO is not one of [buzz, buz].

0 commit comments

Comments
 (0)