@@ -188,6 +188,36 @@ public function testFlushRemovesAllFiles()
188188 $ this ->assertSame ('Settings Test ' , $ this ->settings ->get ('Example.siteName ' ));
189189 }
190190
191+ public function testFlushRemovesFilesAndContextDirectories ()
192+ {
193+ // Create files in main directory (null context)
194+ $ this ->settings ->set ('Example.siteName ' , 'Main ' );
195+ $ this ->settings ->set ('Example.siteEmail ' , 'main@example.com ' );
196+
197+ // Create files in context subdirectories
198+ $ this ->settings ->set ('Example.siteName ' , 'Production ' , 'production ' );
199+ $ this ->settings ->set ('Example.siteTitle ' , 'Prod Site ' , 'production ' );
200+ $ this ->settings ->set ('Example.siteName ' , 'Testing ' , 'testing ' );
201+
202+ $ mainFiles = glob ($ this ->path . '*.php ' , GLOB_NOSORT );
203+ $ this ->assertNotEmpty ($ mainFiles );
204+
205+ $ directories = glob ($ this ->path . '* ' , GLOB_ONLYDIR | GLOB_NOSORT );
206+ $ this ->assertCount (2 , $ directories ); // production and testing
207+
208+ $ this ->settings ->flush ();
209+
210+ $ mainFiles = glob ($ this ->path . '*.php ' , GLOB_NOSORT );
211+ $ this ->assertEmpty ($ mainFiles );
212+
213+ $ directories = glob ($ this ->path . '* ' , GLOB_ONLYDIR | GLOB_NOSORT );
214+ $ this ->assertEmpty ($ directories );
215+
216+ // Should be back to default values
217+ $ this ->assertSame ('Settings Test ' , $ this ->settings ->get ('Example.siteName ' ));
218+ $ this ->assertSame ('Settings Test ' , $ this ->settings ->get ('Example.siteName ' , 'production ' ));
219+ }
220+
191221 public function testSetWithContext ()
192222 {
193223 $ this ->settings ->set ('Example.siteName ' , 'Banana ' , 'environment:test ' );
0 commit comments