]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageContentTest.php
Finished migrated from icon-font to SVG
[bookstack] / tests / Entity / PageContentTest.php
index 6b64c2c640ef8427f72322ae489b9508636bf44e..37051478882e94f25c9cb1f6f2c5f334779a043d 100644 (file)
@@ -9,7 +9,7 @@ class PageContentTest extends TestCase
     public function test_page_includes()
     {
         $page = Page::first();
-        $secondPage = Page::all()->get(2);
+        $secondPage = Page::where('id', '!=', $page->id)->first();
 
         $secondPage->html = "<p id='section1'>Hello, This is a test</p><p id='section2'>This is a second block of content</p>";
         $secondPage->save();
@@ -35,6 +35,38 @@ class PageContentTest extends TestCase
         $pageContent->assertSee('Well This is a second block of content');
     }
 
+    public function test_saving_page_with_includes()
+    {
+        $page = Page::first();
+        $secondPage = Page::where('id', '!=', $page->id)->first();
+        $this->asEditor();
+        $page->html = "<p>{{@$secondPage->id}}</p>";
+
+        $resp = $this->put($page->getUrl(), ['name' => $page->name, 'html' => $page->html, 'summary' => '']);
+
+        $resp->assertStatus(302);
+
+        $page = Page::find($page->id);
+        $this->assertContains("{{@$secondPage->id}}", $page->html);
+    }
+
+    public function test_page_includes_do_not_break_tables()
+    {
+        $page = Page::first();
+        $secondPage = Page::where('id', '!=', $page->id)->first();
+
+        $content = '<table id="table"><tbody><tr><td>test</td></tr></tbody></table>';
+        $secondPage->html = $content;
+        $secondPage->save();
+
+        $page->html = "{{@{$secondPage->id}#table}}";
+        $page->save();
+
+        $this->asEditor();
+        $pageResp = $this->get($page->getUrl());
+        $pageResp->assertSee($content);
+    }
+
     public function test_page_revision_views_viewable()
     {
         $this->asEditor();