Repository navigation
Tests: Add unit coverage for get_comment_type() and comment_type() - #15253
shail-mehta wants to merge 6 commits into
Conversation
Add unit tests for type normalization, known types, filters, and output labels. See #65819.
There was a problem hiding this comment.
🟡 Changes recommended
The tests leave empty-type normalization untested because the factory normalizes it first, and they fail to clear the global comment fixture, risking stale objects in later tests.
2 open issues
What changed in this PR
Adds dedicated PHPUnit tests for WordPress’s get_comment_type() and comment_type() helpers as part of the test cleanup tracked in Trac #65819. No production code changes are included.
Changes:
- Adds cases for comment types, comment objects, and the global comment fallback.
- Tests filter overrides and default/custom output labels.
- Adds direct
@coversannotations for both helpers.
| File | Description |
|---|---|
tests/phpunit/tests/comment/getCommentType.php |
Adds a dedicated test class for comment-type retrieval and output. |
Review effort: Balanced
Clear the comment global in tear_down and force an empty type on the object so empty-type normalization is actually tested.
|
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.
Please trim the repeated getter cases before landing. The standalone pingback, trackback, object-input, and global-input methods largely repeat the same unchanged field return. Keep the empty-type normalization check (the direct object mutation correctly addresses Copilot), the filter-result check, and the default/custom output-label checks; use the retained label tests to exercise the global lookup. That preserves the meaningful behavior with four methods instead of eight. This is a test-size request, not a runtime failure.
AI review · gpt-6
Keep empty-type normalization, filter override, and label output checks that also exercise the global comment fallback. See #65819.
Exercise default and custom comment labels alongside pingback and trackback via data providers. See #65819.

Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
get_comment_type()andcomment_type(), covering empty-type normalization, pingback/trackback types, comment objects, the global comment fallback, the filter, and output labels.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/getCommentType.phpwith@coversfor both functions.Testing Instructions
npm run test:php -- --filter Tests_Comment_GetCommentTypenpm run test:php -- --filter Tests_Comment_GetCommentType -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_Comment_GetCommentType --order-by=randomnpm run test:php -- --group commentUse of AI Tools