Make WordPress Core

Opened 5 weeks ago

Closed 3 weeks ago

#65192 closed enhancement (fixed)

Tests: Add unit tests for wp_admin_canonical_url()

Reported by: pbearne's profile pbearne Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.1 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: tests Cc:

Description

This ticket adds comprehensive unit tests for the wp_admin_canonical_url() function in wp-admin/includes/misc.php. The tests will cover the default URL generation, handling of query parameters, and the wp_admin_canonical_url filter.

Change History (4)

This ticket was mentioned in PR #11751 on WordPress/wordpress-develop by @pbearne.


5 weeks ago
#1

  • Keywords has-patch has-unit-tests added

….php
Description:
This PR adds unit tests for the wp_admin_canonical_url() function in wp-admin/includes/misc.php. These tests ensure that the function correctly identifies and removes single-use query parameters (such as settings-updated, trashed, etc.) from the administration URL to generate a clean canonical link.

The tests cover:

  • Standard canonical URL generation for common admin screens.
  • Successful removal of one or more "removable" query arguments.
  • Correct handling of HTTPS URLs.
  • Verification that no output is generated if the list of removable arguments is empty (via filter).
  • Verification of the wp_admin_canonical_url filter for custom canonical URLs.

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

AI Disclosure:

  • AI assistance: Yes
  • Tool(s): Junie (JetBrains)
  • Model(s): gemini-3-flash-preview
  • Used for: Code analysis, test implementation, and workflow management.

#2 @desrosj
5 weeks ago

  • Focuses tests added

Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.

#3 @SergeyBiryukov
3 weeks ago

  • Milestone changed from Awaiting Review to 7.1

#4 @SergeyBiryukov
3 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 62371:

Tests: Add unit tests for wp_admin_canonical_url().

Follow-up to [31736].

Props pbearne.
Fixes #65192.

Note: See TracTickets for help on using tickets.