Make WordPress Core


Ignore:
Timestamp:
09/04/2025 02:48:51 PM (2 months ago)
Author:
jonsurrell
Message:

Build/Test Tools: Ensure assertEqualHTML fallback render can be reached.

assertEqualHTML catches Exceptions and attempts to re-parse the HTML with the Dom\HtmlDocument class. Ensure that the fallback render is reachable by throwing Exception instead of Error in the tree builder function.

Developed in https://github.com/WordPress/wordpress-develop/pull/9273.

Follow-up to [60295].

Props jonsurrell, bernhard-reiter, dmsnell.
Fixes #63527.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/build-visual-html-tree.php

    r60295 r60707  
    4141 * @since 6.9.0
    4242 *
    43  * @throws WP_HTML_Unsupported_Exception|Error If the markup could not be parsed.
     43 * @throws WP_HTML_Unsupported_Exception|Exception If the markup could not be parsed.
    4444 *
    4545 * @param string      $html             Given test HTML.
     
    5252        : WP_HTML_Processor::create_full_parser( $html );
    5353    if ( null === $processor ) {
    54         throw new Error( 'Could not create a parser.' );
     54        throw new Exception( 'Could not create a parser.' );
    5555    }
    5656    $tree_indent = '  ';
     
    281281                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    282282                $serialized_token_type = var_export( $processor->get_token_type(), true );
    283                 throw new Error( "Unhandled token type for tree construction: {$serialized_token_type}" );
     283                throw new Exception( "Unhandled token type for tree construction: {$serialized_token_type}" );
    284284        }
    285285    }
     
    290290
    291291    if ( null !== $processor->get_last_error() ) {
    292         throw new Error( "Parser error: {$processor->get_last_error()}" );
     292        throw new Exception( "Parser error: {$processor->get_last_error()}" );
    293293    }
    294294
    295295    if ( $processor->paused_at_incomplete_token() ) {
    296         throw new Error( 'Paused at incomplete token.' );
     296        throw new Exception( 'Paused at incomplete token.' );
    297297    }
    298298
Note: See TracChangeset for help on using the changeset viewer.