1 <?php namespace Tests\Entity;
3 use BookStack\Entities\Models\Book;
4 use BookStack\Entities\Models\Page;
7 class PageTest extends TestCase
9 public function test_page_creation_with_markdown_content()
11 $this->setSettings(['app-editor' => 'markdown']);
12 $book = Book::query()->first();
14 $this->asEditor()->get($book->getUrl('/create-page'));
15 $draft = Page::query()->where('book_id', '=', $book->id)
16 ->where('draft', '=', true)->first();
19 'markdown' => '# a title',
20 'html' => '<h1>a title</h1>',
23 $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
24 $resp->assertRedirect();
26 $this->assertDatabaseHas('pages', [
27 'markdown' => $details['markdown'],
28 'name' => $details['name'],
34 $resp = $this->get($draft->getUrl("/edit"));
35 $resp->assertSee("# a title");
38 public function test_page_delete()
40 $page = Page::query()->first();
41 $this->assertNull($page->deleted_at);
43 $deleteViewReq = $this->asEditor()->get($page->getUrl('/delete'));
44 $deleteViewReq->assertSeeText('Are you sure you want to delete this page?');
46 $deleteReq = $this->delete($page->getUrl());
47 $deleteReq->assertRedirect($page->getParent()->getUrl());
48 $this->assertActivityExists('page_delete', $page);
51 $this->assertNotNull($page->deleted_at);
52 $this->assertTrue($page->deletions()->count() === 1);
54 $redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
55 $redirectReq->assertNotificationContains('Page Successfully Deleted');