Make WordPress Core


Ignore:
Timestamp:
09/19/2022 05:43:55 PM (20 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/date/getPostTime.php

    r50291 r54207  
    99 */
    1010class Tests_Date_GetPostTime extends WP_UnitTestCase {
     11
     12    /**
     13     * Cleans up.
     14     */
     15    public function tear_down() {
     16        // Reset the timezone option to the default value.
     17        update_option( 'timezone_string', '' );
     18
     19        parent::tear_down();
     20    }
    1121
    1222    /**
Note: See TracChangeset for help on using the changeset viewer.