Repository navigation
Conversation
Adds tests for `wp_admin_bar_my_account_item()`, `wp_admin_bar_my_account_menu()` and `wp_admin_bar_my_sites_menu()`, covering logged-out users, the node hierarchy, avatar and fallback icon handling, the "Edit Profile" label, single and multiple site users, sites without the `read` capability, the site name fallback, site icons and the Network Admin URLs. See #66491.
|
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
No active review issues are reported for the added PHPUnit coverage of the Toolbar’s My Account and My Sites menus.
No open issues 🎉
What changed in this PR
Adds PHPUnit coverage for the Toolbar’s My Account and My Sites menus, supporting the test coverage work in Trac #66491 without changing production behavior.
Changes:
- Tests My Account visibility, node hierarchy, profile labels, keyboard focus, and avatar behavior.
- Tests My Sites visibility, site-specific links, capability restrictions, and site-name fallback.
- Covers network admin links, secondary styling, site icons, and the icon visibility filter.
| File | Description |
|---|---|
tests/phpunit/tests/adminbar.php |
Adds My Account and My Sites menu tests for single-site and multisite installations. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for working on this, @hmbashar! I really appreciate you taking the time to cover the Toolbar My Account and My Sites menus—these build essential parts of the admin bar across single-site and multisite installs and had no direct test coverage before.
I reviewed the changes against Core standards, verified fixture hygiene, and ran through both single-site and multisite scenarios. Everything looks solid, cleanly isolated, and ready to go.
AI Review: Gemini 3.8 Flash
…into 66491-admin-bar-tests-account-my-sites # Conflicts: # tests/phpunit/tests/adminbar.php
lancewillett
left a comment
There was a problem hiding this comment.
Please fold the single-site “no profile link” assertions into test_admin_bar_contains_correct_links_for_users_with_no_role(). That test already logs in the same no-role user, builds the Toolbar, and reads both nodes. I tried moving the tabindex and “Edit Profile” checks there and removing the second method. The randomized single-site class still passed.
For the network-admin links, please extend the existing super-admin test and its provider with the new URL expectations. That keeps the new destination checks alongside the eight node IDs already covered. The remaining parent and secondary-group assertions can stay focused. This also addresses the overlap John called out on Trac.
AI review · gpt-6
… the existing tests. See #66491.
|
Thanks @lancewillett, I applied both points in 7d721df:
Tests pass in single-site and multisite, and PHPCS is clean. |
lancewillett
left a comment
There was a problem hiding this comment.
Thanks for folding the profile-link assertions into the existing no-role test and extending the network-menu provider. The Toolbar class passed locally in random order on single site (58 tests) and multisite (89 tests).
AI review · gpt-6
Adds unit tests for the Toolbar (Admin Bar) My Account and My Sites menus in
tests/phpunit/tests/adminbar.php. This is the first group of the test coverage work proposed in the ticket. No behavior is changed.Functions covered:
wp_admin_bar_my_account_item()andwp_admin_bar_my_account_menu()my-account,user-actions,user-infoandlogout.tabindex, with and without a profile link.show_avatars.wp_admin_bar_my_sites_menu()readcapability: links to the front end and only offers "Visit Site".www.) when the name is empty.wp_admin_bar_show_site_iconsfilter.Testing:
vendor/bin/phpunit --filter Tests_AdminBarvendor/bin/phpunit -c tests/phpunit/multisite.xml --filter Tests_AdminBarvendor/bin/phpcs tests/phpunit/tests/adminbar.phpI also temporarily broke the related lines in
src/wp-includes/admin-bar.php(avatar class, logged-out guard, no-sites guard,readcapability branch, site name fallback, site icon filter, secondary class) and confirmed that a new test fails for each one.Trac ticket: https://core.trac.wordpress.org/ticket/66491
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.