Repository navigation
Tests: Add unit test coverage for the_shortlink() - #14455
rejaulalomkhan wants to merge 1 commit into
Conversation
Adds comprehensive PHPUnit tests covering default link text, custom link text via data provider, before/after HTML markup wrappers, unused title argument pass-through to filter, the the_shortlink filter hook, pre_get_shortlink filter support, empty shortlink handling, and pretty permalinks. See #65819.
|
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 Committers: Use this line as a base for the props when committing in SVN: 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.
🟢 Approval recommended
The tests match existing behavior, and the test framework handles cleanup of modified state.
No open issues 🎉
What changed in this PR
Adds PHPUnit coverage for the_shortlink() without changing production code.
Changes:
- Tests default and custom link text, plus surrounding markup.
- Checks filter arguments, output customization, and empty shortlinks.
- Exercises output with pretty permalinks enabled.
| File | Description |
|---|---|
| tests/phpunit/tests/link/theShortlink.php | Adds shortlink output and filter tests with shared fixtures. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The output checks cover anchor text, wrappers, filter arguments and replacement output, and empty-shortlink suppression. Optional follow-up: use a custom shortlink containing ?a=1&b=2 and assert a literal ?a=1&b=2 href to protect escaping at the output boundary.
Unit-tests audit and Copilot review found no blockers. PHPCS passed all ten files. The combined batch passed locally in randomized order: single-site 149 tests / 283 assertions (seed 65825), multisite 140 tests / 236 assertions (seed 65826). CI is green on the reviewed commit.
AI review · gpt-6
Verify echoed short links, link text, surrounding markup, empty output, and filter arguments and results. Developed in: #14455 Props rejaulalomkhan. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64547 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #14455 landed in https://core.trac.wordpress.org/changeset/64547 |
Verify echoed short links, link text, surrounding markup, empty output, and filter arguments and results. Developed in: WordPress/wordpress-develop#14455 Props rejaulalomkhan. See #65819. Built from https://develop.svn.wordpress.org/trunk@64547 git-svn-id: http://core.svn.wordpress.org/trunk@63697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds unit test coverage for
the_shortlink()insrc/wp-includes/link-template.php.Test scenarios covered:
This is the short link.text.Short URL, Unicode strings, HTML entities, HTML markup) via@dataProvider.the_shortlinkfilter hook arguments (receives$link,$shortlink,$text,$title).$titleargument to the filter for backward compatibility.the_shortlinkfilter hook.pre_get_shortlinkfilter hook./?p={id}).Verification:
OK (13 tests, 18 assertions)OK (13 tests, 18 assertions)OK (13 tests, 18 assertions)0 errors, 0 warnings)Trac ticket: https://core.trac.wordpress.org/ticket/65819
Use of AI Tools: Antigravity (Gemini 2.5) was used to assist in test case ideation, code scaffolding, and formatting to WordPress core standards. All assertions and test outcomes were verified locally through PHPUnit and PHPCS.