Skip to content

Tests: Add unit test coverage for the logout, lost password and registration URLs - #14680

Open
rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/login-screen-urls
Open

rejaulalomkhan wants to merge 1 commit into
WordPress:trunkfrom
rejaulalomkhan:tests/login-screen-urls

Conversation

@rejaulalomkhan

Copy link
Copy Markdown

Description

Adds a test class for wp_logout_url(), wp_lostpassword_url() and wp_registration_url(), which had no tests.

The tests cover:

  • The logout URL with and without an encoded redirect, and a nonce that verifies for the log-out action.
  • The lost password URL with and without an encoded redirect, and the current site's path on multisite (ms-required).
  • The registration URL.
  • HTTPS for all three URLs when SSL is forced for the login screen.
  • The logout_url, lostpassword_url and register_url filters: their arguments (including the unencoded redirect) and their return values.

Expected URLs are literal; only the nonce is generated at runtime.

Each behaviour was checked against a mutated source (redirect not encoded, login scheme removed, wrong nonce action, site path ignored on multisite, filter arguments or return values discarded); a test fails for every mutation.

This is a test-only change; no production code is modified.

Testing Instructions

  1. npm run test:php -- --filter Tests_General_WpLoginScreenUrls
  2. npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_General_WpLoginScreenUrls
  3. npm run test:php -- --group general --order-by=random

Trac ticket: https://core.trac.wordpress.org/ticket/65819

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafting the tests and running the checks. I reviewed the changes, ran the tests locally, and take responsibility for them.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…tration URLs.

Covers `wp_logout_url()`, `wp_lostpassword_url()` and
`wp_registration_url()`: encoded redirects, the logout nonce, the site
path on multisite, HTTPS when SSL is forced for the login screen, and
the arguments and return values of the `logout_url`, `lostpassword_url`
and `register_url` filters.

See #65819.
@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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props rejaulalomkhan.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@huzaifaalmesbah huzaifaalmesbah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @rejaulalomkhan! Nice coverage for the logout, lost password and registration URLs. LGTM.

AI Review: Opus 5.5

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