diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index d86e543a9a61..ced4f13c6c78 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -69,7 +69,9 @@ abstract class CIUnitTestCase extends TestCase * * @var list array of methods */ - protected $tearDownMethods = []; + protected $tearDownMethods = [ + 'resetIsWindowsMock', + ]; /** * Store of identified traits. @@ -318,6 +320,16 @@ protected function resetServices(bool $initAutoloader = true) Services::reset($initAutoloader); } + /** + * Resets the mocked is_windows() function back to default state. + */ + protected function resetIsWindowsMock(): void + { + if (function_exists('is_windows')) { + is_windows(null); + } + } + /** * Injects the mock Cache driver to prevent filesystem collisions. * diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index b4901a5e8d93..f1ce25c04aa1 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -863,7 +863,7 @@ public function testIsWindowsUsingMock(): void $this->assertFalse(is_windows()); $this->assertNotTrue(is_windows()); - is_windows(); + is_windows(null); $this->assertSame(str_contains(php_uname(), 'Windows'), is_windows()); $this->assertSame(defined('PHP_WINDOWS_VERSION_MAJOR'), is_windows()); }