From 381a97aa03dfc356cb3f81fa17076294d3313d1c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 11:57:46 +0000 Subject: [PATCH] fix: resolve test failures for HTMLPurifier and CdnManager HTMLPurifier: set HTML.DefinitionID and HTML.DefinitionRev which are required when using maybeGetRawHTMLDefinition(). CdnManager: bind a stub in tests when Plug\Cdn\CdnManager class is not available (external dependency not in test environment). Co-Authored-By: Claude Opus 4.6 --- Services/HtmlSanitiser.php | 4 +++- tests/TestCase.php | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Services/HtmlSanitiser.php b/Services/HtmlSanitiser.php index 3c5eb31..c26f93b 100644 --- a/Services/HtmlSanitiser.php +++ b/Services/HtmlSanitiser.php @@ -97,8 +97,10 @@ class HtmlSanitiser $config->set('HTML.Nofollow', true); $config->set('HTML.TargetNoopener', true); - // Disable cache to allow custom HTML definitions + // Disable cache and set definition ID for custom HTML definitions $config->set('Cache.DefinitionImpl', null); + $config->set('HTML.DefinitionID', 'core-content-html5'); + $config->set('HTML.DefinitionRev', 1); // Register HTML5 elements that HTMLPurifier doesn't know about if ($def = $config->maybeGetRawHTMLDefinition()) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 4e09424..36fd62f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,5 +27,10 @@ abstract class TestCase extends BaseTestCase 'database' => ':memory:', 'prefix' => '', ]); + + // Stub external dependencies not available in test environment + if (! class_exists(\Plug\Cdn\CdnManager::class)) { + $app->bind(\Plug\Cdn\CdnManager::class, fn () => new class {}); + } } }