Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #763

 * `assertTag()` fails to match content in CDATA sections.
  • Loading branch information...
commit 2c67e52445416bb7c14046b432acd7eb79e4e612 1 parent 82335c2
@whatthejeff whatthejeff authored
View
3  PHPUnit/Util/XML.php
@@ -907,7 +907,8 @@ protected static function getNodeText(DOMNode $node)
$result = '';
foreach ($node->childNodes as $childNode) {
- if ($childNode->nodeType === XML_TEXT_NODE) {
+ if ($childNode->nodeType === XML_TEXT_NODE ||
+ $childNode->nodeType === XML_CDATA_SECTION_NODE) {
$result .= trim($childNode->data) . ' ';
} else {
$result .= self::getNodeText($childNode);
View
23 Tests/Framework/AssertTest.php
@@ -2838,6 +2838,29 @@ public function testAssertTagRegexpContentFalse()
/**
* @covers PHPUnit_Framework_Assert::assertTag
*/
+ public function testAssertTagCdataContentTrue()
+ {
+ $matcher = array('tag' => 'script',
+ 'content' => 'alert(\'Hello, world!\');');
+ $this->assertTag($matcher, $this->html);
+ }
+
+ /**
+ * @covers PHPUnit_Framework_Assert::assertTag
+ * @expectedException PHPUnit_Framework_AssertionFailedError
+ */
+ public function testAssertTagCdataontentFalse()
+ {
+ $matcher = array('tag' => 'script',
+ 'content' => 'asdf');
+ $this->assertTag($matcher, $this->html);
+ }
+
+
+
+ /**
+ * @covers PHPUnit_Framework_Assert::assertTag
+ */
public function testAssertTagAttributesTrueA()
{
$matcher = array('tag' => 'span',
View
2  Tests/_files/SelectorAssertionsFixture.html
@@ -4,7 +4,7 @@
<head>
<title>Login</title>
<link type="text/css" rel="Stylesheet" href="/stylesheets/screen.css">
- <script type="text/javaScript" src="/javascripts/login.js">
+ <script type="text/javascript">alert('Hello, world!');</script>
</head>
<body id="login">
<ul id="my_ul" class="my_ul_class">
Please sign in to comment.
Something went wrong with that request. Please try again.