Tests: Prevent state leaks in functions tests - #13182
Conversation
|
Updated this branch with current trunk and fixed the PHPCS assignment-alignment warning in wpTimezoneChoice.php. Validation: targeted PHPCS passes. The focused PHPUnit file could not run because the local test configuration file is not present. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
579de47 to
d46ce5d
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
sirreal
left a comment
There was a problem hiding this comment.
I'm not happy with this approach as it is now. The cleanup should cleanup, and tests shouldn't need to set a flag to trigger cleanup behavior.
Drop the `$restore_timezone_translations` property. `tear_down()` now resynchronizes `wp_timezone_choice()`'s locale static after every test, so no test has to opt in to its own cleanup. The resync runs before `parent::tear_down()`, which restores the hook snapshot and so undoes the `load_textdomain` and `gettext` calls the resync fires. In `Tests_Functions_ForceSslAdmin`, capture the `force_ssl_admin()` value in `set_up()` and restore it in `tear_down()` instead of writing a hard-coded `false`, following `tests/phpunit/tests/url.php`.
Summary
Verification
git diff --checkpassed.Trac: https://core.trac.wordpress.org/ticket/65893