Skip to content

Commit 3ba3dc2

Browse files
committed
Tests: replace the timezone used in tests
The `Europe/Kiev` timezone has become deprecated in PHP 8.2 and been replaced with `Europe/Kyiv`. These tests are testing WP date/time functionality. They are **not** testing whether WP/PHP can handle deprecated timezone names correctly. To ensure the tests stay "pure" and test what the original purpose was for these tests, I'm replacing the use of `Europe/Kiev` within these tests now 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.
1 parent 6e5eee3 commit 3ba3dc2

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

tests/phpunit/tests/date/currentTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function test_should_work_with_changed_timezone() {
9292
* @ticket 40653
9393
*/
9494
public function test_should_return_wp_timestamp() {
95-
update_option( 'timezone_string', 'Europe/Kiev' );
95+
update_option( 'timezone_string', 'Europe/Helsinki' );
9696

9797
$timestamp = time();
9898
$datetime = new DateTime( '@' . $timestamp );
@@ -117,7 +117,7 @@ public function test_should_return_wp_timestamp() {
117117
* @ticket 40653
118118
*/
119119
public function test_should_return_correct_local_time() {
120-
update_option( 'timezone_string', 'Europe/Kiev' );
120+
update_option( 'timezone_string', 'Europe/Helsinki' );
121121

122122
$timestamp = time();
123123
$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
@@ -22,7 +22,7 @@ public function tear_down() {
2222
* @ticket 28636
2323
*/
2424
public function test_should_return_current_time_on_invalid_timestamp() {
25-
$timezone = 'Europe/Kiev';
25+
$timezone = 'Europe/Helsinki';
2626
update_option( 'timezone_string', $timezone );
2727

2828
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
@@ -35,7 +35,7 @@ public function test_should_return_current_time_on_invalid_timestamp() {
3535
* @ticket 28636
3636
*/
3737
public function test_should_handle_zero_timestamp() {
38-
$timezone = 'Europe/Kiev';
38+
$timezone = 'Europe/Helsinki';
3939
update_option( 'timezone_string', $timezone );
4040

4141
$datetime = DateTimeImmutable::createFromFormat(
@@ -154,7 +154,7 @@ public function data_formats() {
154154
* @ticket 25768
155155
*/
156156
public function test_should_return_wp_timestamp() {
157-
update_option( 'timezone_string', 'Europe/Kiev' );
157+
update_option( 'timezone_string', 'Europe/Helsinki' );
158158

159159
$datetime = new DateTimeImmutable( 'now', wp_timezone() );
160160
$timestamp = $datetime->getTimestamp();
@@ -204,10 +204,10 @@ public function test_should_handle_dst( $time, $timezone ) {
204204

205205
public function dst_times() {
206206
return array(
207-
'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Kiev' ),
208-
'After DST start' => array( '2019-03-31 04:01:00', 'Europe/Kiev' ),
209-
'Before DST end' => array( '2019-10-27 02:59:00', 'Europe/Kiev' ),
210-
'After DST end' => array( '2019-10-27 04:01:00', 'Europe/Kiev' ),
207+
'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ),
208+
'After DST start' => array( '2019-03-31 04:01:00', 'Europe/Helsinki' ),
209+
'Before DST end' => array( '2019-10-27 02:59:00', 'Europe/Helsinki' ),
210+
'After DST end' => array( '2019-10-27 04:01:00', 'Europe/Helsinki' ),
211211
);
212212
}
213213
}

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
@@ -61,7 +61,7 @@ public function test_get_post_modified_time_returns_false_with_null_or_non_exist
6161
* @ticket 25002
6262
*/
6363
public function test_should_return_wp_timestamp() {
64-
$timezone = 'Europe/Kiev';
64+
$timezone = 'Europe/Helsinki';
6565
update_option( 'timezone_string', $timezone );
6666

6767
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -90,7 +90,7 @@ public function test_should_return_wp_timestamp() {
9090
* @ticket 25002
9191
*/
9292
public function test_should_return_time() {
93-
$timezone = 'Europe/Kiev';
93+
$timezone = 'Europe/Helsinki';
9494
update_option( 'timezone_string', $timezone );
9595

9696
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -131,7 +131,7 @@ public function test_should_keep_utc_time_on_timezone_change() {
131131
)
132132
);
133133

134-
update_option( 'timezone_string', 'Europe/Kiev' );
134+
update_option( 'timezone_string', 'Europe/Helsinki' );
135135

136136
$this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
137137
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) );

tests/phpunit/tests/date/mysql2date.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function test_mysql2date_returns_gmt_or_unix_timestamp() {
3636
* @ticket 28992
3737
*/
3838
public function test_mysql2date_should_format_time() {
39-
$timezone = 'Europe/Kiev';
39+
$timezone = 'Europe/Helsinki';
4040
update_option( 'timezone_string', $timezone );
4141
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
4242
$rfc3339 = $datetime->format( DATE_RFC3339 );
@@ -50,7 +50,7 @@ public function test_mysql2date_should_format_time() {
5050
* @ticket 28992
5151
*/
5252
public function test_mysql2date_should_format_time_with_changed_time_zone() {
53-
$timezone = 'Europe/Kiev';
53+
$timezone = 'Europe/Helsinki';
5454
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
5555
date_default_timezone_set( $timezone );
5656
update_option( 'timezone_string', $timezone );
@@ -66,7 +66,7 @@ public function test_mysql2date_should_format_time_with_changed_time_zone() {
6666
* @ticket 28992
6767
*/
6868
public function test_mysql2date_should_return_wp_timestamp() {
69-
$timezone = 'Europe/Kiev';
69+
$timezone = 'Europe/Helsinki';
7070
update_option( 'timezone_string', $timezone );
7171
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
7272
$wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset();
@@ -80,7 +80,7 @@ public function test_mysql2date_should_return_wp_timestamp() {
8080
* @ticket 28992
8181
*/
8282
public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
83-
$timezone = 'Europe/Kiev';
83+
$timezone = 'Europe/Helsinki';
8484
update_option( 'timezone_string', $timezone );
8585
$datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
8686
$timestamp = $datetime->getTimestamp();

tests/phpunit/tests/date/query.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public function mysql_datetime_input_provider() {
571571
* @param bool $default_to_max Flag to default missing values to max.
572572
*/
573573
public function test_build_mysql_datetime_with_custom_timezone( $datetime, $expected, $default_to_max = false ) {
574-
update_option( 'timezone_string', 'Europe/Kiev' );
574+
update_option( 'timezone_string', 'Europe/Helsinki' );
575575

576576
$q = new WP_Date_Query( array() );
577577

@@ -593,7 +593,7 @@ public function mysql_datetime_input_provider_custom_timezone() {
593593
* @ticket 41782
594594
*/
595595
public function test_build_mysql_datetime_with_relative_date() {
596-
update_option( 'timezone_string', 'Europe/Kiev' );
596+
update_option( 'timezone_string', 'Europe/Helsinki' );
597597

598598
$q = new WP_Date_Query( array() );
599599

tests/phpunit/tests/date/wpTimezone.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function test_should_convert_gmt_offset( $gmt_offset, $tz_name ) {
4242
* @ticket 24730
4343
*/
4444
public function test_should_return_timezone_string() {
45-
update_option( 'timezone_string', 'Europe/Kiev' );
45+
update_option( 'timezone_string', 'Europe/Helsinki' );
4646

47-
$this->assertSame( 'Europe/Kiev', wp_timezone_string() );
47+
$this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
4848

4949
$timezone = wp_timezone();
5050

51-
$this->assertSame( 'Europe/Kiev', $timezone->getName() );
51+
$this->assertSame( 'Europe/Helsinki', $timezone->getName() );
5252
}
5353

5454
/**

tests/phpunit/tests/date/xmlrpc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function test_date_new_post() {
3434
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
3535
}
3636

37-
$timezone = 'Europe/Kiev';
37+
$timezone = 'Europe/Helsinki';
3838
update_option( 'timezone_string', $timezone );
3939

4040
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -154,7 +154,7 @@ public function test_date_new_post() {
154154
* @covers wp_xmlrpc_server::mw_editPost
155155
*/
156156
public function test_date_edit_post() {
157-
$timezone = 'Europe/Kiev';
157+
$timezone = 'Europe/Helsinki';
158158
update_option( 'timezone_string', $timezone );
159159

160160
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@@ -223,7 +223,7 @@ public function test_date_edit_post() {
223223
* @covers wp_xmlrpc_server::wp_editComment
224224
*/
225225
public function test_date_edit_comment() {
226-
$timezone = 'Europe/Kiev';
226+
$timezone = 'Europe/Helsinki';
227227
update_option( 'timezone_string', $timezone );
228228

229229
$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
@@ -233,7 +233,7 @@ public function test_is8601_to_datetime_correct_time( $timezone_string, $gmt_off
233233
public function timezone_provider() {
234234
return array(
235235
array(
236-
'timezone_string' => 'Europe/Kiev',
236+
'timezone_string' => 'Europe/Helsinki',
237237
'gmt_offset' => 3,
238238
),
239239
array(

0 commit comments

Comments
 (0)