Skip to content

Commit b5e8553

Browse files
committed
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.7 branch. See #56468. git-svn-id: https://develop.svn.wordpress.org/branches/5.7@54515 602fd350-edb4-49c9-b593-d223f7449a82
1 parent df0b99c commit b5e8553

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

tests/phpunit/tests/date/currentTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function test_should_work_with_changed_timezone() {
8181
* @ticket 40653
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();
8787
$datetime = new DateTime( '@' . $timestamp );
@@ -106,7 +106,7 @@ public function test_should_return_wp_timestamp() {
106106
* @ticket 40653
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();
112112
$datetime_local = new DateTime( '@' . $timestamp );

tests/phpunit/tests/date/dateI18n.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Tests_Date_DateI18n extends WP_UnitTestCase {
1111
* @ticket 28636
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

1717
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
@@ -24,7 +24,7 @@ public function test_should_return_current_time_on_invalid_timestamp() {
2424
* @ticket 28636
2525
*/
2626
public function test_should_handle_zero_timestamp() {
27-
$timezone = 'Europe/Kiev';
27+
$timezone = 'Europe/Helsinki';
2828
update_option( 'timezone_string', $timezone );
2929

3030
$datetime = DateTimeImmutable::createFromFormat(
@@ -143,7 +143,7 @@ public function data_formats() {
143143
* @ticket 25768
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() );
149149
$timestamp = $datetime->getTimestamp();
@@ -193,10 +193,10 @@ public function test_should_handle_dst( $time, $timezone ) {
193193

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
}
202202
}

tests/phpunit/tests/date/getFeedBuildDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function test_should_return_correct_feed_build_date() {
4747
public function test_should_fall_back_to_last_post_modified() {
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' ) );
5353

tests/phpunit/tests/date/getPostTime.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function test_get_post_modified_time_returns_false_with_null_or_non_exist
5151
* @ticket 25002
5252
*/
5353
public function test_should_return_wp_timestamp() {
54-
$timezone = 'Europe/Kiev';
54+
$timezone = 'Europe/Helsinki';
5555
update_option( 'timezone_string', $timezone );
5656

5757
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -80,7 +80,7 @@ public function test_should_return_wp_timestamp() {
8080
* @ticket 25002
8181
*/
8282
public function test_should_return_time() {
83-
$timezone = 'Europe/Kiev';
83+
$timezone = 'Europe/Helsinki';
8484
update_option( 'timezone_string', $timezone );
8585

8686
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -121,7 +121,7 @@ public function test_should_keep_utc_time_on_timezone_change() {
121121
)
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 ) );
127127
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) );

tests/phpunit/tests/date/mysql2date.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function test_mysql2date_returns_gmt_or_unix_timestamp() {
3333
* @ticket 28992
3434
*/
3535
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 ) );
3939
$rfc3339 = $datetime->format( DATE_RFC3339 );
@@ -47,7 +47,7 @@ function test_mysql2date_should_format_time() {
4747
* @ticket 28992
4848
*/
4949
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 );
5353
update_option( 'timezone_string', $timezone );
@@ -62,8 +62,8 @@ function test_mysql2date_should_format_time_with_changed_time_zone() {
6262
/**
6363
* @ticket 28992
6464
*/
65-
function test_mysql2date_should_return_wp_timestamp() {
66-
$timezone = 'Europe/Kiev';
65+
public function test_mysql2date_should_return_wp_timestamp() {
66+
$timezone = 'Europe/Helsinki';
6767
update_option( 'timezone_string', $timezone );
6868
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
6969
$wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset();
@@ -76,8 +76,8 @@ function test_mysql2date_should_return_wp_timestamp() {
7676
/**
7777
* @ticket 28992
7878
*/
79-
function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
80-
$timezone = 'Europe/Kiev';
79+
public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
80+
$timezone = 'Europe/Helsinki';
8181
update_option( 'timezone_string', $timezone );
8282
$datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
8383
$timestamp = $datetime->getTimestamp();

tests/phpunit/tests/date/query.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public function mysql_datetime_input_provider() {
561561
* @param bool $default_to_max Flag to default missing values to max.
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() );
567567

@@ -583,7 +583,7 @@ public function mysql_datetime_input_provider_custom_timezone() {
583583
* @ticket 41782
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() );
589589

tests/phpunit/tests/date/wpTimezone.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function test_should_convert_gmt_offset( $gmt_offset, $tz_name ) {
3131
* @ticket 24730
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

4343
/**

tests/phpunit/tests/date/xmlrpc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
1414
* @covers wp_xmlrpc_server::mw_newPost
1515
*/
1616
public function test_date_new_post() {
17-
$timezone = 'Europe/Kiev';
17+
$timezone = 'Europe/Helsinki';
1818
update_option( 'timezone_string', $timezone );
1919

2020
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -134,7 +134,7 @@ public function test_date_new_post() {
134134
* @covers wp_xmlrpc_server::mw_editPost
135135
*/
136136
public function test_date_edit_post() {
137-
$timezone = 'Europe/Kiev';
137+
$timezone = 'Europe/Helsinki';
138138
update_option( 'timezone_string', $timezone );
139139

140140
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -202,8 +202,8 @@ public function test_date_edit_post() {
202202
*
203203
* @covers wp_xmlrpc_server::wp_editComment
204204
*/
205-
function test_date_edit_comment() {
206-
$timezone = 'Europe/Kiev';
205+
public function test_date_edit_comment() {
206+
$timezone = 'Europe/Helsinki';
207207
update_option( 'timezone_string', $timezone );
208208

209209
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );

tests/phpunit/tests/formatting/date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function test_is8601_to_datetime_correct_time( $timezone_string, $gmt_off
197197
public function timezone_provider() {
198198
return array(
199199
array(
200-
'timezone_string' => 'Europe/Kiev',
200+
'timezone_string' => 'Europe/Helsinki',
201201
'gmt_offset' => 3,
202202
),
203203
array(

0 commit comments

Comments
 (0)