From 4c652adee3186e8282dde9d91d6e9e1f61fdf43a Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Tue, 20 Aug 2024 18:38:20 -0700 Subject: [PATCH] Fix tests, !== ! == === --- src/wp-includes/html-api/class-wp-html-processor.php | 9 ++++----- .../tests/html-api/wpHtmlProcessorFragmentParsing.php | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index fc4871551fc67..4c779a4dec32d 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -308,10 +308,9 @@ public static function create_fragment( $html, $context = '', $encoding = } $context_node = self::parse_context_element( $context ); - var_dump( $context_node ); if ( null === $context_node ) { _doing_it_wrong( - __FUNCTION__, + __METHOD__, __( 'The context argument must be an HTML start tag.' ), '6.7.0' ); @@ -320,7 +319,7 @@ public static function create_fragment( $html, $context = '', $encoding = if ( self::is_void( $context_node[0] ) ) { _doing_it_wrong( - __FUNCTION__, + __METHOD__, __( 'The context argument may not specify a void element.' ), '6.7.0' ); @@ -329,7 +328,7 @@ public static function create_fragment( $html, $context = '', $encoding = if ( in_array( $context_node[0], array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) { _doing_it_wrong( - __FUNCTION__, + __METHOD__, __( 'The context argument may not specify a self-contained element.' ), '6.7.0' ); @@ -387,7 +386,7 @@ public static function create_fragment( $html, $context = '', $encoding = * @return array|null Element name and associative array of attributes if parsed, otherwise NULL. */ private static function parse_context_element( $context = '' ): ?array { - if ( '' !== $context ) { + if ( '' === $context ) { return array( 'BODY', array() ); } diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php b/tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php index c422ade4ca9d8..cd7a6ee2badc1 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php @@ -23,6 +23,8 @@ class Tests_HtmlApi_WpHtmlProcessorFragmentParsing extends WP_UnitTestCase { * * @dataProvider data_invalid_fragment_contexts * + * @expectedIncorrectUsage WP_HTML_Processor::create_fragment + * * @param string $context Invalid context node for fragment parser. */ public function test_rejects_invalid_fragment_contexts( string $context ) {