mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-06 12:02:45 +03:00
Includes: Switched page to new system
- Added mulit-level depth parsing. - Updating usage of HTML doc in page content to be efficient. - Removed now redundant PageContentTest cases. - Made some include system fixes based upon testing.
This commit is contained in:
@@ -8,7 +8,7 @@ use Tests\TestCase;
|
||||
|
||||
class PageContentTest extends TestCase
|
||||
{
|
||||
protected $base64Jpeg = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=';
|
||||
protected string $base64Jpeg = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=';
|
||||
|
||||
public function test_page_includes()
|
||||
{
|
||||
@@ -57,38 +57,6 @@ class PageContentTest extends TestCase
|
||||
$this->assertEquals('', $page->text);
|
||||
}
|
||||
|
||||
public function test_page_includes_do_not_break_tables()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
$secondPage = $this->entities->page();
|
||||
|
||||
$content = '<table id="table"><tbody><tr><td>test</td></tr></tbody></table>';
|
||||
$secondPage->html = $content;
|
||||
$secondPage->save();
|
||||
|
||||
$page->html = "{{@{$secondPage->id}#table}}";
|
||||
$page->save();
|
||||
|
||||
$pageResp = $this->asEditor()->get($page->getUrl());
|
||||
$pageResp->assertSee($content, false);
|
||||
}
|
||||
|
||||
public function test_page_includes_do_not_break_code()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
$secondPage = $this->entities->page();
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
public function test_page_includes_rendered_on_book_export()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Unit;
|
||||
|
||||
use BookStack\Entities\Tools\PageIncludeParser;
|
||||
use BookStack\Util\HtmlDocument;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PageIncludeParserTest extends TestCase
|
||||
@@ -214,13 +215,14 @@ class PageIncludeParserTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
protected function runParserTest(string $html, array $contentById, string $expected)
|
||||
protected function runParserTest(string $html, array $contentById, string $expected): void
|
||||
{
|
||||
$parser = new PageIncludeParser($html, function (int $id) use ($contentById) {
|
||||
$doc = new HtmlDocument($html);
|
||||
$parser = new PageIncludeParser($doc, function (int $id) use ($contentById) {
|
||||
return $contentById[strval($id)] ?? '';
|
||||
});
|
||||
|
||||
$result = $parser->parse();
|
||||
$this->assertEquals($expected, $result);
|
||||
$parser->parse();
|
||||
$this->assertEquals($expected, $doc->getBodyInnerHtml());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user