]> BookStack Code Mirror - bookstack/blobdiff - tests/TestCase.php
Add Slovak translation
[bookstack] / tests / TestCase.php
index d64aef3dba8d320cfc9ef25f548539797578a26c..f3f36ca1cc75daa3211c82d0ee5eec2628891b33 100644 (file)
@@ -13,6 +13,7 @@ abstract class TestCase extends BaseTestCase
     use DatabaseTransactions;
 
     protected $admin;
+    protected $editor;
 
     /**
      * Set the current user context to be an admin.
@@ -35,6 +36,28 @@ abstract class TestCase extends BaseTestCase
         return $this->admin;
     }
 
+    /**
+     * Set the current user context to be an editor.
+     * @return $this
+     */
+    public function asEditor()
+    {
+        return $this->actingAs($this->getEditor());
+    }
+
+
+    /**
+     * Get a editor user.
+     * @return mixed
+     */
+    public function getEditor() {
+        if($this->editor === null) {
+            $editorRole = Role::getRole('editor');
+            $this->editor = $editorRole->users->first();
+        }
+        return $this->editor;
+    }
+
     /**
      * Create and return a new book.
      * @param array $input