@@ -16,6 +16,13 @@ class RenderCardBlockTest extends WP_UnitTestCase {
1616 * Note: assertEqualHTML normalizes class order — so it doesn't matter
1717 * whether add_class() puts "is-style-outlined" before or after
1818 * "wp-block-my-plugin-card".
19+ *
20+ * Whitespace tip: attributes can span multiple lines (they are part of the
21+ * opening tag, not text nodes). But whitespace *between* elements — like a
22+ * newline between `>` and `<p>` — creates a text node that must match the
23+ * actual output. Since the render callback concatenates $content directly
24+ * with no surrounding whitespace, the expected string must do the same:
25+ * `...><p>...</p></div>` with no gaps.
1926 */
2027 public function test_card_block_renders_with_background_color (): void {
2128 $ attributes = array (
@@ -28,14 +35,13 @@ public function test_card_block_renders_with_background_color(): void {
2835 $ output = my_plugin_render_card_block ( $ attributes , $ inner_content );
2936
3037 // Attribute order and class order don't need to match exactly.
31- $ expected = '
32- <div
33- class="is-style-outlined my-custom-class wp-block-my-plugin-card"
34- style="background-color: #f5f5f5;"
35- >
36- <p class="wp-block-paragraph">Hello</p>
37- </div>
38- ' ;
38+ // Attributes may be on separate lines for readability — that's fine.
39+ // But there must be no whitespace between > and <p>, since the actual
40+ // output has none (whitespace-only text nodes are compared as-is).
41+ $ expected = '<div
42+ class="is-style-outlined my-custom-class wp-block-my-plugin-card"
43+ style="background-color: #f5f5f5;"
44+ ><p class="wp-block-paragraph">Hello</p></div> ' ;
3945
4046 $ this ->assertEqualHTML ( $ expected , $ output );
4147 }
0 commit comments