X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ee24635e06a8c01d751f80caba47c57f76e8989d..refs/heads/ldap_host_failover:/tests/Entity/PageEditorTest.php diff --git a/tests/Entity/PageEditorTest.php b/tests/Entity/PageEditorTest.php index e5aa549b3..b2fb85955 100644 --- a/tests/Entity/PageEditorTest.php +++ b/tests/Entity/PageEditorTest.php @@ -2,20 +2,18 @@ namespace Tests\Entity; -use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Page; use Tests\TestCase; class PageEditorTest extends TestCase { - /** @var Page */ - protected $page; + protected Page $page; protected function setUp(): void { parent::setUp(); - $this->page = Page::query()->first(); + $this->page = $this->entities->page(); } public function test_default_editor_is_wysiwyg_for_new_pages() @@ -58,8 +56,7 @@ class PageEditorTest extends TestCase public function test_empty_markdown_still_saves_without_error() { $this->setSettings(['app-editor' => 'markdown']); - /** @var Book $book */ - $book = Book::query()->first(); + $book = $this->entities->book(); $this->asEditor()->get($book->getUrl('/create-page')); $draft = Page::query()->where('book_id', '=', $book->id) @@ -81,8 +78,7 @@ class PageEditorTest extends TestCase public function test_back_link_in_editor_has_correct_url() { - /** @var Book $book */ - $book = Book::query()->whereHas('pages')->whereHas('chapters')->firstOrFail(); + $book = $this->entities->bookHasChaptersAndPages(); $this->asEditor()->get($book->getUrl('/create-page')); /** @var Chapter $chapter */ $chapter = $book->chapters()->firstOrFail(); @@ -108,8 +104,7 @@ class PageEditorTest extends TestCase public function test_switching_from_html_to_clean_markdown_works() { - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $page->html = '

A Header

Some bold content.

'; $page->save(); @@ -121,8 +116,7 @@ class PageEditorTest extends TestCase public function test_switching_from_html_to_stable_markdown_works() { - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $page->html = '

A Header

Some bold content.

'; $page->save(); @@ -134,8 +128,7 @@ class PageEditorTest extends TestCase public function test_switching_from_markdown_to_wysiwyg_works() { - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $page->html = ''; $page->markdown = "## A Header\n\nSome content with **bold** text!"; $page->save(); @@ -180,8 +173,7 @@ class PageEditorTest extends TestCase public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions() { - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $page->html = '

A Header

Some bold content.

'; $page->save(); @@ -193,8 +185,7 @@ class PageEditorTest extends TestCase public function test_page_save_does_not_change_active_editor_without_change_editor_permissions() { - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $page->html = '

A Header

Some bold content.

'; $page->editor = 'wysiwyg'; $page->save();