X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/397a36cfd05d26faecc1350817fa1d2fb20aa6ff..refs/pull/3918/head:/tests/PublicActionTest.php diff --git a/tests/PublicActionTest.php b/tests/PublicActionTest.php index 178e23e2e..7e3f7be00 100644 --- a/tests/PublicActionTest.php +++ b/tests/PublicActionTest.php @@ -8,7 +8,6 @@ use BookStack\Auth\Role; use BookStack\Auth\User; use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Chapter; -use BookStack\Entities\Models\Page; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\View; @@ -17,11 +16,11 @@ class PublicActionTest extends TestCase public function test_app_not_public() { $this->setSettings(['app-public' => 'false']); - $book = Book::query()->first(); + $book = $this->entities->book(); $this->get('/books')->assertRedirect('/login'); $this->get($book->getUrl())->assertRedirect('/login'); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->get($page->getUrl())->assertRedirect('/login'); } @@ -93,8 +92,7 @@ class PublicActionTest extends TestCase $this->app->make(JointPermissionBuilder::class)->rebuildForRole($publicRole); user()->clearPermissionCache(); - /** @var Chapter $chapter */ - $chapter = Chapter::query()->first(); + $chapter = $this->entities->chapter(); $resp = $this->get($chapter->getUrl()); $resp->assertSee('New Page'); $this->withHtml($resp)->assertElementExists('a[href="' . $chapter->getUrl('/create-page') . '"]'); @@ -118,7 +116,7 @@ class PublicActionTest extends TestCase public function test_content_not_listed_on_404_for_public_users() { - $page = Page::query()->first(); + $page = $this->entities->page(); $page->fill(['name' => 'my testing random unique page name'])->save(); $this->asAdmin()->get($page->getUrl()); // Fake visit to show on recents $resp = $this->get('/cats/dogs/hippos'); @@ -162,8 +160,7 @@ class PublicActionTest extends TestCase public function test_public_view_then_login_redirects_to_previous_content() { $this->setSettings(['app-public' => 'true']); - /** @var Book $book */ - $book = Book::query()->first(); + $book = $this->entities->book(); $resp = $this->get($book->getUrl()); $resp->assertSee($book->name); @@ -175,9 +172,8 @@ class PublicActionTest extends TestCase public function test_access_hidden_content_then_login_redirects_to_intended_content() { $this->setSettings(['app-public' => 'true']); - /** @var Book $book */ - $book = Book::query()->first(); - $this->setEntityRestrictions($book); + $book = $this->entities->book(); + $this->entities->setPermissions($book); $resp = $this->get($book->getUrl()); $resp->assertSee('Book not found');