Repository navigation
Tests: Add unit coverage for get_comment_ID() and comment_ID() - #15276
shail-mehta wants to merge 2 commits into
Conversation
Add unit tests for comment ID retrieval, empty fallback, filter, and display output.\n\nSee #65819.
There was a problem hiding this comment.
🟡 Changes recommended
The empty-fallback assertion remains order-dependent because it does not clear $GLOBALS['comment'] beforehand, allowing a stale comment ID from earlier tests to cause a failure.
1 open issue
What changed in this PR
Adds direct PHPUnit coverage for the comment ID helpers as part of the #65819 test cleanup effort. No production code changes are included.
Changes:
- Tests ID retrieval from the global comment and the empty fallback.
- Verifies filter customization and echoed output.
- Adds explicit
@coversannotations for both helpers.
| File | Description |
|---|---|
tests/phpunit/tests/comment/getCommentID.php |
Adds fixtures and four tests for get_comment_ID() and comment_ID(). |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
lancewillett
left a comment
There was a problem hiding this comment.
Tests string ID and empty fallback. Current unset before the no-comment assertion fixes the reported order dependency.
Local randomized single-site and multisite checks passed with related existing tests: 51 tests, 319 assertions across this five-PR batch (seed 15273). PHPCS passed.
Optional: Echo and constant-filter exercises are lower value than the string-ID and empty-fallback cases; no further edge cases needed.
AI review · gpt-6
Verify comment email, URL, and ID retrieval and display, including global comment handling and filtered output. Developed in: #15274, #15276, #15280 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65137 602fd350-edb4-49c9-b593-d223f7449a82
Verify comment email, URL, and ID retrieval and display, including global comment handling and filtered output. Developed in: WordPress/wordpress-develop#15274, WordPress/wordpress-develop#15276, WordPress/wordpress-develop#15280 Props shailu25. See #65819. Built from https://develop.svn.wordpress.org/trunk@65137 git-svn-id: http://core.svn.wordpress.org/trunk@64286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15276 landed in https://core.trac.wordpress.org/changeset/65137 |

Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
get_comment_ID()andcomment_ID(), covering ID retrieval from the global comment, the empty fallback, the filter, and display output.Test-only; no production code changes.
Why
These helpers had no direct
@coverscoverage. Small helper coverage fits the #65819 test cleanup track.How
Add
tests/phpunit/tests/comment/getCommentID.phpwith@coversfor both functions.Testing Instructions
npm run test:php -- --filter Tests_Comment_GetCommentIDnpm run test:php -- --filter Tests_Comment_GetCommentID -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_Comment_GetCommentID --order-by=randomnpm run test:php -- --group commentUse of AI Tools