]> BookStack Code Mirror - bookstack/blobdiff - tests/PublicActionTest.php
Added 'Sort Book' action to chapters
[bookstack] / tests / PublicActionTest.php
index 499c0c9f9710ab0bbd4c6f7401743c325dc2c6be..178e23e2ebc804fd5484ba93d5d8a3b8d3d9d5fe 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Tests;
 
-use BookStack\Auth\Permissions\PermissionService;
+use BookStack\Auth\Permissions\JointPermissionBuilder;
 use BookStack\Auth\Permissions\RolePermission;
 use BookStack\Auth\Role;
 use BookStack\Auth\User;
@@ -28,7 +28,8 @@ class PublicActionTest extends TestCase
     public function test_login_link_visible()
     {
         $this->setSettings(['app-public' => 'true']);
-        $this->get('/')->assertElementExists('a[href="' . url('/login') . '"]');
+        $resp = $this->get('/');
+        $this->withHtml($resp)->assertElementExists('a[href="' . url('/login') . '"]');
     }
 
     public function test_register_link_visible_when_enabled()
@@ -89,18 +90,19 @@ class PublicActionTest extends TestCase
         foreach (RolePermission::all() as $perm) {
             $publicRole->attachPermission($perm);
         }
-        $this->app[PermissionService::class]->buildJointPermissionForRole($publicRole);
+        $this->app->make(JointPermissionBuilder::class)->rebuildForRole($publicRole);
+        user()->clearPermissionCache();
 
         /** @var Chapter $chapter */
         $chapter = Chapter::query()->first();
         $resp = $this->get($chapter->getUrl());
         $resp->assertSee('New Page');
-        $resp->assertElementExists('a[href="' . $chapter->getUrl('/create-page') . '"]');
+        $this->withHtml($resp)->assertElementExists('a[href="' . $chapter->getUrl('/create-page') . '"]');
 
         $resp = $this->get($chapter->getUrl('/create-page'));
         $resp->assertSee('Continue');
         $resp->assertSee('Page Name');
-        $resp->assertElementExists('form[action="' . $chapter->getUrl('/create-guest-page') . '"]');
+        $this->withHtml($resp)->assertElementExists('form[action="' . $chapter->getUrl('/create-guest-page') . '"]');
 
         $resp = $this->post($chapter->getUrl('/create-guest-page'), ['name' => 'My guest page']);
         $resp->assertRedirect($chapter->book->getUrl('/page/my-guest-page/edit'));