File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -273,6 +273,8 @@ protected function tearDown(): void
273273
274274 // Check for other trait methods
275275 $ this ->callTraitMethods ('tearDown ' );
276+
277+ $ this ->resetIsWindowsMock ();
276278 }
277279
278280 /**
@@ -318,6 +320,14 @@ protected function resetServices(bool $initAutoloader = true)
318320 Services::reset ($ initAutoloader );
319321 }
320322
323+ /**
324+ * Resets the mocked is_windows() function back to default state.
325+ */
326+ protected function resetIsWindowsMock (): void
327+ {
328+ is_windows (null );
329+ }
330+
321331 /**
322332 * Injects the mock Cache driver to prevent filesystem collisions.
323333 *
Original file line number Diff line number Diff line change @@ -863,7 +863,7 @@ public function testIsWindowsUsingMock(): void
863863 $ this ->assertFalse (is_windows ());
864864 $ this ->assertNotTrue (is_windows ());
865865
866- is_windows ();
866+ is_windows (null );
867867 $ this ->assertSame (str_contains (php_uname (), 'Windows ' ), is_windows ());
868868 $ this ->assertSame (defined ('PHP_WINDOWS_VERSION_MAJOR ' ), is_windows ());
869869 }
Original file line number Diff line number Diff line change @@ -93,4 +93,29 @@ public function testCloseEnoughStringBadLength(): void
9393 $ result = $ this ->assertCloseEnoughString ('apples & oranges ' , 'apples ' );
9494 $ this ->assertFalse ($ result , 'Different string lengths should have returned false ' );
9595 }
96+
97+ public function testTearDownResetsIsWindowsMock (): void
98+ {
99+ $ testCase = new class ('test ' ) extends CIUnitTestCase {
100+ protected $ tearDownMethods = ['customTearDown ' ];
101+
102+ protected function customTearDown (): void
103+ {
104+ }
105+
106+ public function triggerTearDown (): void
107+ {
108+ $ this ->tearDown ();
109+ }
110+ };
111+
112+ $ default = DIRECTORY_SEPARATOR === '\\' ;
113+
114+ is_windows (! $ default );
115+ $ this ->assertSame (! $ default , is_windows ());
116+
117+ $ testCase ->triggerTearDown ();
118+
119+ $ this ->assertSame ($ default , is_windows ());
120+ }
96121}
You can’t perform that action at this time.
0 commit comments