@@ -69,7 +69,10 @@ public function test_should_load_ini_file()
6969 {
7070 $ config = new Config ;
7171 $ config ->fromIniFile ('tests/fixtures/config-test.ini ' );
72- $ this ->assertSame (include __DIR__ . '/fixtures/expected-ini-data.php ' , $ config ->section1 );
72+ $ this ->assertSame (
73+ include __DIR__ . '/fixtures/expected-ini-data.php ' ,
74+ $ config ->section1
75+ );
7376 }
7477
7578 /*
@@ -81,16 +84,17 @@ public function test_should_load_env_file_as_is()
8184 $ config = new Config ;
8285 $ config ->fromEnvFile (__DIR__ . '/fixtures/.env ' );
8386
84-
8587 // Scalar type values are preserved
8688 $ this ->assertSame (include __DIR__ . '/fixtures/expected-env-data.php ' , env ());
8789 $ this ->assertSame (42 , env ('KEY_1 ' ));
90+ $ this ->assertSame (null , env ('KEY_2 ' ), '.env key does not exist ' );
8891 $ this ->assertSame ('value3 ' , env ('KEY_3 ' ));
8992 $ this ->assertSame (true , env ('KEY_4 ' ));
9093 $ this ->assertSame (null , env ('KEY_5 ' ));
9194
9295 // ENV variable values are mutated to strings
9396 $ this ->assertSame ('42 ' , \getenv ('KEY_1 ' ));
97+ $ this ->assertSame (false , \getenv ('KEY_2 ' ), '.env key does not exist ' );
9498 $ this ->assertSame ('value3 ' , \getenv ('KEY_3 ' ));
9599 $ this ->assertSame ('1 ' , \getenv ('KEY_4 ' ));
96100 $ this ->assertSame ('null ' , \getenv ('KEY_5 ' ));
@@ -126,11 +130,13 @@ public function test_should_not_populate_global_env_array()
126130 $ config ->fromEnvFile (__DIR__ . '/fixtures/.env ' );
127131
128132 $ this ->assertArrayNotHasKey ('KEY_1 ' , $ _ENV );
133+ $ this ->assertArrayNotHasKey ('KEY_2 ' , $ _ENV );
129134 $ this ->assertArrayNotHasKey ('KEY_3 ' , $ _ENV );
130135 $ this ->assertArrayNotHasKey ('KEY_4 ' , $ _ENV );
131136 $ this ->assertArrayNotHasKey ('KEY_5 ' , $ _ENV );
132137
133138 $ this ->assertSame ('42 ' , \getenv ('KEY_1 ' , true ));
139+ $ this ->assertSame (false , \getenv ('KEY_2 ' , true ));
134140 $ this ->assertSame ('value3 ' , \getenv ('KEY_3 ' , true ));
135141 $ this ->assertSame ('1 ' , \getenv ('KEY_4 ' , true ));
136142 $ this ->assertSame ('null ' , \getenv ('KEY_5 ' , true ));
@@ -234,11 +240,15 @@ public function test_ini_sections_parsing()
234240 $ config ->fromIniFile (__DIR__ . '/fixtures/config-sections.ini ' );
235241 $ this ->assertSame (include_once __DIR__ . '/fixtures/config-sections.php ' , $ config ->toArray ());
236242 }
243+
244+ protected function tearDown (): void
245+ {
246+ env ('' , null , []);
247+ }
237248}
238249
239250class MockOtherConfigInstance extends Config
240251{
241-
242252 public function __construct ()
243253 {
244254 parent ::__construct ();
0 commit comments