Skip to content

Commit 6ec8614

Browse files
authored
Fix flaky test by freezing time before write operation (#57904)
This prevents timing race conditions where time can advance between when the session is written (which records a timestamp) and when the garbage collection check occurs, causing intermittent test failures.
1 parent 8a41491 commit 6ec8614

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tests/Session/ArraySessionHandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function test_it_cleans_up_old_sessions()
100100

101101
$this->assertSame(0, $handler->gc(300));
102102

103+
Carbon::setTestNow(Carbon::now());
103104
$handler->write('foo', 'bar');
104105
$this->assertSame(0, $handler->gc(300));
105106
$this->assertSame('bar', $handler->read('foo'));

0 commit comments

Comments
 (0)