X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e7a7d8cc1d77b032c4efe9d08ec6c749430b7b57..refs/pull/3598/head:/tests/PublicActionTest.php diff --git a/tests/PublicActionTest.php b/tests/PublicActionTest.php index 7caefd0ac..178e23e2e 100644 --- a/tests/PublicActionTest.php +++ b/tests/PublicActionTest.php @@ -1,17 +1,19 @@ -setSettings(['app-public' => 'false']); @@ -26,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('/http/source.bookstackapp.com/login') . '"]'); } public function test_register_link_visible_when_enabled() @@ -87,38 +90,41 @@ 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')); $user = User::getDefault(); $this->assertDatabaseHas('pages', [ - 'name' => 'My guest page', + 'name' => 'My guest page', 'chapter_id' => $chapter->id, 'created_by' => $user->id, - 'updated_by' => $user->id + 'updated_by' => $user->id, ]); } public function test_content_not_listed_on_404_for_public_users() { $page = Page::query()->first(); + $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'); $resp->assertStatus(404); $resp->assertSee($page->name); + View::share('pageTitle', ''); Auth::logout(); $resp = $this->get('/cats/dogs/hippos'); @@ -134,7 +140,7 @@ class PublicActionTest extends TestCase $resp = $this->get('/robots.txt'); $resp->assertSee("User-agent: *\nDisallow:"); - $resp->assertDontSee("Disallow: /"); + $resp->assertDontSee('Disallow: /'); } public function test_robots_effected_by_setting() @@ -145,7 +151,7 @@ class PublicActionTest extends TestCase $resp = $this->get('/robots.txt'); $resp->assertSee("User-agent: *\nDisallow:"); - $resp->assertDontSee("Disallow: /"); + $resp->assertDontSee('Disallow: /'); // Check config overrides app-public setting config()->set('app.allow_robots', false); @@ -181,4 +187,4 @@ class PublicActionTest extends TestCase $resp->assertRedirect($book->getUrl()); $this->followRedirects($resp)->assertSee($book->name); } -} \ No newline at end of file +}