Skip to content

Commit 6969ec3

Browse files
committed
Tests: Make term test data providers static.
Declare the data providers in `tests/phpunit/tests/term/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Call the existing static `text_array_to_dataprovider()` helper with `self::`. Developed in: #14395 Props rejaulalomkhan. See #66211. git-svn-id: https://develop.svn.wordpress.org/trunk@64445 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b65c057 commit 6969ec3

10 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎tests/phpunit/tests/term/getTermLink.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function ( $location, $term ) {
274274
*
275275
* @return array
276276
*/
277-
public function data_term_link_filter_should_receive_term_object() {
277+
public static function data_term_link_filter_should_receive_term_object() {
278278
return array(
279279
'category passing term_id' => array(
280280
'taxonomy' => 'category',
@@ -325,9 +325,9 @@ public function test_get_term_feed_link_should_use_term_taxonomy_when_term_id_is
325325
*
326326
* @return array
327327
*/
328-
public function data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed() {
328+
public static function data_get_term_feed_link_should_use_term_taxonomy_when_term_id_is_passed() {
329329
$taxonomies = array( 'category', 'post_tag', 'wptests_tax' );
330330

331-
return $this->text_array_to_dataprovider( $taxonomies );
331+
return self::text_array_to_dataprovider( $taxonomies );
332332
}
333333
}

‎tests/phpunit/tests/term/getTerms.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3175,7 +3175,7 @@ public function test_cache_key_generation( $args_1, $args_2 ) {
31753175
*
31763176
* @return array
31773177
*/
3178-
public function data_same_term_args() {
3178+
public static function data_same_term_args() {
31793179
return array(
31803180
'all fields vs ids' => array(
31813181
array(

‎tests/phpunit/tests/term/isTermPubliclyViewable.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function test_is_term_publicly_viewable( $taxonomy, $expected ) {
4242
* @type bool $expected The expected result of the function call.
4343
* }
4444
*/
45-
public function data_is_term_publicly_viewable() {
45+
public static function data_is_term_publicly_viewable() {
4646
return array(
4747
array( 'category', true ),
4848
array( 'post_tag', true ),

‎tests/phpunit/tests/term/meta.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public function test_register_term_meta( $taxonomy, $meta_key, $args ) {
491491
$this->assertSame( $args, $this->last_register_meta_call['args'] );
492492
}
493493

494-
public function data_register_term_meta() {
494+
public static function data_register_term_meta() {
495495
return array(
496496
array( 'wptests_tax', 'registered_key1', array( 'single' => true ) ),
497497
array( 'category', 'registered_key2', array() ),
@@ -525,7 +525,7 @@ public function test_unregister_term_meta( $taxonomy, $meta_key ) {
525525
$this->assertEmpty( $actual );
526526
}
527527

528-
public function data_unregister_term_meta() {
528+
public static function data_unregister_term_meta() {
529529
return array(
530530
array( 'wptests_tax', 'registered_key1' ),
531531
array( 'category', 'registered_key2' ),

‎tests/phpunit/tests/term/query.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ public function test_generate_cache_key_placeholder( $args ) {
11061106
*
11071107
* @return array[] Test parameters.
11081108
*/
1109-
public function data_query_cache() {
1109+
public static function data_query_cache() {
11101110
return array(
11111111
'empty query' => array(
11121112
'args' => array(),

‎tests/phpunit/tests/term/sanitizeTerm.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function test_sanitize_term( Closure $input_callback, string $context, st
4747
* expected_description: string,
4848
* }>
4949
*/
50-
public function data_sanitize_term(): array {
50+
public static function data_sanitize_term(): array {
5151
$description = 'Test <script>console.log("Hello")</script> Description';
5252

5353
return array(

‎tests/phpunit/tests/term/termCounts.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function test_term_count_changes_for_post_statuses( $post_status, $change
104104
* @type int $change Expected change.
105105
* }
106106
*/
107-
public function data_term_count_changes_for_post_statuses() {
107+
public static function data_term_count_changes_for_post_statuses() {
108108
return array(
109109
// 0. Published post
110110
array( 'publish', 1 ),
@@ -146,7 +146,7 @@ public function test_term_counts_incremented_on_publish( $original_post_status,
146146
* @type int $change Expected change upon publish.
147147
* }
148148
*/
149-
public function data_term_counts_incremented_on_publish() {
149+
public static function data_term_counts_incremented_on_publish() {
150150
return array(
151151
// 0. Published post
152152
array( 'publish', 0 ),
@@ -193,7 +193,7 @@ public function test_term_count_transitions_update_term_counts( $original_post_s
193193
* @type int $change Expected change upon publish.
194194
* }
195195
*/
196-
public function data_term_count_transitions_update_term_counts() {
196+
public static function data_term_count_transitions_update_term_counts() {
197197
return array(
198198
// 0. Draft -> published post
199199
array( 'draft', 'publish', 1 ),
@@ -269,7 +269,7 @@ public function test_term_count_changes_for_update_post_term_count_statuses_filt
269269
* @type int $change Expected change.
270270
* }
271271
*/
272-
public function data_term_count_changes_for_update_post_term_count_statuses_filter() {
272+
public static function data_term_count_changes_for_update_post_term_count_statuses_filter() {
273273
return array(
274274
// 0. Published post
275275
array( 'publish', 2 ),
@@ -319,7 +319,7 @@ public function test_term_count_changes_for_post_statuses_with_attachments( $pos
319319
* @type int $change Expected change.
320320
* }
321321
*/
322-
public function data_term_count_changes_for_post_statuses_with_attachments() {
322+
public static function data_term_count_changes_for_post_statuses_with_attachments() {
323323
return array(
324324
// 0. Published post
325325
array( 'publish', 2 ),
@@ -370,7 +370,7 @@ public function test_term_counts_incremented_on_publish_with_attachments( $origi
370370
* @type int $change Expected change upon publish.
371371
* }
372372
*/
373-
public function data_term_counts_incremented_on_publish_with_attachments() {
373+
public static function data_term_counts_incremented_on_publish_with_attachments() {
374374
return array(
375375
// 0. Published post
376376
array( 'publish', 0 ),
@@ -426,7 +426,7 @@ public function test_term_count_transitions_update_term_counts_with_attachments(
426426
* @type int $change Expected change upon publish.
427427
* }
428428
*/
429-
public function data_term_count_transitions_update_term_counts_with_attachments() {
429+
public static function data_term_count_transitions_update_term_counts_with_attachments() {
430430
return array(
431431
// 0. Draft -> published post
432432
array( 'draft', 'publish', 2 ),
@@ -494,7 +494,7 @@ public function test_term_counts_incremented_on_publish_with_untermed_attachment
494494
* @type int $change Expected change upon publish.
495495
* }
496496
*/
497-
public function data_term_counts_incremented_on_publish_with_untermed_attachments() {
497+
public static function data_term_counts_incremented_on_publish_with_untermed_attachments() {
498498
return array(
499499
// 0. Published post
500500
array( 'publish', 0 ),
@@ -549,7 +549,7 @@ public function test_term_count_transitions_update_term_counts_with_untermed_att
549549
* @type int $change Expected change upon publish.
550550
* }
551551
*/
552-
public function data_term_count_transitions_update_term_counts_with_untermed_attachments() {
552+
public static function data_term_count_transitions_update_term_counts_with_untermed_attachments() {
553553
return array(
554554
// 0. Draft -> published post
555555
array( 'draft', 'publish', 1 ),

‎tests/phpunit/tests/term/wpGenerateTagCloud.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function test_empty_tags_list_returned( $expected, $args ) {
4141
*
4242
* @return array
4343
*/
44-
public function data_empty_tags() {
44+
public static function data_empty_tags() {
4545
return array(
4646
// When 'format' => 'array', we should be getting an empty array back.
4747
array(

‎tests/phpunit/tests/term/wpSetObjectTerms.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function test_empty_value_should_clear_terms( $empty_value ) {
466466
*
467467
* @return array[]
468468
*/
469-
public function data_empty_value_should_clear_terms() {
469+
public static function data_empty_value_should_clear_terms() {
470470
return array(
471471
'(bool) false' => array( false ),
472472
'null' => array( null ),

‎tests/phpunit/tests/term/wpTerm.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function test_get_instance_replaces_a_poisoned_cache_value( $cache_value
164164
*
165165
* @return array<non-falsy-string, array{ mixed }>
166166
*/
167-
public function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array {
167+
public static function data_get_instance_treats_a_poisoned_cache_value_as_a_cache_miss(): array {
168168
return array(
169169
'true' => array( true ),
170170
'a non-numeric string' => array( 'not-a-term' ),

0 commit comments

Comments
 (0)