Skip to content

Commit

Permalink
Improve skipped test reporting with unsupported exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Sep 3, 2024
1 parent 95eb879 commit f5e38ac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
* @param string $expected_tree Tree structure of parsed HTML.
*/
public function test_parse( ?string $fragment_context, string $html, string $expected_tree ) {
$processed_tree = self::build_tree_representation( $fragment_context, $html );
try {
$processed_tree = self::build_tree_representation( $fragment_context, $html );
} catch ( WP_HTML_Unsupported_Exception $e ) {
$this->markTestSkipped( $e->getMessage() );
return;
}

if ( null === $processed_tree ) {
$this->markTestSkipped( 'Test includes unsupported markup.' );
return;
}
$fragment_detail = $fragment_context ? " in context <{$fragment_context}>" : '';

Expand Down Expand Up @@ -170,7 +176,10 @@ private static function build_tree_representation( ?string $fragment_context, st
$text_node = '';

while ( $processor->next_token() ) {
if ( ! is_null( $processor->get_last_error() ) ) {
if ( null !== $processor->get_unsupported_exception() ) {
throw $processor->get_unsupported_exception();
}
if ( null !== $processor->get_last_error() ) {
return null;
}

Expand Down

0 comments on commit f5e38ac

Please sign in to comment.