Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (15 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/date/wpTimezone.php

    r54230 r55562  
    2323     * @ticket 24730
    2424     *
    25      * @dataProvider timezone_offset_provider
     25     * @dataProvider data_should_convert_gmt_offset
    2626     *
    2727     * @param float  $gmt_offset Numeric offset from UTC.
     
    4040
    4141    /**
    42      * @ticket 24730
    43      */
    44     public function test_should_return_timezone_string() {
    45         update_option( 'timezone_string', 'Europe/Helsinki' );
    46 
    47         $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
    48 
    49         $timezone = wp_timezone();
    50 
    51         $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
    52     }
    53 
    54     /**
    55      * Ensures that deprecated timezone strings are handled correctly.
    56      *
    57      * @ticket 56468
    58      */
    59     public function test_should_return_deprecated_timezone_string() {
    60         $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.
    61         update_option( 'timezone_string', $tz_string );
    62 
    63         $this->assertSame( $tz_string, wp_timezone_string() );
    64 
    65         $timezone = wp_timezone();
    66 
    67         $this->assertSame( $tz_string, $timezone->getName() );
    68     }
    69 
    70     /**
    7142     * Data provider to test numeric offset conversion.
    7243     *
    7344     * @return array
    7445     */
    75     public function timezone_offset_provider() {
     46    public function data_should_convert_gmt_offset() {
    7647        return array(
    7748            array( -12, '-12:00' ),
     
    135106        );
    136107    }
     108
     109    /**
     110     * @ticket 24730
     111     */
     112    public function test_should_return_timezone_string() {
     113        update_option( 'timezone_string', 'Europe/Helsinki' );
     114
     115        $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
     116
     117        $timezone = wp_timezone();
     118
     119        $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
     120    }
     121
     122    /**
     123     * Ensures that deprecated timezone strings are handled correctly.
     124     *
     125     * @ticket 56468
     126     */
     127    public function test_should_return_deprecated_timezone_string() {
     128        $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.
     129        update_option( 'timezone_string', $tz_string );
     130
     131        $this->assertSame( $tz_string, wp_timezone_string() );
     132
     133        $timezone = wp_timezone();
     134
     135        $this->assertSame( $tz_string, $timezone->getName() );
     136    }
    137137}
Note: See TracChangeset for help on using the changeset viewer.