Skip to content
Permalink
Browse files

Allow whitespace before tags when checking HTML.

Whitespace before tags is generally of no consequence, and we should
allow it by default.

Refs #10117
  • Loading branch information...
markstory committed Feb 10, 2017
1 parent 7161157 commit b717f319172f8caa7d1203e0eafcc1535265c749
Showing with 32 additions and 2 deletions.
  1. +1 −1 src/TestSuite/TestCase.php
  2. +31 −1 tests/TestCase/TestSuite/AssertHtmlTest.php
@@ -410,7 +410,7 @@ public function assertHtml($expected, $string, $fullDebug = false)
$tags = $matches[1];
$type = 'Regex matches';
} else {
$tags = preg_quote($tags, '/');
$tags = '\s*' . preg_quote($tags, '/');
$type = 'Text equals';
}
$regex[] = [
@@ -9,7 +9,12 @@
*/
class AssertHtmlTest extends TestCase
{
public function testAssertHtmlWhitespace()
/**
* Test whitespace after HTML tags
*
* @return
*/
public function testAssertHtmlWhitespaceAfter()
{
$input = <<<HTML
<div class="wrapper">
@@ -27,6 +32,31 @@ public function testAssertHtmlWhitespace()
];
$this->assertHtml($pattern, $input);
}
/**
* Test whitespace inside HTML tags
*
* @return void
*/
public function testAssertHtmlInnerWhitespace()
{
$input = <<<HTML
<div class="widget">
<div class="widget-content">
A custom widget
</div>
</div>
HTML;
$expected = [
['div' => ['class' => 'widget']],
['div' => ['class' => 'widget-content']],
'A custom widget',
'/div',
'/div',
];
$this->assertHtml($expected, $input);
}
/**
* test assertHtml works with single and double quotes
*

0 comments on commit b717f31

Please sign in to comment.
You can’t perform that action at this time.