예제 #1
0
 public function test_app_not_public()
 {
     $this->setSettings(['app-public' => 'false']);
     $book = \BookStack\Book::orderBy('name', 'asc')->first();
     $this->visit('/books')->seePageIs('/login');
     $this->visit($book->getUrl())->seePageIs('/login');
     $page = \BookStack\Page::first();
     $this->visit($page->getUrl())->seePageIs('/login');
 }
예제 #2
0
 public function test_ajax_entity_search()
 {
     $page = \BookStack\Page::all()->last();
     $notVisitedPage = \BookStack\Page::first();
     $this->visit($page->getUrl());
     $this->asAdmin()->visit('/ajax/search/entities?term=' . $page->name)->see('.entity-list', $page->name);
     $this->asAdmin()->visit('/ajax/search/entities?types=book&term=' . $page->name)->dontSee('.entity-list', $page->name);
     $this->asAdmin()->visit('/ajax/search/entities')->see('.entity-list', $page->name)->dontSee($notVisitedPage->name);
 }
예제 #3
0
 /**
  * Get an instance of a page that has many tags.
  * @param Tag[]|bool $tags
  * @return mixed
  */
 protected function getPageWithTags($tags = false)
 {
     $page = Page::first();
     if (!$tags) {
         $tags = factory(Tag::class, $this->defaultTagCount)->make();
     }
     $page->tags()->saveMany($tags);
     return $page;
 }
예제 #4
0
 public function test_page_move()
 {
     $page = \BookStack\Page::first();
     $currentBook = $page->book;
     $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
     $this->asAdmin()->visit($page->getUrl() . '/move')->see('Move Page')->see($page->name)->type('book:' . $newBook->id, 'entity_selection')->press('Move Page');
     $page = \BookStack\Page::find($page->id);
     $this->seePageIs($page->getUrl());
     $this->assertTrue($page->book->id == $newBook->id, 'Page book is now the new book');
     $this->visit($newBook->getUrl())->seeInNthElement('.activity-list-item', 0, 'moved page')->seeInNthElement('.activity-list-item', 0, $page->name);
 }
예제 #5
0
 public function test_image_delete()
 {
     $page = \BookStack\Page::first();
     $this->asAdmin();
     $imageName = 'first-image.jpg';
     $relPath = $this->uploadImage($imageName, $page->id);
     $image = \BookStack\Image::first();
     $this->call('DELETE', '/images/' . $image->id);
     $this->assertResponseOk();
     $this->dontSeeInDatabase('images', ['url' => $this->baseUrl . $relPath, 'type' => 'gallery']);
     $this->assertFalse(file_exists(public_path($relPath)), 'Uploaded image has been deleted');
 }
예제 #6
0
 public function test_old_page_slugs_redirect_to_new_pages()
 {
     $page = \BookStack\Page::first();
     $pageUrl = $page->getUrl();
     $newPageUrl = '/books/' . $page->book->slug . '/page/super-test-page';
     // Need to save twice since revisions are not generated in seeder.
     $this->asAdmin()->visit($pageUrl)->clickInElement('#content', 'Edit')->type('super test', '#name')->press('Save Page');
     $page = \BookStack\Page::first();
     $pageUrl = $page->getUrl();
     // Second Save
     $this->visit($pageUrl)->clickInElement('#content', 'Edit')->type('super test page', '#name')->press('Save Page')->seePageIs($newPageUrl);
     $this->visit($pageUrl)->seePageIs($newPageUrl);
 }
예제 #7
0
 public function test_attachment_deletion_on_page_deletion()
 {
     $page = \BookStack\Page::first();
     $this->asAdmin();
     $fileName = 'deletion_test.txt';
     $this->uploadFile($fileName, $page->id);
     $filePath = base_path('storage/' . $this->getUploadPath($fileName));
     $this->assertTrue(file_exists($filePath), 'File at path ' . $filePath . ' does not exist');
     $this->seeInDatabase('attachments', ['name' => $fileName]);
     $this->call('DELETE', $page->getUrl());
     $this->dontSeeInDatabase('attachments', ['name' => $fileName]);
     $this->assertFalse(file_exists($filePath), 'File at path ' . $filePath . ' was not deleted as expected');
     $this->deleteUploads();
 }
예제 #8
0
 public function test_restrictions_manage_own_permission()
 {
     $otherUsersPage = \BookStack\Page::first();
     $content = $this->createEntityChainBelongingToUser($this->user);
     // Check can't restrict other's content
     $this->actingAs($this->user)->visit($otherUsersPage->getUrl())->dontSee('Permissions')->visit($otherUsersPage->getUrl() . '/permissions')->seePageIs('/');
     // Check can't restrict own content
     $this->actingAs($this->user)->visit($content['page']->getUrl())->dontSee('Permissions')->visit($content['page']->getUrl() . '/permissions')->seePageIs('/');
     $this->giveUserPermissions($this->user, ['restrictions-manage-own']);
     // Check can't restrict other's content
     $this->actingAs($this->user)->visit($otherUsersPage->getUrl())->dontSee('Permissions')->visit($otherUsersPage->getUrl() . '/permissions')->seePageIs('/');
     // Check can restrict own content
     $this->actingAs($this->user)->visit($content['page']->getUrl())->see('Permissions')->click('Permissions')->seePageIs($content['page']->getUrl() . '/permissions');
 }
예제 #9
0
 public function setUp()
 {
     parent::setUp();
     $this->page = \BookStack\Page::first();
 }
예제 #10
0
 public function setUp()
 {
     parent::setUp();
     $this->page = \BookStack\Page::first();
     $this->pageRepo = app('\\BookStack\\Repos\\PageRepo');
 }
예제 #11
0
 public function test_page_restriction_form()
 {
     $page = \BookStack\Page::first();
     $this->asAdmin()->visit($page->getUrl() . '/permissions')->see('Page Permissions')->check('restricted')->check('restrictions[2][delete]')->press('Save Permissions')->seeInDatabase('pages', ['id' => $page->id, 'restricted' => true])->seeInDatabase('entity_permissions', ['restrictable_id' => $page->id, 'restrictable_type' => 'BookStack\\Page', 'role_id' => '2', 'action' => 'delete']);
 }