X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/8c945034b9f12e728c601502e730d2cfe4c937cf..refs/pull/4467/head:/tests/Entity/PageContentTest.php diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 0c9854206..d8845fe12 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -5,12 +5,9 @@ namespace Tests\Entity; use BookStack\Entities\Models\Page; use BookStack\Entities\Tools\PageContent; use Tests\TestCase; -use Tests\Uploads\UsesImages; class PageContentTest extends TestCase { - use UsesImages; - protected $base64Jpeg = '/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k='; public function test_page_includes() @@ -111,6 +108,18 @@ class PageContentTest extends TestCase $htmlContent->assertSee('my cat is awesome and scratchy'); } + public function test_page_includes_can_be_nested_up_to_three_times() + { + $page = $this->entities->page(); + $tag = "{{@{$page->id}#bkmrk-test}}"; + $page->html = '
Hello Barry ' . $tag . '
'; + $page->save(); + + $pageResp = $this->asEditor()->get($page->getUrl()); + $this->withHtml($pageResp)->assertElementContains('#bkmrk-test', 'Hello Barry Hello Barry Hello Barry Hello Barry ' . $tag); + $this->withHtml($pageResp)->assertElementNotContains('#bkmrk-test', 'Hello Barry Hello Barry Hello Barry Hello Barry Hello Barry ' . $tag); + } + public function test_page_content_scripts_removed_by_default() { $this->asEditor(); @@ -310,7 +319,7 @@ class PageContentTest extends TestCase { $this->asEditor(); $page = $this->entities->page(); - config()->push('app.allow_content_scripts', 'true'); + config()->set('app.allow_content_scripts', 'true'); $script = 'abc123abc123'; $page->html = "no escape {$script}"; @@ -355,7 +364,7 @@ class PageContentTest extends TestCase { $this->asEditor(); $page = $this->entities->page(); - config()->push('app.allow_content_scripts', 'true'); + config()->set('app.allow_content_scripts', 'true'); $script = 'Hello
'; $page->html = "escape {$script}"; @@ -483,7 +492,7 @@ class PageContentTest extends TestCase { $page = $this->entities->page(); - $this->actingAs($this->getAdmin()) + $this->actingAs($this->users->admin()) ->put($page->getUrl(''), [ 'name' => 'Testing', 'html' => '"Hello & welcome"
', @@ -591,7 +600,7 @@ class PageContentTest extends TestCase $imageFile = public_path($imagePath); $this->assertEquals(base64_decode($this->base64Jpeg), file_get_contents($imageFile)); - $this->deleteImage($imagePath); + $this->files->deleteAtRelativePath($imagePath); } public function test_base64_images_get_extracted_when_containing_whitespace() @@ -615,7 +624,7 @@ class PageContentTest extends TestCase $imageFile = public_path($imagePath); $this->assertEquals(base64_decode($base64PngWithoutWhitespace), file_get_contents($imageFile)); - $this->deleteImage($imagePath); + $this->files->deleteAtRelativePath($imagePath); } public function test_base64_images_within_html_blanked_if_not_supported_extension_for_extract() @@ -659,7 +668,7 @@ class PageContentTest extends TestCase $imageFile = public_path($imagePath); $this->assertEquals(base64_decode($this->base64Jpeg), file_get_contents($imageFile)); - $this->deleteImage($imagePath); + $this->files->deleteAtRelativePath($imagePath); } public function test_markdown_base64_extract_not_limited_by_pcre_limits() @@ -690,7 +699,7 @@ class PageContentTest extends TestCase $imageFile = public_path($imagePath); $this->assertEquals($content, file_get_contents($imageFile)); - $this->deleteImage($imagePath); + $this->files->deleteAtRelativePath($imagePath); ini_set('pcre.backtrack_limit', $pcreBacktrackLimit); ini_set('pcre.recursion_limit', $pcreRecursionLimit); } @@ -735,4 +744,23 @@ class PageContentTest extends TestCase $this->assertStringContainsString('', $page->refresh()->html); } + + public function test_page_save_with_many_headers_and_links_is_reasonable() + { + $page = $this->entities->page(); + + $content = ''; + for ($i = 0; $i < 500; $i++) { + $content .= "
Simple Test |