WordPress 6.9 introduces `assertEqualHTML()` on `WP_UnitTestCase`, a semantic HTML comparison method that replaces fragile `assertSame()` string comparisons in PHPUnit tests. Unlike `assertSame()`, it normalizes attribute order, class name order, style whitespace, tag capitalization, and HTML character references — so tests
•11m read time• From developer.wordpress.org
Table of contents
The problem with assertSame() for HTMLWhat assertEqualHTML() doesBasic usageTesting HTML API transformationsTesting block render callbacksTesting Interactivity API directive injectionUnderstanding failure outputAdding a custom failure messageWhen to keep assertSameMigration tipsResourcesSort: