Repository navigation
Tests: Add unit tests for get_theme_root_uri(). - #16191
rejaulalomkhan wants to merge 2 commits into
Conversation
Cover default theme root URI, relative paths, absolute paths under WP_CONTENT_DIR and ABSPATH, and the theme_root_uri filter. See #17597.
|
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 were identified for the added get_theme_root_uri() test coverage.
No open issues 🎉
What changed in this PR
Adds dedicated PHPUnit coverage for get_theme_root_uri(), verifying theme directory URI resolution without changing production code.
Changes:
- Tests default and relative theme root URIs.
- Tests registered absolute theme directories within
WP_CONTENT_DIRandABSPATH. - Verifies that the
theme_root_urifilter can override the returned URI.
| File | Description |
|---|---|
tests/phpunit/tests/theme/getThemeRootUri.php |
Adds five tests covering URI resolution and filtering, with theme directory state restored after each test. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The custom-root cases protect useful behavior: a registered directory under WP_CONTENT_DIR gets a content URL, while one elsewhere under ABSPATH gets a site URL. Please keep those cases and the directory restore. Drop the blanket remove_all_filters( 'theme_root_uri' ); the base class restores hooks. The filter test returns a constant even if Core forwards the wrong theme. Please either check the requested stylesheet argument or drop that case.
Please use the existing themes test group and link any retained coverage to an open component ticket. The historical ticket can stay as context.
AI review · gpt-6
Use the themes group, drop the blanket theme_root_uri filter removal, and check that the filter receives the requested stylesheet. Link the tests to the new Themes ticket and keep #17597 as context on the custom-root cases. See #66823.
|
Thanks, @lancewillett! Updated in df7a883:
Single site, multisite and the AI assistance · |
lancewillett
left a comment
There was a problem hiding this comment.
The revised filter test catches Core passing the wrong stylesheet. Both custom-root cases also passed with the shared hook cleanup in place. I ran all five tests in randomized order on single-site and multisite.
AI review · gpt-6.2-astra
Trac ticket: https://core.trac.wordpress.org/ticket/66823
Description
Adds tests for
get_theme_root_uri()intests/phpunit/tests/theme/getThemeRootUri.php.The main cases cover the mapping added in [20016] (#17597): a registered absolute theme directory gets a content URL when it is under
WP_CONTENT_DIR, and a site URL when it is elsewhere underABSPATH.test_get_theme_root_uri_with_wp_content_dir_path()WP_CONTENT_DIRresolves throughcontent_url().test_get_theme_root_uri_with_abspath()ABSPATHresolves throughsite_url().test_theme_root_uri_filter_receives_requested_stylesheet()theme_root_urifilter receives the requested stylesheet, and its return value is used.test_get_theme_root_uri_default()content_url( 'themes' ).test_get_theme_root_uri_with_relative_root()content_url().$wp_theme_directoriesis restored after each test.Testing Instructions
themesgroup (822 tests) passes in default and random order.get_theme_root_uri()passesget_stylesheet()to the filter instead of the requested theme, the filter test fails.This Pull Request is for code review only. Please keep all other discussion to the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
Use of AI Tools
AI assistance: Yes
Tool(s): Google Antigravity (first version); Claude Code (review follow-up)
Model(s): Gemini 3.8 Flash; Claude Opus 5.5
Used for: drafting the tests and the review changes, running the tests and the mutation check, and drafting this description. I reviewed every line and take responsibility for the change.