[wp-trac] [WordPress Trac] #60705: Test tool and unit test improvements for 6.6

WordPress Trac noreply at wordpress.org
Thu Mar 21 15:46:26 UTC 2024


#60705: Test tool and unit test improvements for 6.6
--------------------------------------+---------------------
 Reporter:  SergeyBiryukov            |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  6.6
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------

Comment (by SergeyBiryukov):

 In [changeset:"57861" 57861]:
 {{{
 #!CommitTicketReference repository="" revision="57861"
 Tests: Remove unnecessary use of `utf8_encode()` in KSES tests.

 One of the tests for the `wp_kses_xml_named_entities()` function used
 `utf8_encode( chr( 160 ) )` to set an expectation of a Unicode character
 for a non-breaking space.

 It is understandable that this expectation was previously set this way, as
 it is not possible for a developer to distinguish between a ''breaking''
 space and a ''non-breaking'' space visually, so the chances of the test
 accidentally breaking on an incorrect save when the plain Unicode
 character would be used, was high.

 However, the `utf8_encode()` function is deprecated as of PHP 8.2, and its
 use needs to be removed from the WP codebase.

 PHP 7.0 has introduced [https://wiki.php.net/rfc/unicode_escape Unicode
 escape sequences], which allows to create a text string using Unicode
 characters referenced by their codepoint. By switching the test case to
 provide the test expectation using a Unicode escape sequence, we remove
 the use of the deprecated PHP function and still preserve the safeguard
 against the test accidentally breaking.

 Follow-up to [52229].

 Props jrf, afercia, poena, SergeyBiryukov.
 See #55603, #60705.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60705#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list