From 9646339933581fb38ef96a6c272b1f299752e675 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 17 Feb 2026 11:23:34 +0000 Subject: [PATCH] Testing: Addressed failing tests and static checks --- app/Util/HtmlContentFilter.php | 4 ++-- tests/Entity/PageContentFilteringTest.php | 25 ++++++++++++++++++----- tests/Entity/PageDraftTest.php | 4 +++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/Util/HtmlContentFilter.php b/app/Util/HtmlContentFilter.php index 45144a0e8..2ef797d13 100644 --- a/app/Util/HtmlContentFilter.php +++ b/app/Util/HtmlContentFilter.php @@ -176,7 +176,7 @@ class HtmlContentFilter filterOutNonContentElements: false, useAllowListFilter: false, ); - $filter = new static($config); + $filter = new self($config); $filter->filterDocument($doc); } @@ -191,7 +191,7 @@ class HtmlContentFilter filterOutNonContentElements: false, useAllowListFilter: false, ); - $filter = new static($config); + $filter = new self($config); return $filter->filterString($html); } } diff --git a/tests/Entity/PageContentFilteringTest.php b/tests/Entity/PageContentFilteringTest.php index 312f264ca..c048c09dc 100644 --- a/tests/Entity/PageContentFilteringTest.php +++ b/tests/Entity/PageContentFilteringTest.php @@ -401,6 +401,26 @@ TESTCASE; } public function test_non_content_filtering_is_controlled_by_config() + { + config()->set('app.content_filtering', ''); + $page = $this->entities->page(); + $html = <<<'HTML' + + +HTML; + $page->html = $html; + $page->save(); + + $resp = $this->asEditor()->get($page->getUrl()); + $resp->assertSee('superbeans', false); + + config()->set('app.content_filtering', 'h'); + + $resp = $this->asEditor()->get($page->getUrl()); + $resp->assertDontSee('superbeans', false); + } + + public function test_non_content_filtering() { config()->set('app.content_filtering', 'h'); $page = $this->entities->page(); @@ -421,11 +441,6 @@ HTML; $resp->assertSee('inbetweenpsection', false); } - public function test_non_content_filtering() - { - config()->set('app.content_filtering', 'h'); - } - public function test_allow_list_filtering_is_controlled_by_config() { config()->set('app.content_filtering', ''); diff --git a/tests/Entity/PageDraftTest.php b/tests/Entity/PageDraftTest.php index 2623acd3f..8a30a9750 100644 --- a/tests/Entity/PageDraftTest.php +++ b/tests/Entity/PageDraftTest.php @@ -160,9 +160,11 @@ class PageDraftTest extends TestCase { $this->asAdmin(); $page = $this->entities->page(); + $page->html = '

test content

'; + $page->save(); $this->getJson('/ajax/page/' . $page->id)->assertJson([ - 'html' => $page->html, + 'html' => '

test content

', ]); }