mirror of
git://develop.git.wordpress.org/
synced 2025-04-08 14:13:27 +02:00
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.8 branch. See #56468. git-svn-id: https://develop.svn.wordpress.org/branches/5.8@54514 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b3af13cd3e
commit
d6a1abb9fd
@ -81,7 +81,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 );
|
||||
@ -106,7 +106,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 );
|
||||
|
@ -11,7 +11,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 ) );
|
||||
@ -24,7 +24,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(
|
||||
@ -143,7 +143,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();
|
||||
@ -193,10 +193,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' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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' ) );
|
||||
|
||||
|
@ -51,7 +51,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 ) );
|
||||
@ -80,7 +80,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 ) );
|
||||
@ -121,7 +121,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 ) );
|
||||
|
@ -33,7 +33,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
* @ticket 28992
|
||||
*/
|
||||
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 );
|
||||
@ -47,7 +47,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
* @ticket 28992
|
||||
*/
|
||||
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 );
|
||||
@ -62,8 +62,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_return_wp_timestamp() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
public function test_mysql2date_should_return_wp_timestamp() {
|
||||
$timezone = 'Europe/Helsinki';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
$datetime = new DateTime( 'now', new DateTimeZone( $timezone ) );
|
||||
$wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset();
|
||||
@ -76,8 +76,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28992
|
||||
*/
|
||||
function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
public function test_mysql2date_should_return_unix_timestamp_for_gmt_time() {
|
||||
$timezone = 'Europe/Helsinki';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
$datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
||||
$timestamp = $datetime->getTimestamp();
|
||||
|
@ -561,7 +561,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() );
|
||||
|
||||
@ -583,7 +583,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() );
|
||||
|
||||
|
@ -31,13 +31,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() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
* @covers wp_xmlrpc_server::mw_newPost
|
||||
*/
|
||||
public function test_date_new_post() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
$timezone = 'Europe/Helsinki';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
|
||||
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
|
||||
@ -134,7 +134,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 ) );
|
||||
@ -202,8 +202,8 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
*
|
||||
* @covers wp_xmlrpc_server::wp_editComment
|
||||
*/
|
||||
function test_date_edit_comment() {
|
||||
$timezone = 'Europe/Kiev';
|
||||
public function test_date_edit_comment() {
|
||||
$timezone = 'Europe/Helsinki';
|
||||
update_option( 'timezone_string', $timezone );
|
||||
|
||||
$datetime = new DateTimeImmutable( 'now', new DateTimeZone( $timezone ) );
|
||||
|
@ -197,7 +197,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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user