Esempio n. 1
0
 public function testChaptersViewable()
 {
     $this->setSettings(['app-public' => 'true']);
     $chapterToVisit = \BookStack\Chapter::first();
     $pageToVisit = $chapterToVisit->pages()->first();
     // Check chapters index page is showing
     $this->visit($chapterToVisit->getUrl())->seeStatusCode(200)->see($chapterToVisit->name)->see($pageToVisit->name)->click($pageToVisit->name)->see($chapterToVisit->book->name)->see($chapterToVisit->name)->seePageIs($pageToVisit->getUrl());
 }
Esempio n. 2
0
 public function test_chapter_move()
 {
     $chapter = \BookStack\Chapter::first();
     $currentBook = $chapter->book;
     $pageToCheck = $chapter->pages->first();
     $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
     $this->asAdmin()->visit($chapter->getUrl() . '/move')->see('Move Chapter')->see($chapter->name)->type('book:' . $newBook->id, 'entity_selection')->press('Move Chapter');
     $chapter = \BookStack\Chapter::find($chapter->id);
     $this->seePageIs($chapter->getUrl());
     $this->assertTrue($chapter->book->id === $newBook->id, 'Chapter Book is now the new book');
     $this->visit($newBook->getUrl())->seeInNthElement('.activity-list-item', 0, 'moved chapter')->seeInNthElement('.activity-list-item', 0, $chapter->name);
     $pageToCheck = \BookStack\Page::find($pageToCheck->id);
     $this->assertTrue($pageToCheck->book_id === $newBook->id, 'Chapter child page\'s book id has changed to the new book');
     $this->visit($pageToCheck->getUrl())->see($newBook->name);
 }
Esempio n. 3
0
 public function test_public_page_creation()
 {
     $this->setSettings(['app-public' => 'true']);
     $publicRole = \BookStack\Role::getSystemRole('public');
     // Grant all permissions to public
     $publicRole->permissions()->detach();
     foreach (\BookStack\RolePermission::all() as $perm) {
         $publicRole->attachPermission($perm);
     }
     $this->app[\BookStack\Services\PermissionService::class]->buildJointPermissionForRole($publicRole);
     $chapter = \BookStack\Chapter::first();
     $this->visit($chapter->book->getUrl());
     $this->visit($chapter->getUrl())->click('New Page')->see('Create Page')->seePageIs($chapter->getUrl('/create-page'));
     $this->submitForm('Continue', ['name' => 'My guest page'])->seePageIs($chapter->book->getUrl('/page/my-guest-page/edit'));
     $user = \BookStack\User::getDefault();
     $this->seeInDatabase('pages', ['name' => 'My guest page', 'chapter_id' => $chapter->id, 'created_by' => $user->id, 'updated_by' => $user->id]);
 }
Esempio n. 4
0
 public function test_restricted_pages_not_visible_on_chapter_pages()
 {
     $chapter = \BookStack\Chapter::first();
     $page = $chapter->pages->first();
     $this->setEntityRestrictions($page, []);
     $this->actingAs($this->user)->visit($chapter->getUrl())->dontSee($page->name);
 }