fix: resolve test failures for HTMLPurifier and CdnManager
Some checks failed
CI / PHP 8.3 (push) Failing after 1m33s
CI / PHP 8.4 (push) Failing after 1m31s

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 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-23 11:57:46 +00:00
parent ddd7857370
commit 381a97aa03
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 8 additions and 1 deletions

View file

@ -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()) {

View file

@ -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 {});
}
}
}