8000 [Dotenv] clean up before running assertions · symfony/symfony@baafc7b · GitHub
[go: up one dir, main page]

Skip to content

Commit baafc7b

Browse files
committed
[Dotenv] clean up before running assertions
If one of the assertions failed, the clean up part would never happen.
1 parent 8b6cb57 commit baafc7b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ public function getEnvData()
148148

149149
public function testLoad()
150150
{
151+
unset($_ENV['FOO']);
152+
unset($_ENV['BAR']);
153+
unset($_SERVER['FOO']);
154+
unset($_SERVER['BAR']);
155+
putenv('FOO');
156+
putenv('BAR');
157+
151158
@mkdir($tmpdir = sys_get_temp_dir().'/dotenv');
152159

153160
$path1 = tempnam($tmpdir, 'sf-');
@@ -158,14 +165,17 @@ public function testLoad()
158165

159166
(new DotEnv())->load($path1, $path2);
160167< 8000 /td>

161-
$this->assertSame('BAR', getenv('FOO'));
162-
$this->assertSame('BAZ', getenv('BAR'));
168+
$foo = getenv('FOO');
169+
$bar = getenv('BAR');
163170

164171
putenv('FOO');
165172
putenv('BAR');
166173
unlink($path1);
167174
unlink($path2);
168175
rmdir($tmpdir);
176+
177+
$this->assertSame('BAR', $foo);
178+
$this->assertSame('BAZ', $bar);
169179
}
170180

171181
/**

0 commit comments

Comments
 (0)
< 2A66 /div>
0