Repository navigation
Conversation
…es.php. Adds tests for the permission of `core/get-site-info`, the label and description of the `site`, `user` and `content` ability categories, the category and annotations of the core information abilities, and the `roles` returned by `core/get-user-info`. See #66493.
|
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:
|
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues with the added unit coverage for core abilities.
No open issues 🎉
What changed in this PR
Adds unit coverage for core abilities registered in src/wp-includes/abilities.php, without changing production behavior.
Changes:
- Tests
core/get-site-infopermissions for administrators, delegated capability holders, subscribers, and logged-out visitors. - Verifies core category labels and descriptions, ability category assignments, and read-only, non-destructive, idempotent annotations.
- Covers user-role ordering, normalization of sparse arrays, JSON array encoding, and users without roles.
| File | Description |
|---|---|
tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php |
Adds permission, category, annotation, and user-role tests for core abilities. |
Review effort: Balanced
gziolo
left a comment
There was a problem hiding this comment.
Thanks for the new tests! The tests for categories, annotations, delegated manage_options and user roles are useful. My comments are mostly about overlap with existing tests.
…on denial tests. See #66493.
Cover `core/get-site-info` permissions, the categories and annotations of the core information abilities, and the roles returned by `core/get-user-info`. Developed in #15528. Props hmbashar, gziolo. Fixes #66493. git-svn-id: https://develop.svn.wordpress.org/trunk@65307 602fd350-edb4-49c9-b593-d223f7449a82
Cover `core/get-site-info` permissions, the categories and annotations of the core information abilities, and the roles returned by `core/get-user-info`. Developed in WordPress/wordpress-develop#15528. Props hmbashar, gziolo. Fixes #66493. Built from https://develop.svn.wordpress.org/trunk@65307 git-svn-id: http://core.svn.wordpress.org/trunk@64447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds unit tests for behaviors of the core abilities registered in
src/wp-includes/abilities.phpthat had no test, intests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php. No behavior is changed.What is covered:
core/get-site-infopermissionmanage_optionsdelegated.check_permissions()andexecute(), for a subscriber and for a logged-out visitor.site,userandcontentcategories. Onlyuncategorizedwas asserted before.core/get-site-info,core/get-user-infoandcore/get-environment-info)rolesofcore/get-user-infoThe permission tests check the outcome (
check_permissions()andexecute()), not how the capability is declared, so they stay valid if the way abilities declare required capabilities changes (see #66325).Testing:
vendor/bin/phpunit --filter Tests_Abilities_API_WpRegisterCoreAbilitiesvendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_Abilities_API_WpRegisterCoreAbilitiesvendor/bin/phpunit --group abilities-apivendor/bin/phpcs tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.phpI also temporarily broke the related lines in
src/wp-includes/abilities.php(the required capability ofcore/get-site-info, the label and descriptions of the three categories, the category of an ability, each of the three annotations, and thearray_values()call for the roles) and confirmed that a new test fails for each one.Trac ticket: https://core.trac.wordpress.org/ticket/66493
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.