22
33namespace Tests \Feature \Auth ;
44
5- use App \Livewire \Auth \ForgotPassword ;
6- use App \Livewire \Auth \ResetPassword ;
75use App \Models \User ;
8- use Illuminate \Auth \Notifications \ResetPassword as ResetPasswordNotification ;
6+ use Illuminate \Auth \Notifications \ResetPassword ;
97use Illuminate \Foundation \Testing \RefreshDatabase ;
108use Illuminate \Support \Facades \Notification ;
11- use Livewire \Livewire ;
129use Tests \TestCase ;
1310
1411class PasswordResetTest extends TestCase
@@ -17,8 +14,7 @@ class PasswordResetTest extends TestCase
1714
1815 public function test_reset_password_link_screen_can_be_rendered (): void
1916 {
20- $ response = $ this ->get ('/forgot-password ' );
21-
17+ $ response = $ this ->get (route ('password.request ' ));
2218 $ response ->assertStatus (200 );
2319 }
2420
@@ -28,11 +24,9 @@ public function test_reset_password_link_can_be_requested(): void
2824
2925 $ user = User::factory ()->create ();
3026
31- Livewire::test (ForgotPassword::class)
32- ->set ('email ' , $ user ->email )
33- ->call ('sendPasswordResetLink ' );
27+ $ this ->post (route ('password.request ' ), ['email ' => $ user ->email ]);
3428
35- Notification::assertSentTo ($ user , ResetPasswordNotification ::class);
29+ Notification::assertSentTo ($ user , ResetPassword ::class);
3630 }
3731
3832 public function test_reset_password_screen_can_be_rendered (): void
@@ -41,13 +35,10 @@ public function test_reset_password_screen_can_be_rendered(): void
4135
4236 $ user = User::factory ()->create ();
4337
44- Livewire::test (ForgotPassword::class)
45- ->set ('email ' , $ user ->email )
46- ->call ('sendPasswordResetLink ' );
47-
48- Notification::assertSentTo ($ user , ResetPasswordNotification::class, function ($ notification ) {
49- $ response = $ this ->get ('/reset-password/ ' .$ notification ->token );
38+ $ this ->post (route ('password.request ' ), ['email ' => $ user ->email ]);
5039
40+ Notification::assertSentTo ($ user , ResetPassword::class, function ($ notification ) {
41+ $ response = $ this ->get (route ('password.reset ' , $ notification ->token ));
5142 $ response ->assertStatus (200 );
5243
5344 return true ;
@@ -60,19 +51,18 @@ public function test_password_can_be_reset_with_valid_token(): void
6051
6152 $ user = User::factory ()->create ();
6253
63- Livewire::test (ForgotPassword::class)
64- ->set ('email ' , $ user ->email )
65- ->call ('sendPasswordResetLink ' );
54+ $ this ->post (route ('password.request ' ), ['email ' => $ user ->email ]);
6655
67- Notification::assertSentTo ($ user , ResetPasswordNotification::class, function ($ notification ) use ($ user ) {
68- $ response = Livewire::test (ResetPassword::class, ['token ' => $ notification ->token ])
69- ->set ('email ' , $ user ->email )
70- ->set ('password ' , 'password ' )
71- ->set ('password_confirmation ' , 'password ' )
72- ->call ('resetPassword ' );
56+ Notification::assertSentTo ($ user , ResetPassword::class, function ($ notification ) use ($ user ) {
57+ $ response = $ this ->post (route ('password.update ' ), [
58+ 'token ' => $ notification ->token ,
59+ 'email ' => $ user ->email ,
60+ 'password ' => 'password ' ,
61+ 'password_confirmation ' => 'password ' ,
62+ ]);
7363
7464 $ response
75- ->assertHasNoErrors ()
65+ ->assertSessionHasNoErrors ()
7666 ->assertRedirect (route ('login ' , absolute: false ));
7767
7868 return true ;
0 commit comments