Skip to content

WP CLI Tests - #1

Merged
masteradhoc merged 2 commits into
masteradhoc:233-add-wpcli-foundationfrom
nimesh-xecurify:wp-cli-tests-work
Jul 12, 2026
Merged

WP CLI Tests#1
masteradhoc merged 2 commits into
masteradhoc:233-add-wpcli-foundationfrom
nimesh-xecurify:wp-cli-tests-work

Conversation

@nimesh-xecurify

Copy link
Copy Markdown

Adds PHPUnit coverage for Two_Factor_CLI_Command (status, disable, enable, list-providers, backup-codes generate, unlock) and for the new Two_Factor_Core::clear_login_rate_limit() helper.

Because the WP-CLI runtime is not loaded during PHPUnit, lightweight test doubles for WP_CLI, WP_CLI_Command, and the WP_CLI\Utils helpers are added under tests/cli/ to capture output and simulate the error()/confirm() exit behaviour.

@github-actions

github-actions Bot commented Jul 10, 2026

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.

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.

@nimesh-xecurify
nimesh-xecurify changed the base branch from master to 233-add-wpcli-foundation July 10, 2026 09:18
Adds PHPUnit coverage for Two_Factor_CLI_Command (status, disable, enable, list-providers, backup-codes generate, unlock) and for the new Two_Factor_Core::clear_login_rate_limit() helper.

Because the WP-CLI runtime is not loaded during PHPUnit, lightweight test doubles for WP_CLI, WP_CLI_Command, and the WP_CLI\Utils helpers are added under tests/cli/ to capture output and simulate the error()/confirm() exit behaviour.

Also fixes the issues raised in review on PR WordPress#905:

    backup-codes generate now enables the Two_Factor_Backup_Codes provider (mirroring rest_generate_codes()) so the codes are usable at login instead of being stored but never offered.
    enable, disable, and the full reset now destroy the user's sessions when their enabled providers change, matching the profile-page behaviour.
    The full reset no longer clears _two_factor_password_was_reset, so a rescued user still sees the notice explaining why their old password stopped working.
    Removes the misleading reference to a non-existent "Phase 3" totp subcommand from the TOTP enable error message.
Explicitly verify a confirmation prompt is emitted when --yes is omitted, in addition to the existing checks that the command aborts and leaves the provider enabled. Mirrors the prompt assertion used in the wordpress-ai Alt_Text_Command tests.
@masteradhoc
masteradhoc merged commit a3fc583 into masteradhoc:233-add-wpcli-foundation Jul 12, 2026
1 check 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.

2 participants