Make WordPress Core


Ignore:
Timestamp:
09/19/2022 11:51:20 PM (21 months 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/dateI18n.php

    r54217 r54230  
    107107
    108108        $this->assertSame( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) );
     109    }
     110
     111    /**
     112     * Ensures that deprecated timezone strings are handled correctly.
     113     *
     114     * @ticket 56468
     115     */
     116    public function test_adjusts_format_based_on_deprecated_timezone_string() {
     117        update_option( 'timezone_string', 'America/Buenos_Aires' ); // This timezone was deprecated pre-PHP 5.6.
     118
     119        $expected = '2022-08-01 00:00:00 -03 -03:00 America/Buenos_Aires';
     120        if ( PHP_VERSION_ID < 70000 ) {
     121            // PHP 5.6.
     122            $expected = '2022-08-01 00:00:00 ART -03:00 America/Buenos_Aires';
     123        }
     124
     125        $this->assertSame( $expected, date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2022-08-01 00:00:00' ) ) );
    109126    }
    110127
Note: See TracChangeset for help on using the changeset viewer.