I would like to test the case when a user is marked as inactive in db, here is the method in LoginController
protected function credentials(Request $request)
{
$credentials = $request->only($this->username(), 'password');
$credentials['status'] = "A";
return $credentials;
}
therefore I create a fake user and I use the following test to cover the case
$this->faker = Faker::create();
$password = $this->faker->password;
$user = factory(User::class)->create([
'username' => $this->faker->username,
'firstname' => $this->faker->firstName,
'lastname' => $this->faker->lastName,
'status'=> 'I',
'password' => bcrypt($password),
'email' => $this->faker->email
]);
$response = $this->call('POST', '/login', [
'email' => $user->email,
'password' =>$password,
'_token' => csrf_token()
]);
$response->assertRedirect('/login');
but the user is getting logged in each time.
What I miss in this case?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire