Skip to content

Commit 8178c01

Browse files
committed
Tests: Make image, privacy and KSES data providers static.
Declare 25 data providers in the image metadata, privacy export, and KSES tests as `public static` for compatibility with newer PHPUnit versions. Call the existing static `text_array_to_dataprovider()` helper with `self::`. Preserve all datasets and assertions. Developed in: #14956, #14959, #14963 Props rejaulalomkhan, huzaifaalmesbah, mukesh27. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@65028 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c8a7b08 commit 8178c01

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

‎tests/phpunit/tests/image/meta.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function test_stream( $file, $expected ) {
193193
$this->assertSame( $expected, $actual );
194194
}
195195

196-
public function data_stream() {
196+
public static function data_stream() {
197197
return array(
198198
'Orientation only metadata' => array(
199199
'file' => 'testimagemeta://wp_read_image_metadata/image1.jpg',

‎tests/phpunit/tests/kses.php‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function test_wp_filter_post_kses_address( $content, $expected ) {
2828
* @type string $expected Expected result after passing through kses.
2929
* }
3030
*/
31-
public function data_wp_filter_post_kses_address() {
31+
public static function data_wp_filter_post_kses_address() {
3232
$attributes = array(
3333
'class' => 'classname',
3434
'id' => 'id',
@@ -76,7 +76,7 @@ public function test_wp_filter_post_kses_a( $content, $expected ) {
7676
* @type string $expected Expected result after passing through kses.
7777
* }
7878
*/
79-
public function data_wp_filter_post_kses_a() {
79+
public static function data_wp_filter_post_kses_a() {
8080
$attributes = array(
8181
'class' => 'classname',
8282
'id' => 'id',
@@ -177,7 +177,7 @@ public function test_wp_kses_video( $source, $context, $expected ) {
177177
* @type string $expected Expected output following KSES parsing.
178178
* }
179179
*/
180-
public function data_wp_kses_video() {
180+
public static function data_wp_kses_video() {
181181
return array(
182182
// Set 0: Valid post object params in post context.
183183
array(
@@ -227,7 +227,7 @@ public function test_wp_filter_post_kses_abbr( $content, $expected ) {
227227
* @type string $expected Expected result after passing through kses.
228228
* }
229229
*/
230-
public function data_wp_filter_post_kses_abbr() {
230+
public static function data_wp_filter_post_kses_abbr() {
231231
$attributes = array(
232232
'class' => 'classname',
233233
'id' => 'id',
@@ -903,7 +903,7 @@ public function test_ctrl_removal( $content, $expected ) {
903903
$this->assertSame( $expected, wp_kses( $content, $allowedposttags ) );
904904
}
905905

906-
public function data_ctrl_removal() {
906+
public static function data_ctrl_removal() {
907907
return array(
908908
array(
909909
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\X1C\x1D\x1E\x1F",
@@ -955,7 +955,7 @@ public function test_slash_zero_removal( $content, $expected ) {
955955
return $this->assertEqualHTML( $expected, wp_kses( $content, $with_style ) );
956956
}
957957

958-
public function data_slash_zero_removal() {
958+
public static function data_slash_zero_removal() {
959959
return array(
960960
array(
961961
'This \\0 should be no big deal.',
@@ -1005,7 +1005,7 @@ public function test_hair_parse( $input, $output ) {
10051005
return $this->assertSame( $output, wp_kses_hair_parse( $input ) );
10061006
}
10071007

1008-
public function data_hair_parse() {
1008+
public static function data_hair_parse() {
10091009
return array(
10101010
array(
10111011
'title="hello" href="#" id="my_id" ',
@@ -1071,7 +1071,7 @@ public function test_attr_parse( $input, $output ) {
10711071
return $this->assertSame( $output, wp_kses_attr_parse( $input ) );
10721072
}
10731073

1074-
public function data_attr_parse() {
1074+
public static function data_attr_parse() {
10751075
return array(
10761076
array(
10771077
'<a title="hello" href="#" id="my_id" >',
@@ -1129,7 +1129,7 @@ public function test_one_attr( $element, $input, $output ) {
11291129
return $this->assertSame( $output, wp_kses_one_attr( $input, $element ) );
11301130
}
11311131

1132-
public function data_one_attr() {
1132+
public static function data_one_attr() {
11331133
return array(
11341134
array(
11351135
'a',
@@ -1307,7 +1307,7 @@ public function test_safecss_filter_attr( $css, $expected ) {
13071307
* }
13081308
* }
13091309
*/
1310-
public function data_safecss_filter_attr() {
1310+
public static function data_safecss_filter_attr() {
13111311
return array(
13121312
// Empty input, empty output.
13131313
array(
@@ -2062,7 +2062,7 @@ public function test_wildcard_attribute_prefixes( $wildcard_attribute, $expected
20622062
* [0] The prefix being tested.
20632063
* [1] The outcome of `wp_kses_attr_check` for the prefix.
20642064
*/
2065-
public function data_wildcard_attribute_prefixes() {
2065+
public static function data_wildcard_attribute_prefixes() {
20662066
return array(
20672067
// Ends correctly.
20682068
array( 'data-*', true ),
@@ -2101,7 +2101,7 @@ public function test_wp_kses_style_attr_decodes_entities_before_css_filtering( $
21012101
*
21022102
* @return array[]
21032103
*/
2104-
public function data_wp_kses_style_attr_decodes_entities_before_css_filtering() {
2104+
public static function data_wp_kses_style_attr_decodes_entities_before_css_filtering() {
21052105
return array(
21062106
'background image URL with single quotes' => array(
21072107
'<div style="background-image: url(\'https://localhost/image.jpg\');"></div>',
@@ -2145,7 +2145,7 @@ public function test_kses_style_attr_with_url( $input, $expected ) {
21452145
*
21462146
* @return array Nested array of input, expected pairs.
21472147
*/
2148-
public function data_kses_style_attr_with_url() {
2148+
public static function data_kses_style_attr_with_url() {
21492149
return array(
21502150
/*
21512151
* Valid use cases.
@@ -2297,7 +2297,7 @@ public function test_safecss_filter_attr_filtered( $css, $expected ) {
22972297
* }
22982298
* }
22992299
*/
2300-
public function data_safecss_filter_attr_filtered() {
2300+
public static function data_safecss_filter_attr_filtered() {
23012301
return array(
23022302

23032303
// A single attribute name, with a single value.
@@ -2423,7 +2423,7 @@ public function test_wp_kses_object_tag_allowed( $html, $expected ) {
24232423
/**
24242424
* Data provider for test_wp_kses_object_tag_allowed().
24252425
*/
2426-
public function data_wp_kses_object_tag_allowed() {
2426+
public static function data_wp_kses_object_tag_allowed() {
24272427
return array(
24282428
'valid value for type' => array(
24292429
'<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
@@ -2534,7 +2534,7 @@ public function test_wp_kses_object_data_url_with_port_number_allowed( $html, $e
25342534
/**
25352535
* Data provider for test_wp_kses_object_data_url_with_port_number_allowed().
25362536
*/
2537-
public function data_wp_kses_object_data_url_with_port_number_allowed() {
2537+
public static function data_wp_kses_object_data_url_with_port_number_allowed() {
25382538
return array(
25392539
'url with port number' => array(
25402540
'<object type="application/pdf" data="https://example.org:8888/cat/foo.pdf" />',
@@ -2665,7 +2665,7 @@ public function test_wp_kses_allowed_values_list( $content, $expected, $allowed_
26652665
/**
26662666
* Data provider for test_wp_kses_allowed_values_list().
26672667
*/
2668-
public function data_wp_kses_allowed_values_list() {
2668+
public static function data_wp_kses_allowed_values_list() {
26692669
$data = array(
26702670
'valid dir attribute value' => array(
26712671
'<p dir="ltr">foo</p>',
@@ -2723,7 +2723,7 @@ public function test_wp_kses_required_attribute( $content, $expected, $allowed_h
27232723
/**
27242724
* Data provider for test_wp_kses_required_attribute().
27252725
*/
2726-
public function data_wp_kses_required_attribute() {
2726+
public static function data_wp_kses_required_attribute() {
27272727
$data = array(
27282728
'valid dir attribute value' => array(
27292729
'<p dir="ltr">foo</p>', // Test HTML.
@@ -2844,7 +2844,7 @@ public function test_wp_kses_xml_named_entities( $input, $expected ) {
28442844
*
28452845
* @return array Nested array of input, expected pairs.
28462846
*/
2847-
public function data_wp_kses_xml_named_entities() {
2847+
public static function data_wp_kses_xml_named_entities() {
28482848
return array(
28492849
// Empty string value testing.
28502850
'empty string' => array(
@@ -2913,15 +2913,15 @@ public function test_kses_globals_are_defined( $global_name ) {
29132913
*
29142914
* @return array
29152915
*/
2916-
public function data_kses_globals_are_defined() {
2916+
public static function data_kses_globals_are_defined() {
29172917
$required_kses_globals = array(
29182918
'allowedposttags',
29192919
'allowedtags',
29202920
'allowedentitynames',
29212921
'allowedxmlentitynames',
29222922
);
29232923

2924-
return $this->text_array_to_dataprovider( $required_kses_globals );
2924+
return self::text_array_to_dataprovider( $required_kses_globals );
29252925
}
29262926

29272927
/**
@@ -2946,7 +2946,7 @@ public function test_target_attribute_preserved_in_context( $context, $input, $e
29462946
*
29472947
* @return array
29482948
*/
2949-
public function data_target_attribute_preserved_in_descriptions() {
2949+
public static function data_target_attribute_preserved_in_descriptions() {
29502950
return array(
29512951
array(
29522952
'user_description',
@@ -2983,7 +2983,7 @@ public function test_specific_attributes_preserved_in_context( $context, $attrib
29832983
*
29842984
* @return array
29852985
*/
2986-
public function data_allowed_attributes_in_descriptions() {
2986+
public static function data_allowed_attributes_in_descriptions() {
29872987
return array(
29882988
array(
29892989
'user_description',

‎tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function test_doing_it_wrong_for_export_data_grouped_invalid_type( $group
226226
wp_privacy_generate_personal_data_export_file( self::$export_request_id );
227227
}
228228

229-
public function data_export_data_grouped_invalid_type() {
229+
public static function data_export_data_grouped_invalid_type() {
230230
return array(
231231
array( 10 ),
232232
array( 'WordPress' ),
@@ -448,7 +448,7 @@ private function replace_timestamp_placeholder( $actual_content, $expected_conte
448448
return str_replace( '{{TIMESTAMP}}', $timestamp, $expected_content );
449449
}
450450

451-
public function data_contents() {
451+
public static function data_contents() {
452452
return array(
453453
// Unhappy path.
454454
'should contain null when integer' => array(

0 commit comments

Comments
 (0)