X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/05d99a312d29fdae6073c1205ffc2005db23f55b..refs/pull/3693/head:/tests/Auth/UserInviteTest.php diff --git a/tests/Auth/UserInviteTest.php b/tests/Auth/UserInviteTest.php index dcf9e23df..38124cc1a 100644 --- a/tests/Auth/UserInviteTest.php +++ b/tests/Auth/UserInviteTest.php @@ -6,6 +6,7 @@ use BookStack\Auth\Access\UserInviteService; use BookStack\Auth\User; use BookStack\Notifications\UserInvite; use Carbon\Carbon; +use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Notification; use Illuminate\Support\Str; @@ -34,6 +35,30 @@ class UserInviteTest extends TestCase ]); } + public function test_user_invite_sent_in_selected_language() + { + Notification::fake(); + $admin = $this->getAdmin(); + + $email = Str::random(16) . '@example.com'; + $resp = $this->actingAs($admin)->post('/settings/users/create', [ + 'name' => 'Barry', + 'email' => $email, + 'send_invite' => 'true', + 'language' => 'de', + ]); + $resp->assertRedirect('/settings/users'); + + $newUser = User::query()->where('email', '=', $email)->orderBy('id', 'desc')->first(); + Notification::assertSentTo($newUser, UserInvite::class, function ($notification, $channels, $notifiable) { + /** @var MailMessage $mail */ + $mail = $notification->toMail($notifiable); + + return 'Du wurdest eingeladen BookStack beizutreten!' === $mail->subject && + 'Ein Konto wurde für Sie auf BookStack erstellt.' === $mail->greeting; + }); + } + public function test_invite_set_password() { Notification::fake(); @@ -52,7 +77,7 @@ class UserInviteTest extends TestCase $setPasswordResp = $this->followingRedirects()->post('/register/invite/' . $token, [ 'password' => 'my test password', ]); - $setPasswordResp->assertSee('Password set, you now have access to BookStack!'); + $setPasswordResp->assertSee('Password set, you should now be able to login using your set password to access BookStack!'); $newPasswordValid = auth()->validate([ 'email' => $user->email, 'password' => 'my test password',