Conversation
Ensures tests run under the correct user context and accurately verify localized script data. Explicitly sets an administrator user for the `add_settings_action_link` test, ensuring it runs with appropriate capabilities. Corrects the `test_user_options` assertion for backup codes by enqueueing assets and checking `wp_localize_script` output directly, reflecting how data is passed to JavaScript.
|
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 SVNIf you're a Core Committer, use this list when committing to GitHub Merge commitsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR updates the WordPress unit tests to run under the correct user capability context and to assert backup-code “userId” data via wp_localize_script output rather than HTML, aligning the tests with how the plugin actually passes data to JavaScript.
Changes:
- Set the current user to an administrator in
test_add_settings_action_link()so capability-gated links are included. - Fix
test_user_options()for backup codes by registering/enqueuing assets and asserting against localized script data (wp_scripts()), not the rendered HTML.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/providers/class-two-factor-backup-codes.php |
Registers/enqueues the backup codes admin script in-test and asserts userId via localized script data. |
tests/class-two-factor-core.php |
Runs add_settings_action_link test under an admin user and restores the previous user afterward. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ensures tests run under the correct user context and accurately verify localized script data.
Explicitly sets an administrator user for the
add_settings_action_linktest, ensuring it runs with appropriate capabilities.Corrects the
test_user_optionsassertion for backup codes by enqueueing assets and checkingwp_localize_scriptoutput directly, reflecting how data is passed to JavaScript.Changelog Entry