Skip to content

Commit 0b294b5

Browse files
committed
fix: reset is_windows mock state in CIUnitTestCase tearDown
1 parent 94036f1 commit 0b294b5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎system/Test/CIUnitTestCase.php‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ abstract class CIUnitTestCase extends TestCase
6969
*
7070
* @var list<string> array of methods
7171
*/
72-
protected $tearDownMethods = [];
72+
protected $tearDownMethods = [
73+
'resetIsWindowsMock',
74+
];
7375

7476
/**
7577
* Store of identified traits.
@@ -318,6 +320,16 @@ 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+
if (function_exists('is_windows')) {
329+
is_windows(null);
330+
}
331+
}
332+
321333
/**
322334
* Injects the mock Cache driver to prevent filesystem collisions.
323335
*

‎tests/system/CommonFunctionsTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)