Repository navigation
Tests: Add unit coverage for rest_get_avatar_sizes() and rest_get_avatar_urls() - #15250
shail-mehta wants to merge 4 commits into
Conversation
Add unit tests for default sizes, filtered sizes, and URL keys. See #65819.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the test-only addition of REST API avatar helper coverage.
No open issues 🎉
What changed in this PR
Adds direct PHPUnit coverage for the REST API avatar helpers as part of the test cleanup tracked in #65819. This is a test-only change with no production code changes.
Changes:
- Tests default and filtered avatar sizes.
- Verifies avatar URL keys and values for both size sets.
- Adds explicit
@coversannotations for both helpers.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/restGetAvatarSizes.php |
Adds four tests covering avatar sizes and corresponding URLs. |
Review effort: Balanced
|
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 narrow this to the distinct filtered-size behavior: the REST users/comments controller tests and schema fixture already cover default avatar sizes and URLs. For the retained URL check, avoid computing the expectation with get_avatar_url() exactly as production does; assert independently expected URL components for the fixed email and requested sizes. One filtered URL check can exercise both helpers without repeating the default-size matrix.
AI review · gpt-6
Drop default-size cases already covered elsewhere and assert independent Gravatar URL components for filtered sizes. See #65819.
Parse the Gravatar query string so filtered-size URL checks require the exact s parameter. See #65819.
|
Thanks @lancewillett - addressed your feedback: filtered-size coverage only, with independent Gravatar URL checks (exact Copilot asked to restore default size/URL tests; leaving those out since you noted they’re already covered in the REST Happy to change further if needed. |

Trac ticket: #65819
What
Adds a dedicated PHPUnit class for
rest_get_avatar_sizes()andrest_get_avatar_urls(), covering default sizes, filtered sizes, and URL keys.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/rest-api/restGetAvatarSizes.phpwith@coversfor both functions.Testing Instructions
npm run test:php -- --filter Tests_REST_API_RestGetAvatarSizesnpm run test:php -- --filter Tests_REST_API_RestGetAvatarSizes -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_REST_API_RestGetAvatarSizes --order-by=randomnpm run test:php -- --group restapiUse of AI Tools