Repository navigation
Tests: Isolate global styles revisions block variation tests on multisite - #16256
noruzzamans wants to merge 2 commits into
Conversation
|
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 scoped privilege setup and cleanup in the four multisite global styles revision tests.
No open issues 🎉
What changed in this PR
This PR makes four global styles revision tests independent of execution order on multisite by allowing their administrator user to save block style variations without KSES stripping them.
Changes:
- Adds a helper that grants super admin on multisite before setting the current administrator user.
- Updates the four affected tests to use the helper.
- Adds teardown cleanup to revoke super admin and reinitialize KSES.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php |
Adds scoped privilege setup and cleanup for four block style variation tests. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The four multisite failures are reproducible. Granting the fixture user the capability needed to save these four revisions fixes them. Could you keep that part and drop the flag and new teardown? The base case rolls back the site-admin option, restores hooks and resets the current user. With the flag, revoke and explicit kses_init() removed, the class still passed all 50 tests and 234 assertions in each site mode with seed 42. If another existing test needs the extra cleanup, please share the failing order so we can check that case.
AI review · gpt-6.2-astra
|
Thank you, @lancewillett. Dropped the |
lancewillett
left a comment
There was a problem hiding this comment.
The latest revision removes the flag and teardown. The four failing multisite cases now grant the fixture user the capability needed to save the variation data. The narrowed class passed 50 tests and 234 assertions in both site modes, including random order.
AI review · gpt-6.2-astra
Four block style variation tests in
WP_REST_Global_Styles_Revisions_Controller_Testfail on multisite when run in isolation or in reverse order (--order-by=reverse), becauseself::$admin_idlacksunfiltered_htmlon multisite. Whenwp_update_post()saves the fixture,wp_filter_global_styles_post()runsWP_Theme_JSON::remove_insecure_properties(), which strips unregistered block style variations before the revision is stored. In full default runs, an earlier test (Tests_Block_Supports_BlockStyleVariations) leavesblock-style-variation-aregistered inWP_Block_Styles_Registry, masking the failure.This grants super admin to
self::$admin_idon multisite for those four tests before setting the current user, and revokes it withkses_init()intear_down().Failing before the fix (multisite, isolated)
Output:
Also reproduced in reverse order on multisite (
npm run test:php -- -c tests/phpunit/multisite.xml --order-by=reverse --stop-on-failure --filter "Tests_Filesystem_WpFilesystemDirect_Copy|Tests_[U-Z]|WP_").Passing with the fix
npm run test:php -- -c tests/phpunit/multisite.xml --filter WP_REST_Global_Styles_Revisions_Controller_Test):OK (50 tests, 234 assertions)npm run test:php -- --filter WP_REST_Global_Styles_Revisions_Controller_Test):OK (50 tests, 234 assertions)composer exec phpcs -- tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php): 0 errors, 0 warningsTrac ticket: https://core.trac.wordpress.org/ticket/66755