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'); }
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); }
/** * 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; }
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); }
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'); }
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); }
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(); }
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'); }
public function setUp() { parent::setUp(); $this->page = \BookStack\Page::first(); }
public function setUp() { parent::setUp(); $this->page = \BookStack\Page::first(); $this->pageRepo = app('\\BookStack\\Repos\\PageRepo'); }
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']); }