mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Simplify other test
This commit is contained in:
@@ -29,7 +29,7 @@ class RequestPasswordTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function can_request_password_reset_with_web_guard()
|
||||
public function can_request_password_reset_with_custom_user_model()
|
||||
{
|
||||
Config::set('filament.auth.guard', 'web');
|
||||
Config::set('auth.providers.users.model', User::class);
|
||||
|
||||
@@ -30,7 +30,7 @@ class ResetPasswordTest extends TestCase
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect(route('filament.dashboard'));
|
||||
|
||||
$this->assertAuthenticatedAs($user);
|
||||
$this->assertAuthenticatedAs($user, config('filament.auth.guard'));
|
||||
|
||||
$this->assertTrue(Filament::auth()->attempt([
|
||||
'email' => $user->email,
|
||||
@@ -39,33 +39,12 @@ class ResetPasswordTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function can_reset_password_with_web_guard()
|
||||
public function can_reset_password_with_custom_user_model()
|
||||
{
|
||||
// Configure filament to use default Laravel's auth guard
|
||||
Config::set('filament.auth.guard', 'web');
|
||||
|
||||
// Set Laravel's default user model to filament's one, so it has filament's attributes
|
||||
Config::set('auth.providers.users.model', User::class);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$newPassword = Str::random();
|
||||
|
||||
Livewire::test(ResetPassword::class, [
|
||||
'token' => $this->generateToken($user)
|
||||
])
|
||||
->set('email', $user->email)
|
||||
->set('password', $newPassword)
|
||||
->set('passwordConfirmation', $newPassword)
|
||||
->call('submit')
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect(route('filament.dashboard'));
|
||||
|
||||
$this->assertAuthenticatedAs($user, config('filament.auth.guard'));
|
||||
|
||||
$this->assertTrue(Filament::auth()->attempt([
|
||||
'email' => $user->email,
|
||||
'password' => $newPassword,
|
||||
]));
|
||||
$this->can_reset_password();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
Reference in New Issue
Block a user