Skip to content

Commit 883bfe5

Browse files
committed
Prevent test failure from E_USER_WARNING
1 parent bfb2f9c commit 883bfe5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ public function test_normalize_special_leading_newline_handling( string $input,
352352
*/
353353
public function test_normalize_fuzzer_cases_do_not_emit_native_errors( string $input, ?string $expected ) {
354354
$errors = array();
355+
356+
/*
357+
* This test is checking for native PHP warnings/notices. Unsupported HTML may
358+
* intentionally cause wp_trigger_error() under WP_DEBUG, which is separate
359+
* from the native errors this regression test is trying to catch.
360+
*/
361+
add_filter( 'wp_trigger_error_trigger_error', '__return_false' );
355362
set_error_handler(
356363
static function ( int $errno, string $errstr ) use ( &$errors ) {
357364
$errors[] = "{$errno}: {$errstr}";
@@ -363,6 +370,7 @@ static function ( int $errno, string $errstr ) use ( &$errors ) {
363370
$normalized = WP_HTML_Processor::normalize( $input );
364371
} finally {
365372
restore_error_handler();
373+
remove_filter( 'wp_trigger_error_trigger_error', '__return_false' );
366374
}
367375

368376
// Use assertSame() instead of assertEmpty() so PHPUnit shows captured error messages on failure.

0 commit comments

Comments
 (0)