Repository navigation
Tests: Cover the invalid user setting fallback in wp_default_editor(). - #16222
mukeshpanchal27 wants to merge 3 commits into
Conversation
When the user's `editor` setting is not `tinymce`, `html`, or `test`, `wp_default_editor()` falls back to `user_can_richedit()`. The existing tests do not reach this branch. This adds a data-driven test for both results of `user_can_richedit()`. See #65819. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 this test-only change covering invalid editor-setting fallbacks.
No open issues 🎉
What changed in this PR
Adds regression coverage for the invalid user-setting fallback in wp_default_editor(), complementing the existing tests without changing production code.
Changes:
- Tests
editor=invalidwith rich editing both available and unavailable, expectingtinymceandhtmlrespectively. - Cleans up the user settings cookie and restores the previous global settings state after each case.
| File | Description |
|---|---|
tests/phpunit/tests/general/wpDefaultEditor.php |
Adds a data-driven test covering both invalid-setting fallback outcomes. |
Review effort: Balanced
There was a problem hiding this comment.
The invalid setting reaches a real fallback. Forcing it to return tinymce failed the html case locally.
Could you add the two invalid-setting rows to test_wp_default_editor_respects_user_setting() alongside the existing valid html row? That keeps both outcomes and gives the cookie and $_updated_user_settings cleanup one home. I tried all three rows on single-site and multisite.
For the new coverage, please link an Editor component ticket. The existing test can keep its historical ticket annotation. Core’s guidance on test-only changes.
AI review · gpt-6
…user setting test. Add the two invalid setting cases to `test_wp_default_editor_respects_user_setting()` as data provider rows next to the valid `html` case, so the cookie and `$_updated_user_settings` cleanup lives in one place. See #66757. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @lancewillett. I moved the two invalid setting rows into About the ticket: |
lancewillett
left a comment
There was a problem hiding this comment.
Yes, please open an Editor ticket for this follow-up and link it in the PR body. The existing test can keep its historical #65819 annotation. The shared fixture looks good. I ran the revised class in both modes and forcing the fallback to TinyMCE failed the rich-editing-unavailable row.
AI review · gpt-6.2-astra
Trac ticket: https://core.trac.wordpress.org/ticket/66818
Description
Follow-up to 65747, which added tests for
wp_default_editor().wp_default_editor()usesuser_can_richedit()only when the user'seditorsetting holds a value other thantinymce,html, ortest. Otherwiseget_user_setting( 'editor', 'tinymce' )decides the result, becausewp_get_current_user()always returns aWP_Userobject. The tests from [65747] never reach this fallback branch.This adds two invalid setting rows to the existing
test_wp_default_editor_respects_user_setting()test, which now uses a data provider:editorsettinguser_can_richedit()htmltruehtmlinvalidtruetinymceinvalidfalsehtmlThe first row is the existing case. It now also sets
user_can_richedit()totrue, which shows that a valid setting wins even when rich editing is available. All three rows share the existing cookie and$_updated_user_settingscleanup.Testing
npm run test:php -- --filter Tests_General_WpDefaultEditor: 5 tests pass on single site and multisite.tinymce, the "invalid setting, rich editing unavailable" row failed.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Finding the untested branch, writing the test, and drafting this description. I reviewed the result.
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.
🤖 Generated with Claude Code