lavina
2 months ago
182
5
Laravel

Testing login functionality

Posted 2 months ago by lavina

Hey guys, i am testing my log in functionality and i keep getting an error im not sure how to fix:

public function testUserCanLoginWithCorrectCredentials()
{
    $this->withoutMiddleware();
    $user = factory(User::class)->create([
        'password' => bcrypt($password = 'test'),
    ]);
    $response = $this->post($this->loginPostRoute(), [
        'email' => $user->email,
        'password' => $password,
    ]);
    $response->assertRedirect('/home');
    $this->assertAuthenticatedAs($user);
}

My user is indeed authenticated, but the error is: Response status code [500] is not a redirect status code. If i dont run withoutMiddleware i get status code 419, because i am not throwing csrf token, what am i missing?

Please sign in or create an account to participate in this conversation.