]> BookStack Code Mirror - bookstack/blobdiff - tests/Auth/AuthTest.php
Update settings.php
[bookstack] / tests / Auth / AuthTest.php
index 3d36d85b2e65d926de8c85b9781579eab2cc4f2c..42b44c1525631cac003445c7012bea712c21c34c 100644 (file)
@@ -1,8 +1,8 @@
 <?php namespace Tests;
 
+use BookStack\Auth\User;
 use BookStack\Entities\Page;
 use BookStack\Notifications\ConfirmEmail;
-use BookStack\Auth\User;
 use BookStack\Settings\SettingService;
 use Illuminate\Support\Facades\Notification;
 
@@ -276,6 +276,15 @@ class AuthTest extends BrowserKitTest
     public function test_user_cannot_be_deleted_if_last_admin()
     {
         $adminRole = \BookStack\Auth\Role::getRole('admin');
+
+        // Delete all but one admin user if there are more than one
+        $adminUsers = $adminRole->users;
+        if (count($adminUsers) > 1) {
+            foreach ($adminUsers->splice(1) as $user) {
+                $user->delete();
+            }
+        }
+
         // Ensure we currently only have 1 admin user
         $this->assertEquals(1, $adminRole->users()->count());
         $user = $adminRole->users->first();