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/mysql2date.php

    r54217 r54230  
    6464
    6565    /**
     66     * Ensures that deprecated timezone strings are handled correctly.
     67     *
     68     * @ticket 56468
     69     */
     70    public function test_mysql2date_should_format_time_with_deprecated_time_zone() {
     71        $timezone = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6.
     72        update_option( 'timezone_string', $timezone );
     73        $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
     74        $rfc3339  = $datetime->format( DATE_RFC3339 );
     75        $mysql    = $datetime->format( 'Y-m-d H:i:s' );
     76
     77        $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) );
     78        $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) );
     79    }
     80
     81    /**
    6682     * @ticket 28992
    6783     */
Note: See TracChangeset for help on using the changeset viewer.