Level 63
Apr 11, 2026
2
Level 6
Is the session not expiring in tests?
I tried having this simple test
public function test_if_session_has_expired(): void {
$user = User::factory()->create(['type' => 'admin']);
$this->actingAs($user);
$loggedInResponse = $this->get(route('dashboard'));
$loggedInResponse->assertOk();
// SESSION_LIFETIME=3
$this->travel(500)->minutes();
$reloadResponse = $this->get(route('dashboard'));
$reloadResponse->assertOk();
}
It should fail and redirect to login page but it passed.
Please or to participate in this conversation.