Make WordPress Core

Changeset 54516


Ignore:
Timestamp:
10/14/2022 07:00:08 AM (2 years 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.6 branch.
See #56468.

Location:
branches/5.6
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r48952 r54516  
    8181     */
    8282    public function test_should_return_wp_timestamp() {
    83         update_option( 'timezone_string', 'Europe/Kiev' );
     83        update_option( 'timezone_string', 'Europe/Helsinki' );
    8484
    8585        $timestamp = time();
     
    106106     */
    107107    public function test_should_return_correct_local_time() {
    108         update_option( 'timezone_string', 'Europe/Kiev' );
     108        update_option( 'timezone_string', 'Europe/Helsinki' );
    109109
    110110        $timestamp      = time();
  • branches/5.6/tests/phpunit/tests/date/dateI18n.php

    r48952 r54516  
    1111     */
    1212    public function test_should_return_current_time_on_invalid_timestamp() {
    13         $timezone = 'Europe/Kiev';
     13        $timezone = 'Europe/Helsinki';
    1414        update_option( 'timezone_string', $timezone );
    1515
     
    2424     */
    2525    public function test_should_handle_zero_timestamp() {
    26         $timezone = 'Europe/Kiev';
     26        $timezone = 'Europe/Helsinki';
    2727        update_option( 'timezone_string', $timezone );
    2828
     
    143143     */
    144144    public function test_should_return_wp_timestamp() {
    145         update_option( 'timezone_string', 'Europe/Kiev' );
     145        update_option( 'timezone_string', 'Europe/Helsinki' );
    146146
    147147        $datetime     = new DateTimeImmutable( 'now', wp_timezone() );
     
    193193    public function dst_times() {
    194194        return array(
    195             'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Kiev' ),
    196             'After DST start'  => array( '2019-03-31 04:01:00', 'Europe/Kiev' ),
    197             'Before DST end'   => array( '2019-10-27 02:59:00', 'Europe/Kiev' ),
    198             'After DST end'    => array( '2019-10-27 04:01:00', 'Europe/Kiev' ),
     195            'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ),
     196            'After DST start'  => array( '2019-03-31 04:01:00', 'Europe/Helsinki' ),
     197            'Before DST end'   => array( '2019-10-27 02:59:00', 'Europe/Helsinki' ),
     198            'After DST end'    => array( '2019-10-27 04:01:00', 'Europe/Helsinki' ),
    199199        );
    200200    }
  • branches/5.6/tests/phpunit/tests/date/getFeedBuildDate.php

    r48952 r54516  
    4747        global $wp_query;
    4848
    49         update_option( 'timezone_string', 'Europe/Kiev' );
     49        update_option( 'timezone_string', 'Europe/Helsinki' );
    5050        $datetime     = new DateTimeImmutable( 'now', wp_timezone() );
    5151        $datetime_utc = $datetime->setTimezone( new DateTimeZone( 'UTC' ) );
  • branches/5.6/tests/phpunit/tests/date/getPostTime.php

    r48937 r54516  
    5050     */
    5151    public function test_should_return_wp_timestamp() {
    52         $timezone = 'Europe/Kiev';
     52        $timezone = 'Europe/Helsinki';
    5353        update_option( 'timezone_string', $timezone );
    5454
     
    7979     */
    8080    public function test_should_return_time() {
    81         $timezone = 'Europe/Kiev';
     81        $timezone = 'Europe/Helsinki';
    8282        update_option( 'timezone_string', $timezone );
    8383
     
    120120        );
    121121
    122         update_option( 'timezone_string', 'Europe/Kiev' );
     122        update_option( 'timezone_string', 'Europe/Helsinki' );
    123123
    124124        $this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
  • branches/5.6/tests/phpunit/tests/date/mysql2date.php

    r48937 r54516  
    3333     */
    3434    function test_mysql2date_should_format_time() {
    35         $timezone = 'Europe/Kiev';
     35        $timezone = 'Europe/Helsinki';
    3636        update_option( 'timezone_string', $timezone );
    3737        $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
     
    4747     */
    4848    function test_mysql2date_should_format_time_with_changed_time_zone() {
    49         $timezone = 'Europe/Kiev';
     49        $timezone = 'Europe/Helsinki';
    5050        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    5151        date_default_timezone_set( $timezone );
     
    6262     * @ticket 28992
    6363     */
    64     function test_mysql2date_should_return_wp_timestamp() {
    65         $timezone = 'Europe/Kiev';
     64    public function test_mysql2date_should_return_wp_timestamp() {
     65        $timezone = 'Europe/Helsinki';
    6666        update_option( 'timezone_string', $timezone );
    6767        $datetime     = new DateTime( 'now', new DateTimeZone( $timezone ) );
     
    7676     * @ticket 28992
    7777     */
    78     function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
    79         $timezone = 'Europe/Kiev';
     78    public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
     79        $timezone = 'Europe/Helsinki';
    8080        update_option( 'timezone_string', $timezone );
    8181        $datetime  = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
  • branches/5.6/tests/phpunit/tests/date/query.php

    r49606 r54516  
    556556     */
    557557    public function test_build_mysql_datetime_with_custom_timezone( $datetime, $expected, $default_to_max = false ) {
    558         update_option( 'timezone_string', 'Europe/Kiev' );
     558        update_option( 'timezone_string', 'Europe/Helsinki' );
    559559
    560560        $q = new WP_Date_Query( array() );
     
    578578     */
    579579    public function test_build_mysql_datetime_with_relative_date() {
    580         update_option( 'timezone_string', 'Europe/Kiev' );
     580        update_option( 'timezone_string', 'Europe/Helsinki' );
    581581
    582582        $q = new WP_Date_Query( array() );
  • branches/5.6/tests/phpunit/tests/date/wpTimezone.php

    r48937 r54516  
    3030     */
    3131    public function test_should_return_timezone_string() {
    32         update_option( 'timezone_string', 'Europe/Kiev' );
     32        update_option( 'timezone_string', 'Europe/Helsinki' );
    3333
    34         $this->assertSame( 'Europe/Kiev', wp_timezone_string() );
     34        $this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
    3535
    3636        $timezone = wp_timezone();
    3737
    38         $this->assertSame( 'Europe/Kiev', $timezone->getName() );
     38        $this->assertSame( 'Europe/Helsinki', $timezone->getName() );
    3939    }
    4040
  • branches/5.6/tests/phpunit/tests/date/xmlrpc.php

    r48937 r54516  
    1212     */
    1313    public function test_date_new_post() {
    14         $timezone = 'Europe/Kiev';
     14        $timezone = 'Europe/Helsinki';
    1515        update_option( 'timezone_string', $timezone );
    1616
     
    130130     */
    131131    public function test_date_edit_post() {
    132         $timezone = 'Europe/Kiev';
     132        $timezone = 'Europe/Helsinki';
    133133        update_option( 'timezone_string', $timezone );
    134134
     
    196196     * @ticket 30429
    197197     */
    198     function test_date_edit_comment() {
    199         $timezone = 'Europe/Kiev';
     198    public function test_date_edit_comment() {
     199        $timezone = 'Europe/Helsinki';
    200200        update_option( 'timezone_string', $timezone );
    201201
  • branches/5.6/tests/phpunit/tests/formatting/date.php

    r48952 r54516  
    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.