]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageContentTest.php
Updated minimum php version from 7.3 to 7.4
[bookstack] / tests / Entity / PageContentTest.php
index 0b99c63c3971ab92f393e90123c04053bba922a4..9524186c8f1cdc64f0b9cd43f215515948cf98b1 100644 (file)
@@ -62,7 +62,9 @@ class PageContentTest extends TestCase
 
     public function test_page_includes_do_not_break_tables()
     {
+        /** @var Page $page */
         $page = Page::query()->first();
+        /** @var Page $secondPage */
         $secondPage = Page::query()->where('id', '!=', $page->id)->first();
 
         $content = '<table id="table"><tbody><tr><td>test</td></tr></tbody></table>';
@@ -72,8 +74,25 @@ class PageContentTest extends TestCase
         $page->html = "{{@{$secondPage->id}#table}}";
         $page->save();
 
-        $this->asEditor();
-        $pageResp = $this->get($page->getUrl());
+        $pageResp = $this->asEditor()->get($page->getUrl());
+        $pageResp->assertSee($content, false);
+    }
+
+    public function test_page_includes_do_not_break_code()
+    {
+        /** @var Page $page */
+        $page = Page::query()->first();
+        /** @var Page $secondPage */
+        $secondPage = Page::query()->where('id', '!=', $page->id)->first();
+
+        $content = '<pre id="bkmrk-code"><code>var cat = null;</code></pre>';
+        $secondPage->html = $content;
+        $secondPage->save();
+
+        $page->html = "{{@{$secondPage->id}#bkmrk-code}}";
+        $page->save();
+
+        $pageResp = $this->asEditor()->get($page->getUrl());
         $pageResp->assertSee($content, false);
     }
 
@@ -651,4 +670,24 @@ class PageContentTest extends TestCase
         $page->refresh();
         $this->assertStringContainsString('<img src=""', $page->html);
     }
+
+    public function test_nested_headers_gets_assigned_an_id()
+    {
+        $this->asEditor();
+        $page = Page::query()->first();
+
+        $content = '<table><tbody><tr><td><h5>Simple Test</h5></td></tr></tbody></table>';
+        $this->put($page->getUrl(), [
+            'name'    => $page->name,
+            'html'    => $content,
+            'summary' => '',
+        ]);
+
+        $updatedPage = Page::query()->where('id', '=', $page->id)->first();
+
+        // The top level <table> node will get assign the bkmrk-simple-test id because the system will
+        // take the node value of h5
+        // So the h5 should get the bkmrk-simple-test-1 id
+        $this->assertStringContainsString('<h5 id="bkmrk-simple-test-1">Simple Test</h5>', $updatedPage->html);
+    }
 }