File tree Expand file tree Collapse file tree
tests/Feature/Http/Controllers/User Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88use CraftCms \Cms \Support \Facades \UserPermissions ;
99use CraftCms \Cms \User \Elements \User ;
1010use CraftCms \Cms \User \Models \User as UserModel ;
11+ use CraftCms \Cms \User \Notifications \ResetPasswordNotification ;
12+ use Illuminate \Notifications \Channels \MailChannel ;
1113use Illuminate \Support \Facades \Gate ;
14+ use Illuminate \Support \Facades \Notification ;
1215use Illuminate \Support \Facades \Session ;
1316
1417use function CraftCms \Cms \t ;
180183 expect ($ response ->status ())->not ()->toBe (401 );
181184});
182185
186+ it ('sends password reset email for a valid loginName ' , function () {
187+ Notification::fake ();
188+ auth ()->logout ();
189+
190+ $ user = UserModel::factory ()->createElement ();
191+ $ user = User::find ()->id ($ user ->id )->one ();
192+
193+ postJson (action ([PasswordController::class, 'sendPasswordResetEmail ' ]), [
194+ 'loginName ' => $ user ->email ,
195+ ])->assertOk ();
196+
197+ Notification::assertSentTo (
198+ $ user ,
199+ ResetPasswordNotification::class,
200+ fn ($ notification , $ channels ) => in_array (MailChannel::class, $ channels )
201+ );
202+ });
203+
183204it ('requires loginName when not providing userId for sendPasswordResetEmail ' , function () {
184205 $ response = postJson (action ([PasswordController::class, 'sendPasswordResetEmail ' ]), []);
185206
You can’t perform that action at this time.
0 commit comments