X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c5b58d8fd20a85a56a8903a0cf15047a9b9fed41..refs/pull/665/head:/tests/BrowserKitTest.php diff --git a/tests/BrowserKitTest.php b/tests/BrowserKitTest.php index 98259dea9..1eabc7417 100644 --- a/tests/BrowserKitTest.php +++ b/tests/BrowserKitTest.php @@ -3,6 +3,7 @@ use BookStack\Entity; use BookStack\Role; use BookStack\Services\PermissionService; +use BookStack\User; use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Testing\DatabaseTransactions; use Laravel\BrowserKitTesting\TestCase; @@ -129,15 +130,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; }