X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/33a2999a57854495fcea8c1acf1b75b04a28a0bf..refs/pull/524/head:/tests/BrowserKitTest.php diff --git a/tests/BrowserKitTest.php b/tests/BrowserKitTest.php index 674aef984..98259dea9 100644 --- a/tests/BrowserKitTest.php +++ b/tests/BrowserKitTest.php @@ -1,6 +1,8 @@ admin === null) { - $adminRole = Role::getRole('admin'); + $adminRole = Role::getSystemRole('admin'); $this->admin = $adminRole->users->first(); } return $this->admin; @@ -99,11 +107,9 @@ abstract class BrowserKitTest extends TestCase { if ($updaterUser === false) $updaterUser = $creatorUser; $book = factory(\BookStack\Book::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]); - $chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]); - $page = factory(\BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]); - $book->chapters()->saveMany([$chapter]); - $chapter->pages()->saveMany([$page]); - $restrictionService = $this->app[\BookStack\Services\PermissionService::class]; + $chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]); + $page = factory(\BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id, 'chapter_id' => $chapter->id]); + $restrictionService = $this->app[PermissionService::class]; $restrictionService->buildJointPermissionsForEntity($book); return [ 'book' => $book, @@ -112,6 +118,16 @@ abstract class BrowserKitTest extends TestCase ]; } + /** + * Helper for updating entity permissions. + * @param Entity $entity + */ + protected function updateEntityPermissions(Entity $entity) + { + $restrictionService = $this->app[PermissionService::class]; + $restrictionService->buildJointPermissionsForEntity($entity); + } + /** * Quick way to create a new user * @param array $attributes