Skip to content

Commit 33658fa

Browse files
authored
Merge pull request #3 from wptrainingteam/update/nowdoc-syntax-in-tests
Use NOWDOC syntax for multi-line expected HTML strings
2 parents 70fcae4 + a811232 commit 33658fa

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tests/RenderCardBlockTest.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class RenderCardBlockTest extends WP_UnitTestCase {
2323
* actual output. Since the render callback concatenates $content directly
2424
* with no surrounding whitespace, the expected string must do the same:
2525
* `...><p>...</p></div>` with no gaps.
26+
*
27+
* NOWDOC syntax (<<<'HTML') keeps the expected markup readable without
28+
* variable interpolation. Indented closing markers (PHP 7.3+) let the
29+
* heredoc align naturally with the surrounding code.
2630
*/
2731
public function test_card_block_renders_with_background_color(): void {
2832
$attributes = array(
@@ -38,10 +42,12 @@ public function test_card_block_renders_with_background_color(): void {
3842
// Attributes may be on separate lines for readability — that's fine.
3943
// But there must be no whitespace between > and <p>, since the actual
4044
// output has none (whitespace-only text nodes are compared as-is).
41-
$expected = '<div
45+
$expected = <<<'HTML'
46+
<div
4247
class="is-style-outlined my-custom-class wp-block-my-plugin-card"
4348
style="background-color: #f5f5f5;"
44-
><p class="wp-block-paragraph">Hello</p></div>';
49+
><p class="wp-block-paragraph">Hello</p></div>
50+
HTML;
4551

4652
$this->assertEqualHTML( $expected, $output );
4753
}

0 commit comments

Comments
 (0)