Make WordPress Core


Ignore:
Timestamp:
09/19/2022 11:51:20 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add tests with deprecated timezone strings.

This commit adds tests in select places to ensure that these date/time related functions continue to behave as expected when the timezone_string option is set to an outdated/deprecated timezone name.

The timezone string used in these tests, America/Buenos_Aires, is a timezone string which was already deprecated in PHP 5.6.20 (the current minimum PHP version), so using this timezone string, we can safely test the handling of deprecated timezone names on all supported PHP versions.

See: timezone_identifiers_list() output for PHP 5.6.20.

Follow-up to [54207], [54217], [54227], [54229].

Props jrf, costdev.
See #56468.

File:
1 edited

Legend:

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

    r54217 r54230  
    5050
    5151        $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() );
    5268    }
    5369
Note: See TracChangeset for help on using the changeset viewer.