X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/4a2a539c086c7975374f69bfe15748d9f757a1ee..refs/pull/358/head:/tests/TestCase.php diff --git a/tests/TestCase.php b/tests/TestCase.php index d64aef3db..f3f36ca1c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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