Skip to content

Tests: Cover get_comment_author_IP() and comment_author_IP() - #15254

Open
shail-mehta wants to merge 7 commits into
WordPress:trunkfrom
shail-mehta:tests/get-comment-author-ip-65819
Open

shail-mehta wants to merge 7 commits into
WordPress:trunkfrom
shail-mehta:tests/get-comment-author-ip-65819

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Trac ticket: #65819

What

Adds a dedicated PHPUnit class for get_comment_author_IP() and comment_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 @covers coverage. Small helper coverage fits the #65819 test cleanup track.

How

Add tests/phpunit/tests/comment/getCommentAuthorIP.php with @covers for both functions.

Testing Instructions

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

Use of AI Tools

  • Cursor

Add unit tests for IP retrieval, objects, globals, filters, and output.

See #65819.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 @covers annotations 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>
@shail-mehta
shail-mehta requested a balanced review from Copilot October 30, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the added PHPUnit coverage for the comment-author IP helpers.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 30, 2026 17:14
@github-actions

github-actions Bot commented Oct 30, 2026 •

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 shailu25, lancewillett.

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.

@lancewillett lancewillett 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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests leave comment-object input, global-comment fallback, and empty-IP behavior untested for both helpers, allowing regressions in these supported cases to go undetected.

1 open issue

Review effort: Balanced

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests cover only explicit comment IDs with non-empty IPs, leaving comment-object input, global-comment fallback, and empty-IP retrieval/output untested.

1 open issue
1 resolved since last review

Review effort: Balanced

@shail-mehta

Copy link
Copy Markdown
Member Author

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.

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.

3 participants