66use BookStack \Auth \User ;
77use BookStack \Notifications \UserInvite ;
88use Carbon \Carbon ;
9+ use Illuminate \Notifications \Messages \MailMessage ;
910use Illuminate \Support \Facades \DB ;
1011use Illuminate \Support \Facades \Notification ;
1112use Illuminate \Support \Str ;
@@ -20,8 +21,8 @@ public function test_user_creation_creates_invite()
2021
2122 $ email = Str::random (16 ) . '@example.com ' ;
2223 $ resp = $ this ->actingAs ($ admin )->post ('/settings/users/create ' , [
23- 'name ' => 'Barry ' ,
24- 'email ' => $ email ,
24+ 'name ' => 'Barry ' ,
25+ 'email ' => $ email ,
2526 'send_invite ' => 'true ' ,
2627 ]);
2728 $ resp ->assertRedirect ('/settings/users ' );
@@ -34,6 +35,31 @@ public function test_user_creation_creates_invite()
3435 ]);
3536 }
3637
38+ public function test_user_invite_sent_in_selected_language ()
39+ {
40+ Notification::fake ();
41+ $ admin = $ this ->getAdmin ();
42+
43+ $ email = Str::random (16 ) . '@example.com ' ;
44+ $ resp = $ this ->actingAs ($ admin )->post ('/settings/users/create ' , [
45+ 'name ' => 'Barry ' ,
46+ 'email ' => $ email ,
47+ 'send_invite ' => 'true ' ,
48+ 'setting ' => [
49+ 'language ' => 'de ' ,
50+ ]
51+ ]);
52+ $ resp ->assertRedirect ('/settings/users ' );
53+
54+ $ newUser = User::query ()->where ('email ' , '= ' , $ email )->orderBy ('id ' , 'desc ' )->first ();
55+ Notification::assertSentTo ($ newUser , UserInvite::class, function ($ notification , $ channels , $ notifiable ) {
56+ /** @var MailMessage $mail */
57+ $ mail = $ notification ->toMail ($ notifiable );
58+ return 'Du wurdest eingeladen BookStack beizutreten! ' === $ mail ->subject &&
59+ 'Ein Konto wurde für Sie auf BookStack erstellt. ' === $ mail ->greeting ;
60+ });
61+ }
62+
3763 public function test_invite_set_password ()
3864 {
3965 Notification::fake ();
@@ -54,7 +80,7 @@ public function test_invite_set_password()
5480 ]);
5581 $ setPasswordResp ->assertSee ('Password set, you should now be able to login using your set password to access BookStack! ' );
5682 $ newPasswordValid = auth ()->validate ([
57- 'email ' => $ user ->email ,
83+ 'email ' => $ user ->email ,
5884 'password ' => 'my test password ' ,
5985 ]);
6086 $ this ->assertTrue ($ newPasswordValid );
0 commit comments