Skip to content

Commit 9ed93eb

Browse files
committed
assertHtml() should accept whitespace before a closing tag.
Allow any amount of whitespace between tags. Refs #10117
1 parent 41b6e4b commit 9ed93eb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/TestSuite/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function assertHtml($expected, $string, $fullDebug = false)
401401
}
402402
$regex[] = [
403403
sprintf('%sClose %s tag', $prefix[0], substr($tags, strlen($match[0]))),
404-
sprintf('%s<[\s]*\/[\s]*%s[\s]*>[\n\r]*', $prefix[1], substr($tags, strlen($match[0]))),
404+
sprintf('%s\s*<[\s]*\/[\s]*%s[\s]*>[\n\r]*', $prefix[1], substr($tags, strlen($match[0]))),
405405
$i,
406406
];
407407
continue;

tests/TestCase/TestSuite/AssertHtmlTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99
*/
1010
class AssertHtmlTest extends TestCase
1111
{
12+
public function testAssertHtmlWhitespace()
13+
{
14+
$input = <<<HTML
15+
<div class="wrapper">
16+
<h4 class="widget-title">Popular tags
17+
<i class="i-icon"></i>
18+
</h4>
19+
</div>
20+
HTML;
21+
$pattern = [
22+
'div' => ['class' => 'wrapper'],
23+
'h4' => ['class' => 'widget-title'], 'Popular tags',
24+
'i' => ['class' => 'i-icon'], '/i',
25+
'/h4',
26+
'/div'
27+
];
28+
$this->assertHtml($pattern, $input);
29+
}
1230
/**
1331
* test assertHtml works with single and double quotes
1432
*

0 commit comments

Comments
 (0)