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.
See #56468.

git-svn-id: https://develop.svn.wordpress.org/trunk@54217 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-09-19 21:18:59 +00:00
parent fd91d0f355
commit 8127aaed05
9 changed files with 26 additions and 26 deletions

View File

@ -92,7 +92,7 @@ class Tests_Date_CurrentTime extends WP_UnitTestCase {
* @ticket 40653
*/
public function test_should_return_wp_timestamp() {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$timestamp = time();
$datetime = new DateTime( '@' . $timestamp );
@ -117,7 +117,7 @@ class Tests_Date_CurrentTime extends WP_UnitTestCase {
* @ticket 40653
*/
public function test_should_return_correct_local_time() {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$timestamp = time();
$datetime_local = new DateTime( '@' . $timestamp );

View File

@ -22,7 +22,7 @@ class Tests_Date_DateI18n extends WP_UnitTestCase {
* @ticket 28636
*/
public function test_should_return_current_time_on_invalid_timestamp() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
@ -35,7 +35,7 @@ class Tests_Date_DateI18n extends WP_UnitTestCase {
* @ticket 28636
*/
public function test_should_handle_zero_timestamp() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = DateTimeImmutable::createFromFormat(
@ -154,7 +154,7 @@ class Tests_Date_DateI18n extends WP_UnitTestCase {
* @ticket 25768
*/
public function test_should_return_wp_timestamp() {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$datetime = new DateTimeImmutable( 'now', wp_timezone() );
$timestamp = $datetime->getTimestamp();
@ -204,10 +204,10 @@ class Tests_Date_DateI18n extends WP_UnitTestCase {
public function dst_times() {
return array(
'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Kiev' ),
'After DST start' => array( '2019-03-31 04:01:00', 'Europe/Kiev' ),
'Before DST end' => array( '2019-10-27 02:59:00', 'Europe/Kiev' ),
'After DST end' => array( '2019-10-27 04:01:00', 'Europe/Kiev' ),
'Before DST start' => array( '2019-03-31 02:59:00', 'Europe/Helsinki' ),
'After DST start' => array( '2019-03-31 04:01:00', 'Europe/Helsinki' ),
'Before DST end' => array( '2019-10-27 02:59:00', 'Europe/Helsinki' ),
'After DST end' => array( '2019-10-27 04:01:00', 'Europe/Helsinki' ),
);
}
}

View File

@ -47,7 +47,7 @@ class Tests_Date_GetFeedBuildDate extends WP_UnitTestCase {
public function test_should_fall_back_to_last_post_modified() {
global $wp_query;
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$datetime = new DateTimeImmutable( 'now', wp_timezone() );
$datetime_utc = $datetime->setTimezone( new DateTimeZone( 'UTC' ) );

View File

@ -61,7 +61,7 @@ class Tests_Date_GetPostTime extends WP_UnitTestCase {
* @ticket 25002
*/
public function test_should_return_wp_timestamp() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@ -90,7 +90,7 @@ class Tests_Date_GetPostTime extends WP_UnitTestCase {
* @ticket 25002
*/
public function test_should_return_time() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@ -131,7 +131,7 @@ class Tests_Date_GetPostTime extends WP_UnitTestCase {
)
);
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) );

View File

@ -36,7 +36,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
* @ticket 28992
*/
public function test_mysql2date_should_format_time() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
$rfc3339 = $datetime->format( DATE_RFC3339 );
@ -50,7 +50,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
* @ticket 28992
*/
public function test_mysql2date_should_format_time_with_changed_time_zone() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
date_default_timezone_set( $timezone );
update_option( 'timezone_string', $timezone );
@ -66,7 +66,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
* @ticket 28992
*/
public function test_mysql2date_should_return_wp_timestamp() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
$wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset();
@ -80,7 +80,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
* @ticket 28992
*/
public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
$timestamp = $datetime->getTimestamp();

View File

@ -571,7 +571,7 @@ class Tests_Date_Query extends WP_UnitTestCase {
* @param bool $default_to_max Flag to default missing values to max.
*/
public function test_build_mysql_datetime_with_custom_timezone( $datetime, $expected, $default_to_max = false ) {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$q = new WP_Date_Query( array() );
@ -593,7 +593,7 @@ class Tests_Date_Query extends WP_UnitTestCase {
* @ticket 41782
*/
public function test_build_mysql_datetime_with_relative_date() {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$q = new WP_Date_Query( array() );

View File

@ -42,13 +42,13 @@ class Tests_Date_wpTimezone extends WP_UnitTestCase {
* @ticket 24730
*/
public function test_should_return_timezone_string() {
update_option( 'timezone_string', 'Europe/Kiev' );
update_option( 'timezone_string', 'Europe/Helsinki' );
$this->assertSame( 'Europe/Kiev', wp_timezone_string() );
$this->assertSame( 'Europe/Helsinki', wp_timezone_string() );
$timezone = wp_timezone();
$this->assertSame( 'Europe/Kiev', $timezone->getName() );
$this->assertSame( 'Europe/Helsinki', $timezone->getName() );
}
/**

View File

@ -34,7 +34,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
$this->expectDeprecationMessageMatches( '`Passing null to parameter \#[0-9]+ \(\$[^\)]+\) of type [^ ]+ is deprecated`' );
}
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@ -154,7 +154,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
* @covers wp_xmlrpc_server::mw_editPost
*/
public function test_date_edit_post() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
@ -223,7 +223,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
* @covers wp_xmlrpc_server::wp_editComment
*/
public function test_date_edit_comment() {
$timezone = 'Europe/Kiev';
$timezone = 'Europe/Helsinki';
update_option( 'timezone_string', $timezone );
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );

View File

@ -233,7 +233,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
public function timezone_provider() {
return array(
array(
'timezone_string' => 'Europe/Kiev',
'timezone_string' => 'Europe/Helsinki',
'gmt_offset' => 3,
),
array(