Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1b8aa3c

Browse filesBrowse files
minor #43756 [Dotenv] Fix testBootEnv() to start from a fresh context (fancyweb)
This PR was merged into the 5.3 branch. Discussion ---------- [Dotenv] Fix testBootEnv() to start from a fresh context | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Same reason than #43692, needed by #43755. Commits ------- 417b9c2 [Dotenv] Fix testBootEnv() to start from a fresh context
2 parents cfd53c3 + 417b9c2 commit 1b8aa3c
Copy full SHA for 1b8aa3c

File tree

Expand file treeCollapse file tree

1 file changed

+11
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-5
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Tests/DotenvTest.php
+11-5Lines changed: 11 additions & 5 deletions
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.