0

I have this feature test

public function it_can_logout()
{
    $user = User::find(1);

    $this->assertNotNull($user);

    $credentials = [
        'email' => $user->email,
        'password' => 'password',
    ];

    $loginResponse = $this->postJson('api/login', $credentials);
    $loginResponse->assertStatus(200);

    $response = $this->post('api/logout');

    $response->assertStatus(200);
    $response->assertJson(['status' => true, 'message' => 'logged out']);
    $this->assertGuest();
}

and this method to be tested

public function logout(Request $request)
{
    auth('web')->logout();
    $request->session()->invalidate();
    $request->session()->regenerateToken();

    return response()->json([
        'status' => true,
        'message' => 'logged out'
    ], 200);
}

But when running

php artisan test --filter=it_can_logout

I have this issue

Session store not set on request
andrewtweber
  • 24,520
  • 22
  • 88
  • 110
Fil
  • 8,225
  • 14
  • 59
  • 85
  • Does this answer your question? [Laravel - Session store not set on request](https://stackoverflow.com/questions/34449770/laravel-session-store-not-set-on-request) – andrewtweber Feb 10 '23 at 21:26

0 Answers0