Skip to content

Commit

Permalink
Use static data providers
Browse files Browse the repository at this point in the history
This becomes a requirement in PHPUNIT 10
  • Loading branch information
sirreal committed Jan 31, 2024
1 parent 70bda27 commit 7cd5331
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions tests/phpunit/tests/html-api/wpHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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' ),
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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(
'<a><strong>Click <a supported><big unsupported>Here</big></a></strong></a>',
Expand Down Expand Up @@ -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( '<img target>', array( 'HTML', 'BODY', 'IMG' ), 1 ),
'Two sibling IMG tags' => array( '<img><img target>', array( 'HTML', 'BODY', 'IMG' ), 2 ),
Expand Down Expand Up @@ -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( '<div><span><figure><img target></figure></span></div>', array( 'span', 'figure', 'img' ), true ),
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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' ),
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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( '<!--->', '' ),
Expand Down
32 changes: 16 additions & 16 deletions tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<div />', true ),
Expand Down Expand Up @@ -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' ),
Expand Down Expand Up @@ -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( '&quot;' ),
Expand Down Expand Up @@ -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( '<div id=one id=two>', 'id' ),
'Triple attributes' => array( '<div id=one id=two id=three>', 'id' ),
Expand Down Expand Up @@ -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(
'<script><span class="d-none d-md-inline">Back to notifications</span></script><div></div>',
Expand Down Expand Up @@ -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(
'<ul><li><div class=start>I <3 when outflow > inflow</div><img class=end></li></ul>',
Expand Down Expand Up @@ -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' => '<textarea><span class="d-none d-md-inline">Back to notifications</span></textarea><div></div>',
Expand Down Expand Up @@ -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( '<iframe><section>Inside</section></iframe><section target>' ),
'NOEMBED' => array( '<noembed><p></p></noembed><div target>' ),
Expand Down Expand Up @@ -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( '<div>', 'foo', false ),
'Tag with boolean class' => array( '<img class>', 'foo', false ),
Expand Down Expand Up @@ -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( '<!--' ),
'Basic truncated comment' => array( '<!-- this ends --' ),
Expand Down Expand Up @@ -2237,7 +2237,7 @@ public function test_closes_abrupt_closing_of_empty_comment( $html_with_after_ma
*
* @return array[]
*/
public function data_abruptly_closed_empty_comments() {
public static function data_abruptly_closed_empty_comments() {
return array(
'Empty comment with two dashes only' => array( '<hr><!--><hr id=after>' ),
'Empty comment with two dashes only, improperly closed' => array( '<hr><!--!><hr id=inside>--><hr id=after>' ),
Expand Down Expand Up @@ -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( '<script>console.log("<div>");</script><div target><div>' ),
'Unexpected SCRIPT closer after DIV' => array( 'console.log("<div target>")</script><div><div>' ),
Expand Down Expand Up @@ -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( '<!DOCTYPE html>Just some HTML' ),
'No tags' => array( 'this is nothing more than a text node' ),
Expand Down Expand Up @@ -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( '<swit' ),
'Incomplete tag (no attributes)' => array( '<div' ),
Expand Down Expand Up @@ -2485,7 +2485,7 @@ public function test_updating_attributes( $html, $expected ) {
*
* @return array[]
*/
public function data_updating_attributes() {
public static function data_updating_attributes() {
return array(
'tags inside of a comment' => array(
'input' => '<!-- this is a comment. no <strong>tags</strong> allowed --><span>test</span>',
Expand Down Expand Up @@ -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' => '<img src="https://s0.wp.com/i/atat.png" title="&; First &lt;title&gt; is &notit;" TITLE="second title" title="An Imperial &imperial; AT-AT"><span>test</span>',
Expand Down

0 comments on commit 7cd5331

Please sign in to comment.