Skip to content

Fixed broken test cases#841

Merged
masteradhoc merged 1 commit intoWordPress:masterfrom
nimesh-xecurify:fix-test-cases
Mar 20, 2026
Merged

Fixed broken test cases#841
masteradhoc merged 1 commit intoWordPress:masterfrom
nimesh-xecurify:fix-test-cases

Conversation

@nimesh-xecurify
Copy link
Copy Markdown
Contributor

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.

Changelog Entry

Fixed - Fixed broken test cases.

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.
@github-actions
Copy link
Copy Markdown

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 props-bot label.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: nimeshatxecurify.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: nimesh-xecurify <nimeshatxecurify@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@masteradhoc masteradhoc added this to the 0.16.0 milestone Mar 20, 2026
@masteradhoc masteradhoc self-requested a review March 20, 2026 05:18
Copy link
Copy Markdown
Collaborator

@masteradhoc masteradhoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@masteradhoc masteradhoc merged commit 62ac5a4 into WordPress:master Mar 20, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants