From 0b294b55225a710e8559018d69918eace0e1589d Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 12 Sep 2026 21:56:48 +0200 Subject: [PATCH] fix: reset is_windows mock state in CIUnitTestCase tearDown --- system/Test/CIUnitTestCase.php | 14 +++++++++++++- tests/system/CommonFunctionsTest.php | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) 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()); }