]> BookStack Code Mirror - bookstack/blobdiff - tests/BrowserKitTest.php
Update all.blade.php
[bookstack] / tests / BrowserKitTest.php
index 98259dea94b587a7792da7bea8b8c7231ce575d6..a8ff0304422cfef5cf04a964e011cb3b3ff43de1 100644 (file)
@@ -13,17 +13,16 @@ abstract class BrowserKitTest extends TestCase
 
     use DatabaseTransactions;
 
+    // Local user instances
+    private $admin;
+    private $editor;
+
     /**
      * The base URL to use while testing the application.
-     *
      * @var string
      */
     protected $baseUrl = 'http://localhost';
 
-    // Local user instances
-    private $admin;
-    private $editor;
-
     public function tearDown()
     {
         \DB::disconnect();
@@ -129,15 +128,25 @@ abstract class BrowserKitTest extends TestCase
     }
 
     /**
-     * Quick way to create a new user
+     * Get an instance of a user with 'editor' permissions
      * @param array $attributes
      * @return mixed
      */
     protected function getEditor($attributes = [])
     {
-        $user = factory(\BookStack\User::class)->create($attributes);
-        $role = Role::getRole('editor');
-        $user->attachRole($role);;
+        $user = \BookStack\Role::getRole('editor')->users()->first();
+        if (!empty($attributes)) $user->forceFill($attributes)->save();
+        return $user;
+    }
+
+    /**
+     * Get an instance of a user with 'viewer' permissions
+     * @return mixed
+     */
+    protected function getViewer()
+    {
+        $user = \BookStack\Role::getRole('viewer')->users()->first();
+        if (!empty($attributes)) $user->forceFill($attributes)->save();
         return $user;
     }