Repository navigation
Tests: Cover format_to_edit() - #15317
devmuhib009 wants to merge 1 commit 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 identified for this test-only addition of PHPUnit coverage for format_to_edit().
No open issues 🎉
What changed in this PR
Adds PHPUnit coverage for WordPress’s format_to_edit() function, addressing Trac ticket #65819 without changing production behavior.
Changes:
- Tests textarea escaping with both the default and explicit
falserich-text argument. - Verifies that rich-text mode leaves content unescaped.
- Confirms that the
format_to_editfilter modifies content before escaping.
| File | Description |
|---|---|
tests/phpunit/tests/formatting/formatToEdit.php |
Adds three tests covering escaping, rich-text mode, and filter behavior. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
I left a few small notes inline.
AI Review: Opus 5.5
| $expected = '<b>"hello" & 'world'</b>'; | ||
|
|
||
| $this->assertSame( $expected, format_to_edit( $content ) ); | ||
| $this->assertSame( $expected, format_to_edit( $content, false ) ); |
There was a problem hiding this comment.
This one looks like a small coverage gap: esc_textarea() differs from esc_html() by double-encoding existing entities, and the class still passes if the function switches to esc_html(). Could you add a case like $this->assertSame( 'AT&amp;T', format_to_edit( 'AT&T' ) );?
lancewillett
left a comment
There was a problem hiding this comment.
Reviewed the changed code against the implementation and existing coverage; no blocking issue found.
Validated with the related behavioral coverage patches on current trunk: 35 tests / 43 assertions in each of single-site and multisite, randomized seed 1101. No failures, errors, warnings, or skips.
Current-head CI and Copilot review checked.
AI review · gpt-6
Verify the HTML escaping and format handling in `format_to_edit()`. Developed in: #15317 Props devmuhib, huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65174 602fd350-edb4-49c9-b593-d223f7449a82
Verify the HTML escaping and format handling in `format_to_edit()`. Developed in: WordPress/wordpress-develop#15317 Props devmuhib, huzaifaalmesbah. See #65819. Built from https://develop.svn.wordpress.org/trunk@65174 git-svn-id: http://core.svn.wordpress.org/trunk@64323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15317 landed in https://core.trac.wordpress.org/changeset/65174 |
Trac ticket: https://core.trac.wordpress.org/ticket/65819
This PR adds unit tests for
format_to_edit()covering:$rich_textis false (default)$rich_textis trueformat_to_editfilter hook