Skip to content

Commit

Permalink
assertHtml() should accept whitespace before a closing tag.
Browse files Browse the repository at this point in the history
Allow any amount of whitespace between tags.

Refs #10117
  • Loading branch information
markstory committed Jan 28, 2017
1 parent 41b6e4b commit 9ed93eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TestSuite/TestCase.php
Expand Up @@ -401,7 +401,7 @@ public function assertHtml($expected, $string, $fullDebug = false)
}
$regex[] = [
sprintf('%sClose %s tag', $prefix[0], substr($tags, strlen($match[0]))),
sprintf('%s<[\s]*\/[\s]*%s[\s]*>[\n\r]*', $prefix[1], substr($tags, strlen($match[0]))),
sprintf('%s\s*<[\s]*\/[\s]*%s[\s]*>[\n\r]*', $prefix[1], substr($tags, strlen($match[0]))),
$i,
];
continue;
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/TestSuite/AssertHtmlTest.php
Expand Up @@ -9,6 +9,24 @@
*/
class AssertHtmlTest extends TestCase
{
public function testAssertHtmlWhitespace()
{
$input = <<<HTML
<div class="wrapper">
<h4 class="widget-title">Popular tags
<i class="i-icon"></i>
</h4>
</div>
HTML;
$pattern = [
'div' => ['class' => 'wrapper'],
'h4' => ['class' => 'widget-title'], 'Popular tags',
'i' => ['class' => 'i-icon'], '/i',
'/h4',
'/div'
];
$this->assertHtml($pattern, $input);
}
/**
* test assertHtml works with single and double quotes
*
Expand Down

0 comments on commit 9ed93eb

Please sign in to comment.