mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-02 08:10:04 +00:00
Tests: Reset timezone-related options if the tests change them.
The `options` table is not explicitly reset after each test or test class, so if an option is changed during a test, it should be reset to the default value ''after'' the test. This commit does so for those tests which did not have such resetting in place yet, while one or more tests in the class ''do'' change the value of the `timezone_string` option. Note: The test suite executes a `ROLLBACK` query after each test, which should reset the `options` table in theory, however that appears to not always be enough, as some timezone-related tests can fail in a complete test suite run, while not failing when run in isolation. This commit aims to improve stability of the tests. Follow-up to [45857] / #45821. Props jrf, costdev. See #56468. git-svn-id: https://develop.svn.wordpress.org/trunk@54207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,6 +7,17 @@
|
||||
*/
|
||||
class Tests_Date_CurrentTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset changed options to their default value.
|
||||
update_option( 'gmt_offset', 0 );
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34378
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,17 @@
|
||||
*/
|
||||
class Tests_Date_DateI18n extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset changed options to their default value.
|
||||
update_option( 'gmt_offset', 0 );
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28636
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ class Tests_Date_GetFeedBuildDate extends WP_UnitTestCase {
|
||||
public function tear_down() {
|
||||
global $wp_query;
|
||||
|
||||
update_option( 'timezone_string', 'UTC' );
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
unset( $wp_query );
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class Tests_Date_GetPermalink extends WP_UnitTestCase {
|
||||
|
||||
public function tear_down() {
|
||||
delete_option( 'permalink_structure' );
|
||||
update_option( 'timezone_string', 'UTC' );
|
||||
update_option( 'timezone_string', '' );
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( 'UTC' );
|
||||
|
||||
|
||||
@@ -9,6 +9,16 @@
|
||||
*/
|
||||
class Tests_Date_GetPostTime extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset the timezone option to the default value.
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28310
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,9 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( 'UTC' );
|
||||
|
||||
// Reset the timezone option to the default value.
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,16 @@ class Tests_Date_Query extends WP_UnitTestCase {
|
||||
$this->q = new WP_Date_Query( array( 'm' => 2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset the timezone option to the default value.
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
public function test_construct_date_query_empty() {
|
||||
$q = new WP_Date_Query( array() );
|
||||
$this->assertSame( 'AND', $q->relation );
|
||||
|
||||
@@ -8,6 +8,17 @@
|
||||
*/
|
||||
class Tests_Date_wpTimezone extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset changed options to their default value.
|
||||
update_option( 'gmt_offset', 0 );
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 24730
|
||||
*
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
*/
|
||||
class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset the timezone option to the default value.
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30429
|
||||
*
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
*/
|
||||
class Tests_Formatting_Date extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Cleans up.
|
||||
*/
|
||||
public function tear_down() {
|
||||
// Reset changed options to their default value.
|
||||
update_option( 'gmt_offset', 0 );
|
||||
update_option( 'timezone_string', '' );
|
||||
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpatched, this test passes only when Europe/London is not observing DST.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user