[wp-trac] [WordPress Trac] #63527: Tests: Add test assertion to compare HTML for equivalence

WordPress Trac noreply at wordpress.org
Wed Jul 16 15:57:48 UTC 2025


#63527: Tests: Add test assertion to compare HTML for equivalence
--------------------------------------+------------------------------
 Reporter:  Bernhard Reiter           |       Owner:  Bernhard Reiter
     Type:  enhancement               |      Status:  closed
 Priority:  normal                    |   Milestone:  6.9
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by jonsurrell):

 Replying to [comment:9 SirLouen]:
 > @bernhard-reiter
 > I wondered why `CDATA` wrapper couldn't be dealt as it was being in
 `parse_markup_fragment` for a cleaner markup?

 Are you asking about the behavior of `assertEqualHTML` in general or
 specifically for the script tests that were modified in [60295]?


 Speaking generally, the goal with `assertEqualHTML` is to compare HTML
 inputs and present differences in a way that's easy for humans to parse.
 It should what the input actually mean when processed (like a browser
 would). To that end, it's important that it faithfully represent the
 inputs so it can be trusted in tests.

 Specifically for the modified tests, this is stylistic to some extent, but
 even here I believe there's value in faithfully representing the
 expectations.
 [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/dependencies/scripts.php?rev=60294#L3038
 Before, the input was parsed as XML and some string replacement was used
 to remove the CDATA comments] before comparing. On its own, this isn't
 likely harmful but it does hide some of what's actually happening. This
 ties in nicely with #59883 and non-HTML5 support.

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


More information about the wp-trac mailing list