From 7cd5331e1be406a908e94b3e73fbef52aa104598 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 31 Jan 2024 13:32:38 +0100 Subject: [PATCH] Use static data providers This becomes a requirement in PHPUNIT 10 --- .../tests/html-api/wpHtmlProcessor.php | 4 +-- .../html-api/wpHtmlProcessorBreadcrumbs.php | 10 +++--- .../html-api/wpHtmlProcessorSemanticRules.php | 6 ++-- ...lProcessorSemanticRulesHeadingElements.php | 4 +-- .../wpHtmlTagProcessor-token-scanning.php | 4 +-- .../tests/html-api/wpHtmlTagProcessor.php | 32 +++++++++---------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php index 120cf354e9b0b..49010607e7781 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php @@ -193,7 +193,7 @@ public function test_cannot_nest_void_tags( $tag_name ) { * * @return array[] */ - public function data_void_tags() { + public static function data_void_tags() { return array( 'AREA' => array( 'AREA' ), 'BASE' => array( 'BASE' ), @@ -237,7 +237,7 @@ public function test_step_in_body_fails_on_unsupported_tags( $tag_name ) { * * @return array[] */ - public function data_unsupported_special_in_body_tags() { + public static function data_unsupported_special_in_body_tags() { return array( 'APPLET' => array( 'APPLET' ), 'BASE' => array( 'BASE' ), diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index 06576ba1e6123..1488be91654a7 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -34,7 +34,7 @@ public function test_navigates_into_normative_html_for_supported_elements( $html * * @return array[] */ - public function data_single_tag_of_supported_elements() { + public static function data_single_tag_of_supported_elements() { $supported_elements = array( 'A', 'ABBR', @@ -165,7 +165,7 @@ public function test_fails_when_encountering_unsupported_tag( $html ) { * * @return array[] */ - public function data_unsupported_elements() { + public static function data_unsupported_elements() { $unsupported_elements = array( 'APPLET', // Deprecated. 'BASE', @@ -244,7 +244,7 @@ public function test_fails_when_encountering_unsupported_markup( $html, $descrip * * @return array[] */ - public function data_unsupported_markup() { + public static function data_unsupported_markup() { return array( 'A with formatting following unclosed A' => array( 'Click Here', @@ -310,7 +310,7 @@ public function test_reports_correct_breadcrumbs_for_html( $html, $breadcrumbs, * * @return array[] */ - public function data_html_target_with_breadcrumbs() { + public static function data_html_target_with_breadcrumbs() { return array( 'Simple IMG tag' => array( '', array( 'HTML', 'BODY', 'IMG' ), 1 ), 'Two sibling IMG tags' => array( '', array( 'HTML', 'BODY', 'IMG' ), 2 ), @@ -393,7 +393,7 @@ public function test_reports_if_tag_matches_breadcrumbs_of_various_specificity( * * @return array[]. */ - public function data_html_with_breadcrumbs_of_various_specificity() { + public static function data_html_with_breadcrumbs_of_various_specificity() { return array( // Test with void elements. 'Inner IMG' => array( '
', array( 'span', 'figure', 'img' ), true ), diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php index ca1acb2660e29..7362a588cf3f4 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php @@ -79,7 +79,7 @@ public function test_in_body_article_group_can_nest_inside_itself( $tag_name ) { * * @return array[]. */ - public function data_article_container_group() { + public static function data_article_container_group() { $group = array(); foreach ( @@ -274,7 +274,7 @@ public function test_in_body_heading_element_closes_open_p_tag( $tag_name ) { * * @return array[]. */ - public function data_heading_elements() { + public static function data_heading_elements() { return array( 'H1' => array( 'H1' ), 'H2' => array( 'H2' ), @@ -328,7 +328,7 @@ public function test_in_body_heading_element_closes_other_heading_elements( $fir * * @return array[] */ - public function data_heading_combinations() { + public static function data_heading_combinations() { $headings = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ); $combinations = array(); diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php index d8d70acb61e76..b33c6e072dfb1 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRulesHeadingElements.php @@ -53,7 +53,7 @@ public function test_in_body_heading_element_closes_open_p_tag( $tag_name ) { * * @return array[]. */ - public function data_heading_elements() { + public static function data_heading_elements() { return array( 'H1' => array( 'H1' ), 'H2' => array( 'H2' ), @@ -109,7 +109,7 @@ public function test_in_body_heading_element_closes_other_heading_elements( $fir * * @return array[] */ - public function data_heading_combinations() { + public static function data_heading_combinations() { $headings = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ); $combinations = array(); diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php index 538144910550f..efcc4a01f745f 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php @@ -295,7 +295,7 @@ public function test_basic_assertion_rawtext_elements( $tag_name ) { * * @return array[]. */ - public function data_rawtext_elements() { + public static function data_rawtext_elements() { return array( 'IFRAME' => array( 'IFRAME' ), 'NOEMBED' => array( 'NOEMBED' ), @@ -542,7 +542,7 @@ public function test_basic_assertion_common_comments( $html, $text ) { * * @return array[]. */ - public function data_common_comments() { + public static function data_common_comments() { return array( 'Shortest comment' => array( '', '' ), 'Short comment' => array( '', '' ), diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 2121ffa221fc9..5375a2fca0ebf 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -77,7 +77,7 @@ public function test_has_self_closing_flag_matches_input_html( $html, $flag_is_s * * @return array[] */ - public function data_has_self_closing_flag() { + public static function data_has_self_closing_flag() { return array( // These should not have a self-closer, and will leave an element un-closed if it's assumed they are self-closing. 'Self-closing flag on non-void HTML element' => array( '
', true ), @@ -259,7 +259,7 @@ public function test_attributes_parser_is_case_insensitive_for_attributes_withou * * @return array[]. */ - public function data_attribute_name_case_variants() { + public static function data_attribute_name_case_variants() { return array( array( 'DATA-enabled' ), array( 'data-enabled' ), @@ -724,7 +724,7 @@ public function test_set_attribute_prevents_xss( $attribute_value ) { * * @return string[][]. */ - public function data_set_attribute_prevents_xss() { + public static function data_set_attribute_prevents_xss() { return array( array( '"' ), array( '"' ), @@ -1146,7 +1146,7 @@ public function test_previous_duplicated_attributes_are_not_removed_on_successiv * * @return array[]. */ - public function data_html_with_duplicated_attributes() { + public static function data_html_with_duplicated_attributes() { return array( 'Double attributes' => array( '
', 'id' ), 'Triple attributes' => array( '
', 'id' ), @@ -1801,7 +1801,7 @@ public function test_next_tag_ignores_script_tag_contents( $script_then_div ) { * * @return array[]. */ - public function data_next_tag_ignores_script_tag_contents() { + public static function data_next_tag_ignores_script_tag_contents() { return array( 'Simple script tag' => array( '
', @@ -1878,7 +1878,7 @@ public function test_next_tag_ignores_invalid_first_character_of_tag_name_commen * * @return array[] */ - public function data_next_tag_ignores_invalid_first_character_of_tag_name_comments() { + public static function data_next_tag_ignores_invalid_first_character_of_tag_name_comments() { return array( 'Invalid tag openers as normal text' => array( '
  • I <3 when outflow > inflow
', @@ -1917,7 +1917,7 @@ public function test_next_tag_ignores_contents_of_rcdata_tag( $rcdata_then_div, * * @return array[] */ - public function data_next_tag_ignores_contents_of_rcdata_tag() { + public static function data_next_tag_ignores_contents_of_rcdata_tag() { return array( 'simple textarea' => array( 'rcdata_then_div' => '
', @@ -1996,7 +1996,7 @@ public function test_next_tag_ignores_contents_of_rawtext_tags( $rawtext_element * * @return array[]. */ - public function data_next_tag_ignores_contents_of_rawtext_tags() { + public static function data_next_tag_ignores_contents_of_rawtext_tags() { return array( 'IFRAME' => array( '
' ), 'NOEMBED' => array( '<p></p>
' ), @@ -2135,7 +2135,7 @@ public function test_has_class_handles_expected_class_name_variations( $html, $s * * @return array[] */ - public function data_html_with_variations_of_class_values_and_sought_class_names() { + public static function data_html_with_variations_of_class_values_and_sought_class_names() { return array( 'Tag without any classes' => array( '
', 'foo', false ), 'Tag with boolean class' => array( '', 'foo', false ), @@ -2202,7 +2202,7 @@ public function test_documents_may_end_with_unclosed_comment( $html_ending_befor * * @return array[] */ - public function data_html_with_unclosed_comments() { + public static function data_html_with_unclosed_comments() { return array( 'Shortest open valid comment' => array( '
' ), 'Empty comment with two dashes only, improperly closed' => array( '

' ), @@ -2276,7 +2276,7 @@ public function test_skips_contents_of_script_and_rcdata_regions( $input_html ) * * @return array[] */ - public function data_skips_contents_of_script_and_rcdata_regions() { + public static function data_skips_contents_of_script_and_rcdata_regions() { return array( 'Balanced SCRIPT tags' => array( '
' ), 'Unexpected SCRIPT closer after DIV' => array( 'console.log("
")
' ), @@ -2357,7 +2357,7 @@ public function test_next_tag_returns_false_when_there_are_no_tags( $html_withou * * @return array[] */ - public function data_html_without_tags() { + public static function data_html_without_tags() { return array( 'DOCTYPE declaration' => array( 'Just some HTML' ), 'No tags' => array( 'this is nothing more than a text node' ), @@ -2400,7 +2400,7 @@ public function test_next_tag_returns_false_for_incomplete_syntax_elements( $inc * * @return array[] */ - public function data_incomplete_syntax_elements() { + public static function data_incomplete_syntax_elements() { return array( 'Incomplete tag name' => array( ' array( ' array( 'input' => 'test', @@ -2549,7 +2549,7 @@ public function test_updating_attributes_in_malformed_html( $html, $expected ) { * * @return array[] */ - public function data_updating_attributes_in_malformed_html() { + public static function data_updating_attributes_in_malformed_html() { return array( 'Invalid entity inside attribute value' => array( 'input' => 'test',