]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageDraftTest.php
Fixes for CodeStyle vol.2
[bookstack] / tests / Entity / PageDraftTest.php
index 5c984940d32569ce3e0b5d1cdce60bef2bf9d1cb..68059af6e7126d1c2b75487d425b6c684a8aca3e 100644 (file)
@@ -1,5 +1,8 @@
-<?php namespace Tests\Entity;
+<?php
 
+namespace Tests\Entity;
+
+use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
 use Tests\BrowserKitTest;
 
@@ -15,7 +18,7 @@ class PageDraftTest extends BrowserKitTest
     public function setUp(): void
     {
         parent::setUp();
-        $this->page = \BookStack\Entities\Page::first();
+        $this->page = \BookStack\Entities\Models\Page::first();
         $this->pageRepo = app(PageRepo::class);
     }
 
@@ -55,7 +58,7 @@ class PageDraftTest extends BrowserKitTest
 
     public function test_alert_message_shows_if_someone_else_editing()
     {
-        $nonEditedPage = \BookStack\Entities\Page::take(10)->get()->last();
+        $nonEditedPage = \BookStack\Entities\Models\Page::take(10)->get()->last();
         $addedContent = '<p>test message content</p>';
         $this->asAdmin()->visit($this->page->getUrl('/edit'))
             ->dontSeeInField('html', $addedContent);
@@ -67,14 +70,14 @@ class PageDraftTest extends BrowserKitTest
         $this->actingAs($newUser)
             ->visit($this->page->getUrl('/edit'))
             ->see('Admin has started editing this page');
-            $this->flushSession();
+        $this->flushSession();
         $this->visit($nonEditedPage->getUrl() . '/edit')
             ->dontSeeInElement('.notification', 'Admin has started editing this page');
     }
 
     public function test_draft_pages_show_on_homepage()
     {
-        $book = \BookStack\Entities\Book::first();
+        $book = \BookStack\Entities\Models\Book::first();
         $this->asAdmin()->visit('/')
             ->dontSeeInElement('#recent-drafts', 'New Page')
             ->visit($book->getUrl() . '/create-page')
@@ -84,7 +87,7 @@ class PageDraftTest extends BrowserKitTest
 
     public function test_draft_pages_not_visible_by_others()
     {
-        $book = \BookStack\Entities\Book::first();
+        $book = \BookStack\Entities\Models\Book::first();
         $chapter = $book->chapters->first();
         $newUser = $this->getEditor();
 
@@ -101,4 +104,14 @@ class PageDraftTest extends BrowserKitTest
             ->dontSeeInElement('.book-contents', 'New Page');
     }
 
+    public function test_page_html_in_ajax_fetch_response()
+    {
+        $this->asAdmin();
+        $page = Page::query()->first();
+
+        $this->getJson('/ajax/page/' . $page->id);
+        $this->seeJson([
+            'html' => $page->html,
+        ]);
+    }
 }