@@ -16,8 +16,46 @@ public function test_password_update_page_is_displayed()
1616
1717 $ response = $ this
1818 ->actingAs ($ user )
19- ->get (route ('password.edit ' ));
19+ ->get (route ('user- password.edit ' ));
2020
2121 $ response ->assertStatus (200 );
2222 }
23+
24+ public function test_password_can_be_updated ()
25+ {
26+ $ user = User::factory ()->create ();
27+
28+ $ response = $ this
29+ ->actingAs ($ user )
30+ ->from (route ('user-password.edit ' ))
31+ ->put (route ('user-password.update ' ), [
32+ 'current_password ' => 'password ' ,
33+ 'password ' => 'new-password ' ,
34+ 'password_confirmation ' => 'new-password ' ,
35+ ]);
36+
37+ $ response
38+ ->assertSessionHasNoErrors ()
39+ ->assertRedirect (route ('user-password.edit ' ));
40+
41+ $ this ->assertTrue (Hash::check ('new-password ' , $ user ->refresh ()->password ));
42+ }
43+
44+ public function test_correct_password_must_be_provided_to_update_password ()
45+ {
46+ $ user = User::factory ()->create ();
47+
48+ $ response = $ this
49+ ->actingAs ($ user )
50+ ->from (route ('user-password.edit ' ))
51+ ->put (route ('user-password.update ' ), [
52+ 'current_password ' => 'wrong-password ' ,
53+ 'password ' => 'new-password ' ,
54+ 'password_confirmation ' => 'new-password ' ,
55+ ]);
56+
57+ $ response
58+ ->assertSessionHasErrors ('current_password ' )
59+ ->assertRedirect (route ('user-password.edit ' ));
60+ }
2361}
0 commit comments