2121 * @group html-api-html5lib-tests
2222 */
2323class Tests_HtmlApi_Html5lib extends WP_UnitTestCase {
24+ const TREE_INDENT = ' ' ;
25+
2426 /**
2527 * Skip specific tests that may not be supported or have known issues.
2628 */
@@ -234,7 +236,6 @@ private static function build_tree_representation( ?string $fragment_context, st
234236 */
235237 $ output = '' ;
236238 $ indent_level = 0 ;
237- $ indent = ' ' ;
238239 $ was_text = null ;
239240 $ text_node = '' ;
240241
@@ -287,7 +288,7 @@ private static function build_tree_representation( ?string $fragment_context, st
287288 ++$ indent_level ;
288289 }
289290
290- $ output .= str_repeat ( $ indent , $ tag_indent ) . "< {$ tag_name }> \n" ;
291+ $ output .= str_repeat ( self :: TREE_INDENT , $ tag_indent ) . "< {$ tag_name }> \n" ;
291292
292293 $ attribute_names = $ processor ->get_attribute_names_with_prefix ( '' );
293294 if ( $ attribute_names ) {
@@ -340,18 +341,18 @@ static function ( $a, $b ) {
340341 if ( true === $ val ) {
341342 $ val = '' ;
342343 }
343- $ output .= str_repeat ( $ indent , $ tag_indent + 1 ) . "{$ display_name }= \"{$ val }\"\n" ;
344+ $ output .= str_repeat ( self :: TREE_INDENT , $ tag_indent + 1 ) . "{$ display_name }= \"{$ val }\"\n" ;
344345 }
345346 }
346347
347348 // Self-contained tags contain their inner contents as modifiable text.
348349 $ modifiable_text = $ processor ->get_modifiable_text ();
349350 if ( '' !== $ modifiable_text ) {
350- $ output .= str_repeat ( $ indent , $ tag_indent + 1 ) . "\"{$ modifiable_text }\"\n" ;
351+ $ output .= str_repeat ( self :: TREE_INDENT , $ tag_indent + 1 ) . "\"{$ modifiable_text }\"\n" ;
351352 }
352353
353354 if ( 'html ' === $ namespace && 'TEMPLATE ' === $ token_name ) {
354- $ output .= str_repeat ( $ indent , $ indent_level ) . "content \n" ;
355+ $ output .= str_repeat ( self :: TREE_INDENT , $ indent_level ) . "content \n" ;
355356 ++$ indent_level ;
356357 }
357358
@@ -365,14 +366,14 @@ static function ( $a, $b ) {
365366 }
366367 $ was_text = true ;
367368 if ( '' === $ text_node ) {
368- $ text_node .= str_repeat ( $ indent , $ indent_level ) . '" ' ;
369+ $ text_node .= str_repeat ( self :: TREE_INDENT , $ indent_level ) . '" ' ;
369370 }
370371 $ text_node .= $ text_content ;
371372 break ;
372373
373374 case '#funky-comment ' :
374375 // Comments must be "<" then "!-- " then the data then " -->".
375- $ output .= str_repeat ( $ indent , $ indent_level ) . "<!-- {$ processor ->get_modifiable_text ()} --> \n" ;
376+ $ output .= str_repeat ( self :: TREE_INDENT , $ indent_level ) . "<!-- {$ processor ->get_modifiable_text ()} --> \n" ;
376377 break ;
377378
378379 case '#comment ' :
@@ -395,7 +396,7 @@ static function ( $a, $b ) {
395396 throw new Error ( "Unhandled comment type for tree construction: {$ processor ->get_comment_type ()}" );
396397 }
397398 // Comments must be "<" then "!-- " then the data then " -->".
398- $ output .= str_repeat ( $ indent , $ indent_level ) . "<!-- {$ comment_text_content } --> \n" ;
399+ $ output .= str_repeat ( self :: TREE_INDENT , $ indent_level ) . "<!-- {$ comment_text_content } --> \n" ;
399400 break ;
400401
401402 default :
0 commit comments