From 36a7c6ca409455ac8663d1a98b672685b654b2b2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 30 Nov 2023 11:15:34 +0000 Subject: [PATCH] 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 --- ....php => wpTimezoneChoiceUsortCallback.php} | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) rename tests/phpunit/tests/functions/{WpTimezoneChoiceUsortCallback.php => wpTimezoneChoiceUsortCallback.php} (92%) diff --git a/tests/phpunit/tests/functions/WpTimezoneChoiceUsortCallback.php b/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php similarity index 92% rename from tests/phpunit/tests/functions/WpTimezoneChoiceUsortCallback.php rename to tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php index 4732d670aa..58f805833e 100644 --- a/tests/phpunit/tests/functions/WpTimezoneChoiceUsortCallback.php +++ b/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php @@ -1,9 +1,9 @@ assertEquals( $sorted, $unsorted, $info ); + $this->assertSame( $sorted, $unsorted ); } - - public function wp_timezone_choice_usort_callback_data() { + public function data_wp_timezone_choice_usort_callback() { return array( - array( + 'just GMT+' => array( 'unsorted' => array( array( 'continent' => 'Etc', @@ -99,10 +97,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: just GMT+', ), - array( + 'mixed UTC and GMT' => array( 'unsorted' => array( array( 'continent' => 'Etc', @@ -177,10 +174,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: MIXED utc and GMT', ), - array( + 'just alpha city' => array( 'unsorted' => array( array( 'continent' => 'Etc', @@ -255,10 +251,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: just alpha city', ), - array( + 'not Etc continents are not sorted' => array( 'unsorted' => array( array( 'continent' => 'd', @@ -333,9 +328,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: not Etc continent are not sorted', ), - array( + + 'not Etc just t_continent' => array( 'unsorted' => array( array( 'continent' => '', @@ -410,9 +405,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: not Etc just t_city', ), - array( + + 'not Etc just t_city' => array( 'unsorted' => array( array( 'continent' => '', @@ -487,9 +482,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: not Etc just t_city', ), - array( + + 'not Etc just t_subcity' => array( 'unsorted' => array( array( 'continent' => '', @@ -564,9 +559,9 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => 'e', ), ), - 'info' => '_wp_timezone_choice_usort_callback: just sub city', ), - array( + + 'just continent with Etc which pulls 1 to bottom' => array( 'unsorted' => array( array( 'continent' => '', @@ -641,7 +636,6 @@ class Tests_Functions_WpTimezoneChoiceUsortCallback extends WP_UnitTestCase { 't_subcity' => '', ), ), - 'info' => '_wp_timezone_choice_usort_callback: just continent with etc which pulls 1 to bottom', ), ); }