Skip to content

Commit b9e3b55

Browse files
committed
Tests: Make entity, menu, media and feed data providers static.
Declare 18 data providers in the entity fields, menu, media, feed, oEmbed, and theme tests as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Developed in: #15155, #15157, #15159, #15167, #15168, #15170 Props devmuhib, rejaulalomkhan, shailu25, huzaifaalmesbah. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@65007 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f2d0059 commit b9e3b55

13 files changed

Lines changed: 18 additions & 18 deletions

‎tests/phpunit/tests/entity-fields/wpPreloadEntityFields.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function test_the_site_editor_preloads_the_fields_of_its_screen( $path, $
9696
*
9797
* @return array[]
9898
*/
99-
public function data_site_editor_screens() {
99+
public static function data_site_editor_screens() {
100100
return array(
101101
'pages' => array( '/page', array( 'page' ) ),
102102
'page' => array( '/page/12', array( 'page' ) ),
@@ -198,7 +198,7 @@ public function test_non_array_paths( $paths, $expected ) {
198198
*
199199
* @return array[]
200200
*/
201-
public function data_non_array_paths() {
201+
public static function data_non_array_paths() {
202202
$object = new stdClass();
203203

204204
return array(

‎tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function test_the_notes_field_follows_the_editor_support_argument() {
243243
* @return array[] The id of each field and whether the design post types
244244
* exclude it.
245245
*/
246-
public function data_default_fields_of_every_post_type() {
246+
public static function data_default_fields_of_every_post_type() {
247247
return array(
248248
'date' => array( 'date', true ),
249249
'last_edited_date' => array( 'last_edited_date', false ),
@@ -285,7 +285,7 @@ public function test_a_default_field_of_every_post_type( $field_id, $excluded_fo
285285
*
286286
* @return array[] The id of each field and the supports that give it.
287287
*/
288-
public function data_default_fields_and_their_supports() {
288+
public static function data_default_fields_and_their_supports() {
289289
return array(
290290
'discussion' => array( 'discussion', array( 'comments', 'trackbacks' ) ),
291291
'excerpt' => array( 'excerpt', array( 'excerpt' ) ),

‎tests/phpunit/tests/feed/rss2.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public function test_get_feed_build_date( $url, $element ) {
539539
}
540540

541541

542-
public function data_get_feed_build_date() {
542+
public static function data_get_feed_build_date() {
543543
return array(
544544
array( '/?feed=rss2', 'rss' ),
545545
array( '/?feed=commentsrss2', 'rss' ),

‎tests/phpunit/tests/feed/rssEnclosure.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function test_rss_enclosure_with_multiline_enclosure_string( $enclosure_d
6868
*
6969
* @return array[]
7070
*/
71-
public function data_rss_enclosure_with_multiline_enclosure_string() {
71+
public static function data_rss_enclosure_with_multiline_enclosure_string() {
7272
return array(
7373
'two-break-lines' => array(
7474
array(
@@ -124,7 +124,7 @@ public function test_rss_enclosure_with_non_valid_enclosure_string( $enclosure_s
124124
*
125125
* @return array[]
126126
*/
127-
public function data_rss_enclosure_with_non_valid_enclosure_string() {
127+
public static function data_rss_enclosure_with_non_valid_enclosure_string() {
128128
return array(
129129
'empty' => array( '' ),
130130
'no-break-lines' => array( 'http://example.com/sound2.mp3 12345 audio/mpeg' ),

‎tests/phpunit/tests/feed/wpSimplePieFile.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function test_header_parsing( $callback, $header_field, $expected ) {
4141
*
4242
* @return array
4343
*/
44-
public function data_header_parsing() {
44+
public static function data_header_parsing() {
4545
return array(
4646
'single content type header works' => array(
4747
'mocked_response_single_header_values',

‎tests/phpunit/tests/media/wpCrossOriginIsolation.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function test_deprecated_attribute_injector_returns_html_unchanged( strin
367367
*
368368
* @return array<non-falsy-string, array{ non-falsy-string }>
369369
*/
370-
public function data_cross_origin_elements(): array {
370+
public static function data_cross_origin_elements(): array {
371371
return array(
372372
'cross-origin script' => array(
373373
'<script src="https://external.example.com/script.js"></script>',

‎tests/phpunit/tests/media/wpIsDocumentIsolationPolicySupported.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function test_user_agent_support( ?string $user_agent, bool $expected ) {
4848
/**
4949
* @return array[]
5050
*/
51-
public function data_user_agents() {
51+
public static function data_user_agents() {
5252
return array(
5353
'no user agent' => array( null, false ),
5454
'Firefox' => array( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0', false ),

‎tests/phpunit/tests/menu/walker-nav-menu.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static function ( $atts ) use ( $value ) {
106106
$this->assertSame( "<li id=\"menu-item-{$post_id}\" class=\"menu-item-{$post_id}\"><a{$expected}>{$post_title}</a>", $output );
107107
}
108108

109-
public function data_start_el_with_empty_attributes() {
109+
public static function data_start_el_with_empty_attributes() {
110110
return array(
111111
array(
112112
'',
@@ -187,7 +187,7 @@ public function test_walker_nav_menu_start_el_should_add_rel_privacy_policy_to_p
187187
*
188188
* @return array[]
189189
*/
190-
public function data_walker_nav_menu_start_el_should_add_rel_privacy_policy_to_privacy_policy_url() {
190+
public static function data_walker_nav_menu_start_el_should_add_rel_privacy_policy_to_privacy_policy_url() {
191191
return array(
192192
'no xfn value' => array(
193193
'expected' => 'rel="privacy-policy"',
@@ -411,7 +411,7 @@ public function test_build_atts_should_build_attributes( $atts, $expected ) {
411411
*
412412
* @return array[]
413413
*/
414-
public function data_build_atts_should_build_attributes() {
414+
public static function data_build_atts_should_build_attributes() {
415415
return array(
416416
'an empty attributes array' => array(
417417
'atts' => array(),

‎tests/phpunit/tests/menu/wpNavMenuRemoveMenuItemHasChildrenClass.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function test_menu_item_has_children_class_should_be_removed_or_retained_
5858
*
5959
* @return array
6060
*/
61-
public function data_menu_item_has_children_class_should_be_removed_or_retained_as_expected() {
61+
public static function data_menu_item_has_children_class_should_be_removed_or_retained_as_expected() {
6262
return array(
6363
'Depth not set' => array(
6464
'args' => (object) array( 'depth' => 1 ),

‎tests/phpunit/tests/oembed/wpFilterOembedIframeTitleAttributes.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function test_oembed_iframe_title_attribute( $html, $oembed_data, $url, $
1616
$this->assertEqualHTML( $expected, $actual );
1717
}
1818

19-
public function data_oembed_iframe_title_attribute() {
19+
public static function data_oembed_iframe_title_attribute() {
2020
return array(
2121
array(
2222
'<p>Foo</p><iframe src=""></iframe><b>Bar</b>',

0 commit comments

Comments
 (0)