Changeset 58971
- Timestamp:
- 09/03/2024 04:25:16 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
r58970 r58971 55 55 */ 56 56 public function test_parse( ?string $fragment_context, string $html, string $expected_tree ) { 57 $processed_tree = self::build_tree_representation( $fragment_context, $html ); 57 try { 58 $processed_tree = self::build_tree_representation( $fragment_context, $html ); 59 } catch ( WP_HTML_Unsupported_Exception $e ) { 60 $this->markTestSkipped( "Unsupported markup: {$e->getMessage()}" ); 61 return; 62 } 58 63 59 64 if ( null === $processed_tree ) { 60 65 $this->markTestSkipped( 'Test includes unsupported markup.' ); 61 } 66 return; 67 } 68 62 69 $fragment_detail = $fragment_context ? " in context <{$fragment_context}>" : ''; 63 70 … … 156 163 : WP_HTML_Processor::create_full_parser( $html ); 157 164 if ( null === $processor ) { 158 return null;165 throw new WP_HTML_Unsupported_Exception( "Could not create a parser with the given fragment context: {$fragment_context}.", '', 0, '', array(), array() ); 159 166 } 160 167 … … 171 178 172 179 while ( $processor->next_token() ) { 173 if ( ! is_null( $processor->get_last_error()) ) {174 return null;180 if ( null !== $processor->get_last_error() ) { 181 break; 175 182 } 176 183 … … 336 343 } 337 344 338 if ( ! is_null( $processor->get_last_error() ) ) { 339 return null; 345 if ( null !== $processor->get_unsupported_exception() ) { 346 throw $processor->get_unsupported_exception(); 347 } 348 349 if ( null !== $processor->get_last_error() ) { 350 throw new WP_HTML_Unsupported_Exception( "Parser error: {$processor->get_last_error()}", '', 0, '', array(), array() ); 340 351 } 341 352 342 353 if ( $processor->paused_at_incomplete_token() ) { 343 return null;354 throw new WP_HTML_Unsupported_Exception( 'Paused at incomplete token.', '', 0, '', array(), array() ); 344 355 } 345 356
Note: See TracChangeset
for help on using the changeset viewer.