]> BookStack Code Mirror - bookstack/blobdiff - tests/Auth/UserInviteTest.php
Fixed failing test after drawio default url change
[bookstack] / tests / Auth / UserInviteTest.php
index dcf9e23df9b829a10cfd175800d058247c1333fe..38124cc1aef4ca64de5a2878d6dd0935acab9c3c 100644 (file)
@@ -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',