8000 [Dotenv] Fix testBootEnv() to start from a fresh context · symfony/symfony@417b9c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 417b9c2

Browse files
committed
[Dotenv] Fix testBootEnv() to start from a fresh context
1 parent cfd53c3 commit 417b9c2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,30 @@ public function testDoNotUsePutenv()
485485

486486
public function testBootEnv()
487487
{
488+
$resetContext = static function (): void {
489+
unset($_SERVER['SYMFONY_DOTENV_VARS'], $_ENV['SYMFONY_DOTENV_VARS']);
490+
unset($_SERVER['TEST_APP_ENV'], $_ENV['TEST_APP_ENV']);
491+
unset($_SERVER['TEST_APP_DEBUG'], $_ENV['TEST_APP_DEBUG']);
492+
unset($_SERVER['FOO'], $_ENV['FOO']);
493+
};
494+
488495
@mkdir($tmpdir = sys_get_temp_dir().'/dotenv');
489496
$path = tempnam($tmpdir, 'sf-');
490497

491498
file_put_contents($path, 'FOO=BAR');
499+
$resetContext();
492500
(new Dotenv('TEST_APP_ENV', 'TEST_APP_DEBUG'))->bootEnv($path);
493-
494501
$this->assertSame('BAR', $_SERVER['FOO']);
495-
496-
unset($_SERVER['FOO'], $_ENV['FOO']);
497502
unlink($path);
498503

499504
file_put_contents($path.'.local.php', '<?php return ["TEST_APP_ENV" => "dev", "FOO" => "BAR"];');
505+
$resetContext();
500506
(new Dotenv('TEST_APP_ENV', 'TEST_APP_DEBUG'))->bootEnv($path);
501507
$this->assertSame('BAR', $_SERVER['FOO']);
502508
$this->assertSame('1', $_SERVER['TEST_APP_DEBUG']);
503-
504-
unset($_SERVER['FOO'], $_ENV['FOO']);
505509
unlink($path.'.local.php');
510+
511+
$resetContext();
506512
rmdir($tmpdir);
507513
}
508514
}

0 commit comments

Comments
 (0)
0