X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/0b364fd72f994e6dff572a1606f3aa26e7690aa1..refs/pull/232/head:/tests/TestCase.php diff --git a/tests/TestCase.php b/tests/TestCase.php index 4c2893f4e..d3620eae0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -39,11 +39,19 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase */ public function asAdmin() { + return $this->actingAs($this->getAdmin()); + } + + /** + * Get the current admin user. + * @return mixed + */ + public function getAdmin() { if($this->admin === null) { $adminRole = \BookStack\Role::getRole('admin'); $this->admin = $adminRole->users->first(); } - return $this->actingAs($this->admin); + return $this->admin; } /** @@ -58,6 +66,14 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase return $this->actingAs($this->editor); } + /** + * Get a user that's not a system user such as the guest user. + */ + public function getNormalUser() + { + return \BookStack\User::where('system_name', '=', null)->get()->last(); + } + /** * Quickly sets an array of settings. * @param $settingsArray