Make WordPress Core

Changeset 54513


Ignore:
Timestamp:
10/14/2022 06:49:30 AM (21 months ago)
Author:
peterwilsoncc
Message:

Tests: Replace the timezone used in date/time tests.

The Europe/Kiev timezone has been deprecated in PHP 8.2 and replaced with Europe/Kyiv.

The tests updated in this commit are testing the WordPress date/time functionality. They are not testing whether WP or PHP can handle deprecated timezone names correctly.

To ensure the tests follow the original purpose, the use of Europe/Kiev within these tests is now replaced with the Europe/Helsinki timezone, which is within the same timezone as Europe/Kyiv. This should ensure that these tests run without issue and test what they are supposed to be testing on every supported PHP version (unless at some point in the future Europe/Helsinki would be renamed, but that's a bridge to cross if and when).

Note: Separate tests should/will be added to ensure that relevant date/time related functions handle a deprecated timezone correctly, but that is not something these tests are supposed to be testing.

Follow-up to [45853], [45856], [45876], [45882], [45887], [45908], [45914], [46577], [46154], [46580], [46864], [46974], [54207].

Props jrf, costdev, SergeyBiryukov.
Merges [54217] to the 5.9 branch.
See #56468.

Location:
branches/5.9
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/tests/phpunit/tests/date/currentTime.php

    r51331 r54513  
    8282     */
    8383    public function test_should_return_wp_timestamp() {
    84         update_option( 'timezone_string', 'Europe/Kiev' );
     84        update_option( 'timezone_string', 'Europe/Helsinki' );
    8585
    8686        $timestamp = time();
     
    107107     */
    108108    public function test_should_return_correct_local_time() {
    109         update_option( 'timezone_string', 'Europe/Kiev' );
     109        update_option( 'timezone_string', 'Europe/Helsinki' );
    110110
    111111        $timestamp      = time();
  • branches/5.9/tests/phpunit/tests/date/dateI18n.php

    r50291 r54513  
    1212     */
    1313    public function test_should_return_current_time_on_invalid_timestamp() {
    14         $timezone = 'Europe/Kiev';
     14        $timezone = 'Europe/Helsinki';
    1515        update_option( 'timezone_string', $timezone );
    1616
     
    2525     */
    2626    public function test_should_handle_zero_timestamp() {
    27         $timezone = 'Europe/Kiev';
     27        $timezone = 'Europe/Helsinki';
    2828        update_option( 'timezone_string', $timezone );
    2929
     
    144144     */
    145145    public function test_should_return_wp_timestamp() {
    146         update_option( 'timezone_string', 'Europe/Kiev' );
     146        update_option( 'timezone_string', 'Europe/Helsinki' );
    147147
    148148        $datetime     = new DateTimeImmutable( 'now', wp_timezone() );
     
    194194    public function dst_times() {
    195195        return array(
    196             'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Kiev' ),
    197             'After DST start'  => array( '2019-03-31 04:01:00', 'Europe/Kiev' ),
    198             'Before DST end'   => array( '2019-10-27 02:59:00', 'Europe/Kiev' ),
    199             'After DST end'    => array( '2019-10-27 04:01:00', 'Europe/Kiev' ),
     196            'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ),
     197            'After DST start'  => array( '2019-03-31 04:01:00', 'Europe/Helsinki' ),
     198            'Before DST end'   => array( '2019-10-27 02:59:00', 'Europe/Helsinki' ),
     199            'After DST end'    => array( '2019-10-27 04:01:00', 'Europe/Helsinki' ),
    200200        );
    201201    }
  • branches/5.9/tests/phpunit/tests/date/getFeedBuildDate.php

    r52010 r54513  
    4848        global $wp_query;
    4949
    50         update_option( 'timezone_string', 'Europe/Kiev' );
     50        update_option( 'timezone_string', 'Europe/Helsinki' );
    5151        $datetime     = new DateTimeImmutable( 'now', wp_timezone() );
    5252        $datetime_utc = $datetime->setTimezone( new DateTimeZone( 'UTC' ) );
  • branches/5.9/tests/phpunit/tests/date/getPostTime.php

    r50291 r54513  
    5252     */
    5353    public function test_should_return_wp_timestamp() {
    54         $timezone = 'Europe/Kiev';
     54        $timezone = 'Europe/Helsinki';
    5555        update_option( 'timezone_string', $timezone );
    5656
     
    8181     */
    8282    public function test_should_return_time() {
    83         $timezone = 'Europe/Kiev';
     83        $timezone = 'Europe/Helsinki';
    8484        update_option( 'timezone_string', $timezone );
    8585
     
    122122        );
    123123
    124         update_option( 'timezone_string', 'Europe/Kiev' );
     124        update_option( 'timezone_string', 'Europe/Helsinki' );
    125125
    126126        $this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
  • branches/5.9/tests/phpunit/tests/date/mysql2date.php

    r52010 r54513  
    3434     */
    3535    public function test_mysql2date_should_format_time() {
    36         $timezone = 'Europe/Kiev';
     36        $timezone = 'Europe/Helsinki';
    3737        update_option( 'timezone_string', $timezone );
    3838        $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
     
    4848     */
    4949    public function test_mysql2date_should_format_time_with_changed_time_zone() {
    50         $timezone = 'Europe/Kiev';
     50        $timezone = 'Europe/Helsinki';
    5151        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    5252        date_default_timezone_set( $timezone );
     
    6464     */
    6565    public function test_mysql2date_should_return_wp_timestamp() {
    66         $timezone = 'Europe/Kiev';
     66        $timezone = 'Europe/Helsinki';
    6767        update_option( 'timezone_string', $timezone );
    6868        $datetime     = new DateTime( 'now', new DateTimeZone( $timezone ) );
     
    7878     */
    7979    public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
    80         $timezone = 'Europe/Kiev';
     80        $timezone = 'Europe/Helsinki';
    8181        update_option( 'timezone_string', $timezone );
    8282        $datetime  = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
  • branches/5.9/tests/phpunit/tests/date/query.php

    r51568 r54513  
    562562     */
    563563    public function test_build_mysql_datetime_with_custom_timezone( $datetime, $expected, $default_to_max = false ) {
    564         update_option( 'timezone_string', 'Europe/Kiev' );
     564        update_option( 'timezone_string', 'Europe/Helsinki' );
    565565
    566566        $q = new WP_Date_Query( array() );
     
    584584     */
    585585    public function test_build_mysql_datetime_with_relative_date() {
    586         update_option( 'timezone_string', 'Europe/Kiev' );
     586        update_option( 'timezone_string', 'Europe/Helsinki' );
    587587
    588588        $q = new WP_Date_Query( array() );
  • branches/5.9/tests/phpunit/tests/date/wpTimezone.php

    r50291 r54513  
    3232     */
    3333    public function test_should_return_timezone_string() {
    34         update_option( 'timezone_string', 'Europe/Kiev' );
     34        update_option( 'timezone_string', 'Europe/Helsinki' );
    3535
    36         $this->assertSame( 'Europe/Kiev', wp_timezone_string() );
     36        $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
    3737
    3838        $timezone = wp_timezone();
    3939
    40         $this->assertSame( 'Europe/Kiev', $timezone->getName() );
     40        $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
    4141    }
    4242
  • branches/5.9/tests/phpunit/tests/date/xmlrpc.php

    r52389 r54513  
    2525        }
    2626
    27         $timezone = 'Europe/Kiev';
     27        $timezone = 'Europe/Helsinki';
    2828        update_option( 'timezone_string', $timezone );
    2929
     
    145145     */
    146146    public function test_date_edit_post() {
    147         $timezone = 'Europe/Kiev';
     147        $timezone = 'Europe/Helsinki';
    148148        update_option( 'timezone_string', $timezone );
    149149
     
    214214     */
    215215    public function test_date_edit_comment() {
    216         $timezone = 'Europe/Kiev';
     216        $timezone = 'Europe/Helsinki';
    217217        update_option( 'timezone_string', $timezone );
    218218
  • branches/5.9/tests/phpunit/tests/formatting/date.php

    r52010 r54513  
    198198        return array(
    199199            array(
    200                 'timezone_string' => 'Europe/Kiev',
     200                'timezone_string' => 'Europe/Helsinki',
    201201                'gmt_offset'      => 3,
    202202            ),
Note: See TracChangeset for help on using the changeset viewer.