Skip to content

Commit 36a7c6c

Browse files
Tests: Update _wp_timezone_choice_usort_callback() tests for consistency.
* Use the same `@group` annotation as the other tests. * Use `assertSame()` to verify the type of the result. * Use `data_` prefix for the data provider. * Use named data set in the data provider. This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test. * Other minor corrections. Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#repetitive-tests Core Handbook: Writing PHP Tests: Repetitive Tests]. Follow-up to [57145]. See #59953, #59647. git-svn-id: https://develop.svn.wordpress.org/trunk@57146 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4cee935 commit 36a7c6c

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

tests/phpunit/tests/functions/WpTimezoneChoiceUsortCallback.php renamed to tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/**
4-
* Tests for the _wp_timezone_choice_usort_callback function.
4+
* Tests for the _wp_timezone_choice_usort_callback() function.
55
*
6-
* @group Functions.php
6+
* @group function
77
*
88
* @covers ::_wp_timezone_choice_usort_callback
99
*/
@@ -12,19 +12,17 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase {
1212
/**
1313
* @ticket 59953
1414
*
15-
* @dataProvider wp_timezone_choice_usort_callback_data
15+
* @dataProvider data_wp_timezone_choice_usort_callback
1616
*/
17-
public function test__wp_timezone_choice_usort_callback( $unsorted, $sorted, $info ) {
18-
17+
public function test_wp_timezone_choice_usort_callback( $unsorted, $sorted ) {
1918
usort( $unsorted, '_wp_timezone_choice_usort_callback' );
2019

21-
$this->assertEquals( $sorted, $unsorted, $info );
20+
$this->assertSame( $sorted, $unsorted );
2221
}
2322

24-
25-
public function wp_timezone_choice_usort_callback_data() {
23+
public function data_wp_timezone_choice_usort_callback() {
2624
return array(
27-
array(
25+
'just GMT+' => array(
2826
'unsorted' => array(
2927
array(
3028
'continent' => 'Etc',
@@ -99,10 +97,9 @@ public function wp_timezone_choice_usort_callback_data() {
9997
't_subcity' => '',
10098
),
10199
),
102-
'info' => '_wp_timezone_choice_usort_callback: just GMT+',
103100
),
104101

105-
array(
102+
'mixed UTC and GMT' => array(
106103
'unsorted' => array(
107104
array(
108105
'continent' => 'Etc',
@@ -177,10 +174,9 @@ public function wp_timezone_choice_usort_callback_data() {
177174
't_subcity' => '',
178175
),
179176
),
180-
'info' => '_wp_timezone_choice_usort_callback: MIXED utc and GMT',
181177
),
182178

183-
array(
179+
'just alpha city' => array(
184180
'unsorted' => array(
185181
array(
186182
'continent' => 'Etc',
@@ -255,10 +251,9 @@ public function wp_timezone_choice_usort_callback_data() {
255251
't_subcity' => '',
256252
),
257253
),
258-
'info' => '_wp_timezone_choice_usort_callback: just alpha city',
259254
),
260255

261-
array(
256+
'not Etc continents are not sorted' => array(
262257
'unsorted' => array(
263258
array(
264259
'continent' => 'd',
@@ -333,9 +328,9 @@ public function wp_timezone_choice_usort_callback_data() {
333328
't_subcity' => '',
334329
),
335330
),
336-
'info' => '_wp_timezone_choice_usort_callback: not Etc continent are not sorted',
337331
),
338-
array(
332+
333+
'not Etc just t_continent' => array(
339334
'unsorted' => array(
340335
array(
341336
'continent' => '',
@@ -410,9 +405,9 @@ public function wp_timezone_choice_usort_callback_data() {
410405
't_subcity' => '',
411406
),
412407
),
413-
'info' => '_wp_timezone_choice_usort_callback: not Etc just t_city',
414408
),
415-
array(
409+
410+
'not Etc just t_city' => array(
416411
'unsorted' => array(
417412
array(
418413
'continent' => '',
@@ -487,9 +482,9 @@ public function wp_timezone_choice_usort_callback_data() {
487482
't_subcity' => '',
488483
),
489484
),
490-
'info' => '_wp_timezone_choice_usort_callback: not Etc just t_city',
491485
),
492-
array(
486+
487+
'not Etc just t_subcity' => array(
493488
'unsorted' => array(
494489
array(
495490
'continent' => '',
@@ -564,9 +559,9 @@ public function wp_timezone_choice_usort_callback_data() {
564559
't_subcity' => 'e',
565560
),
566561
),
567-
'info' => '_wp_timezone_choice_usort_callback: just sub city',
568562
),
569-
array(
563+
564+
'just continent with Etc which pulls 1 to bottom' => array(
570565
'unsorted' => array(
571566
array(
572567
'continent' => '',
@@ -641,7 +636,6 @@ public function wp_timezone_choice_usort_callback_data() {
641636
't_subcity' => '',
642637
),
643638
),
644-
'info' => '_wp_timezone_choice_usort_callback: just continent with etc which pulls 1 to bottom',
645639
),
646640
);
647641
}

0 commit comments

Comments
 (0)