+ public function test_content_not_listed_on_404_for_public_users()
+ {
+ $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');
+ $resp->assertStatus(404);
+ $resp->assertSee($page->name);
+ View::share('pageTitle', '');
+
+ Auth::logout();
+ $resp = $this->get('/cats/dogs/hippos');
+ $resp->assertStatus(404);
+ $resp->assertDontSee($page->name);
+ }
+
+ public function test_default_favicon_file_created_upon_access()
+ {
+ $faviconPath = public_path('favicon.ico');
+ if (file_exists($faviconPath)) {
+ unlink($faviconPath);
+ }
+
+ $this->assertFileDoesNotExist($faviconPath);
+ $this->get('/favicon.ico');
+ $this->assertFileExists($faviconPath);
+ }
+
+ public function test_public_view_then_login_redirects_to_previous_content()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ $book = $this->entities->book();
+ $resp = $this->get($book->getUrl());
+ $resp->assertSee($book->name);
+
+ $this->get('/login');
+ $resp = $this->post('/login', ['email' => '
[email protected]', 'password' => 'password']);
+ $resp->assertRedirect($book->getUrl());
+ }
+
+ public function test_access_hidden_content_then_login_redirects_to_intended_content()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ $book = $this->entities->book();
+ $this->permissions->setEntityPermissions($book);
+
+ $resp = $this->get($book->getUrl());
+ $resp->assertSee('Book not found');
+
+ $this->get('/login');
+ $resp = $this->post('/login', ['email' => '
[email protected]', 'password' => 'password']);
+ $resp->assertRedirect($book->getUrl());
+ $this->followRedirects($resp)->assertSee($book->name);
+ }
+
+ public function test_public_view_can_take_on_other_roles()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ $newRole = $this->users->attachNewRole($this->users->guest(), []);
+ $page = $this->entities->page();
+ $this->permissions->disableEntityInheritedPermissions($page);
+ $this->permissions->addEntityPermission($page, ['view', 'update'], $newRole);
+
+ $resp = $this->get($page->getUrl());
+ $resp->assertOk();
+
+ $this->withHtml($resp)->assertLinkExists($page->getUrl('/edit'));
+ }
+
+ public function test_public_user_cannot_view_or_update_their_profile()
+ {
+ $this->setSettings(['app-public' => 'true']);
+ $guest = $this->users->guest();
+
+ $resp = $this->get($guest->getEditUrl());
+ $this->assertPermissionError($resp);
+
+ $resp = $this->put($guest->getEditUrl(), ['name' => 'My new guest name']);
+ $this->assertPermissionError($resp);
+ }
+}