@@ -30,34 +30,49 @@ protected function tearDown(): void
3030 #[Test]
3131 public function config_returns_global_config_when_no_override_is_set (): void
3232 {
33- // Ensure CONFIG_OVERRIDE is not set
3433 config (['app.env ' => 'testing ' ]);
34+
35+ // Parse the config as-is
36+ $ config_original = include config_path ('base.php ' );
37+
38+ // If CONFIG_OVERRIDE is defined with no value
3539 putenv ('CONFIG_OVERRIDE= ' );
3640
37- $ config = include config_path ('base.php ' );
41+ // Re-parse the base config
42+ $ config_updated = include config_path ('base.php ' );
3843
39- $ this ->assertIsArray ($ config );
40- $ this ->assertEquals ('GTM-NCBVKQ2 ' , $ config ['gtm_code ' ]);
41- $ this ->assertEquals ('contained-hero ' , $ config ['layout ' ]);
42- $ this ->assertFalse ($ config ['top_menu_enabled ' ]);
44+ // Ensure the app config was not modified
45+ $ this ->assertIsArray ($ config_updated );
46+ $ this ->assertEquals ($ config_original ['gtm_code ' ], $ config_updated ['gtm_code ' ]);
47+ $ this ->assertEquals ($ config_original ['layout ' ], $ config_updated ['layout ' ]);
48+ $ this ->assertEquals ($ config_original ['top_menu_enabled ' ], $ config_updated ['top_menu_enabled ' ]);
4349 }
4450
4551 #[Test]
4652 public function config_returns_global_config_when_override_file_does_not_exist (): void
4753 {
54+ // Parse the config as-is
55+ $ config_original = include config_path ('base.php ' );
56+
4857 // Set CONFIG_OVERRIDE to non-existent file
4958 putenv ('CONFIG_OVERRIDE=non-existent-file.php ' );
5059
51- $ config = include config_path ('base.php ' );
60+ // Re-parse the base config
61+ $ config_updated = include config_path ('base.php ' );
5262
53- $ this ->assertIsArray ($ config );
54- $ this ->assertEquals ('GTM-NCBVKQ2 ' , $ config ['gtm_code ' ]);
55- $ this ->assertEquals ('contained-hero ' , $ config ['layout ' ]);
63+ // Ensure the app config was not modified
64+ $ this ->assertIsArray ($ config_updated );
65+ $ this ->assertEquals ($ config_original ['gtm_code ' ], $ config_updated ['gtm_code ' ]);
66+ $ this ->assertEquals ($ config_original ['layout ' ], $ config_updated ['layout ' ]);
67+ $ this ->assertEquals ($ config_original ['top_menu_enabled ' ], $ config_updated ['top_menu_enabled ' ]);
5668 }
5769
5870 #[Test]
5971 public function config_merges_override_file_when_it_exists (): void
6072 {
73+ // Parse the config as-is
74+ $ config_original = include config_path ('base.php ' );
75+
6176 // Create a test override file
6277 $ overrideContent = '<?php
6378return [
@@ -81,7 +96,7 @@ public function config_merges_override_file_when_it_exists(): void
8196 $ this ->assertEquals ('test_value ' , $ config ['new_config_key ' ]);
8297
8398 // Ensure non-overridden values remain
84- $ this ->assertEquals (' @waynestate ' , $ config ['twitter_handle ' ]);
99+ $ this ->assertEquals ($ config_original [ ' twitter_handle ' ] , $ config ['twitter_handle ' ]);
85100 }
86101
87102 #[Test]
@@ -139,6 +154,9 @@ public function config_recursively_merges_nested_arrays(): void
139154 #[Test]
140155 public function config_handles_empty_override_file (): void
141156 {
157+ // Parse the config as-is
158+ $ config_original = include config_path ('base.php ' );
159+
142160 // Create empty override file
143161 $ overrideContent = '<?php
144162return []; ' ;
@@ -150,8 +168,8 @@ public function config_handles_empty_override_file(): void
150168
151169 // Should return the global config unchanged
152170 $ this ->assertIsArray ($ config );
153- $ this ->assertEquals (' GTM-NCBVKQ2 ' , $ config ['gtm_code ' ]);
154- $ this ->assertEquals (' contained-hero ' , $ config ['layout ' ]);
171+ $ this ->assertEquals ($ config [ ' gtm_code ' ] , $ config ['gtm_code ' ]);
172+ $ this ->assertEquals ($ config [ ' layout ' ] , $ config ['layout ' ]);
155173 }
156174
157175 #[Test]
0 commit comments