Repository navigation
Tests: Cover get_comment_author_IP() and comment_author_IP() - #15254
shail-mehta wants to merge 7 commits into
Conversation
Add unit tests for IP retrieval, objects, globals, filters, and output. See #65819.
There was a problem hiding this comment.
🟡 Changes recommended
The escaping test uses a value without HTML-special characters, so it would still pass if esc_html() were removed and would not detect an escaping regression.
1 open issue
What changed in this PR
Adds dedicated PHPUnit coverage for get_comment_author_IP() and comment_author_IP() as part of the #65819 test cleanup effort. No production code changes.
Changes:
- Tests IP retrieval by comment ID, comment object, and global fallback, including empty IPs.
- Tests filter customization and echoed output, with
@coversannotations for both helpers.
| File | Description |
|---|---|
tests/phpunit/tests/comment/getCommentAuthorIP.php |
Adds fixtures and six tests for comment-author IP helpers. |
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.
The updated escaping test now catches a real escaping regression. Please trim the surrounding field-read matrix: the ID, object, global, and empty-IP cases repeat retrieval of the fixture value. Keep one representative getter case, the filter override, and the escaped-output case. This gives three focused checks without losing the escaping coverage. The current suite passes locally; this request is about keeping the new coverage proportionate.
AI review · gpt-6
Keep one getter case, the filter override, and the escaped-output check. See #65819.
Cover comment object, global fallback, and empty IP for both helpers via data providers while keeping the HTML escaping check. See #65819.
Retain one getter case, the filter override, and the escaped-output check per review feedback. See #65819.
|
Thanks @lancewillett - addressed your feedback: one representative getter, the filter override, and the escaped-output check. Copilot asked to restore comment-object, global fallback, and empty-IP cases; leaving those out as the repetitive field-read matrix you asked to trim. Happy to change further if needed. |

Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
get_comment_author_IP()andcomment_author_IP(), covering IP retrieval, comment objects, the global comment fallback, empty IPs, the filter, and escaped 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/getCommentAuthorIP.phpwith@coversfor both functions.Testing Instructions
npm run test:php -- --filter Tests_Comment_GetCommentAuthorIPnpm run test:php -- --filter Tests_Comment_GetCommentAuthorIP -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_Comment_GetCommentAuthorIP --order-by=randomnpm run test:php -- --group commentUse of AI Tools