Make WordPress Core

Changeset 57146


Ignore:
Timestamp:
11/30/2023 11:15:34 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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: Core Handbook: Writing PHP Tests: Repetitive Tests.

Follow-up to [57145].

See #59953, #59647.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/wpTimezoneChoiceUsortCallback.php

    r57145 r57146  
    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
     
    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(
     
    10098                                        ),
    10199                                ),
    102                                 'info'     => '_wp_timezone_choice_usort_callback: just GMT+',
    103                         ),
    104 
    105                         array(
     100                        ),
     101
     102                        'mixed UTC and GMT'                 => array(
    106103                                'unsorted' => array(
    107104                                        array(
     
    178175                                        ),
    179176                                ),
    180                                 'info'     => '_wp_timezone_choice_usort_callback: MIXED utc and GMT',
    181                         ),
    182 
    183                         array(
     177                        ),
     178
     179                        'just alpha city'                   => array(
    184180                                'unsorted' => array(
    185181                                        array(
     
    256252                                        ),
    257253                                ),
    258                                 'info'     => '_wp_timezone_choice_usort_callback: just alpha city',
    259                         ),
    260 
    261                         array(
     254                        ),
     255
     256                        'not Etc continents are not sorted' => array(
    262257                                'unsorted' => array(
    263258                                        array(
     
    334329                                        ),
    335330                                ),
    336                                 'info'     => '_wp_timezone_choice_usort_callback: not Etc continent are not sorted',
    337                         ),
    338                         array(
     331                        ),
     332
     333                        'not Etc just t_continent'          => array(
    339334                                'unsorted' => array(
    340335                                        array(
     
    411406                                        ),
    412407                                ),
    413                                 'info'     => '_wp_timezone_choice_usort_callback: not Etc just t_city',
    414                         ),
    415                         array(
     408                        ),
     409
     410                        'not Etc just t_city'               => array(
    416411                                'unsorted' => array(
    417412                                        array(
     
    488483                                        ),
    489484                                ),
    490                                 'info'     => '_wp_timezone_choice_usort_callback: not Etc just t_city',
    491                         ),
    492                         array(
     485                        ),
     486
     487                        'not Etc just t_subcity'            => array(
    493488                                'unsorted' => array(
    494489                                        array(
     
    565560                                        ),
    566561                                ),
    567                                 'info'     => '_wp_timezone_choice_usort_callback: just sub city',
    568                         ),
    569                         array(
     562                        ),
     563
     564                        'just continent with Etc which pulls 1 to bottom' => array(
    570565                                'unsorted' => array(
    571566                                        array(
     
    642637                                        ),
    643638                                ),
    644                                 'info'     => '_wp_timezone_choice_usort_callback: just continent with etc which pulls 1 to bottom',
    645639                        ),
    646640                );
Note: See TracChangeset for help on using the changeset viewer.