2020use Config \Logger as LoggerConfig ;
2121use Config \Session as SessionConfig ;
2222use PHPUnit \Framework \Attributes \Group ;
23+ use PHPUnit \Framework \Attributes \RequiresOperatingSystem ;
2324use Tests \Support \Session \FaultyStream ;
2425use Tests \Support \Session \FileHandlerCloseFail ;
2526
@@ -36,13 +37,15 @@ final class FileHandlerTest extends CIUnitTestCase
3637 private string $ originalSavePath ;
3738 private string $ originalSidBits ;
3839 private string $ originalSidLength ;
40+ private bool $ registeredFaultyStream = false ;
3941
4042 protected function setUp (): void
4143 {
4244 parent ::setUp ();
4345
4446 if (! in_array ('faulty ' , stream_get_wrappers (), true )) {
4547 stream_wrapper_register ('faulty ' , FaultyStream::class);
48+ $ this ->registeredFaultyStream = true ;
4649 }
4750
4851 $ this ->originalSavePath = (string ) ini_get ('session.save_path ' );
@@ -63,6 +66,11 @@ protected function tearDown(): void
6366
6467 FaultyStream::reset ();
6568
69+ if ($ this ->registeredFaultyStream && in_array ('faulty ' , stream_get_wrappers (), true )) {
70+ stream_wrapper_unregister ('faulty ' );
71+ $ this ->registeredFaultyStream = false ;
72+ }
73+
6674 $ this ->removeDirectory ($ this ->tempPath );
6775 }
6876
@@ -226,6 +234,7 @@ public function testOpenThrowsForInvalidSavePath(): void
226234 $ this ->withSuppressedErrors (fn (): bool => $ handler ->open ($ this ->tempPath . '/blocker/sub ' , $ this ->sessionName ));
227235 }
228236
237+ #[RequiresOperatingSystem('Linux|Darwin ' )]
229238 public function testOpenThrowsForWriteProtectedSavePath (): void
230239 {
231240 $ dir = $ this ->tempPath . '/readonly ' ;
@@ -517,6 +526,7 @@ public function testGCWhenSavePathMissing(): void
517526 $ this ->assertLogContains ('debug ' , "Session: Garbage collector couldn't list files under directory " );
518527 }
519528
529+ #[RequiresOperatingSystem('Linux|Darwin ' )]
520530 public function testGCWhenDirectoryCannotBeOpened (): void
521531 {
522532 $ dir = $ this ->tempPath . '/unreadable ' ;
0 commit comments