Skip to content

Commit

Permalink
Fix "ignore case" in DOMNodeComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
daltones authored and sebastianbergmann committed May 23, 2018
1 parent 26ca1ea commit feeec2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/DOMNodeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase)

$text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node);

return $ignoreCase ? $text : \strtolower($text);
return $ignoreCase ? \strtolower($text) : $text;
}
}
20 changes: 18 additions & 2 deletions tests/DOMNodeComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public function assertEqualsSucceedsProvider()
$this->createDOMDocument("<root>\n <child/>\n</root>"),
$this->createDOMDocument('<root><child/></root>')
],
[
$this->createDOMDocument('<Root></Root>'),
$this->createDOMDocument('<root></root>'),
$ignoreCase = true
]
];
}

Expand All @@ -98,6 +103,14 @@ public function assertEqualsFailsProvider()
[
$this->createDOMDocument('<foo> bar </foo>'),
$this->createDOMDocument('<foo> bir </foo>')
],
[
$this->createDOMDocument('<Root></Root>'),
$this->createDOMDocument('<root></root>')
],
[
$this->createDOMDocument('<root> bar </root>'),
$this->createDOMDocument('<root> BAR </root>')
]
];
}
Expand Down Expand Up @@ -136,13 +149,16 @@ public function testAcceptsFails($expected, $actual)
*
* @param mixed $expected
* @param mixed $actual
* @param bool $ignoreCase
*/
public function testAssertEqualsSucceeds($expected, $actual)
public function testAssertEqualsSucceeds($expected, $actual, $ignoreCase = false)
{
$exception = null;

try {
$this->comparator->assertEquals($expected, $actual);
$delta = 0.0;
$canonicalize = false;
$this->comparator->assertEquals($expected, $actual, $delta, $canonicalize, $ignoreCase);
} catch (ComparisonFailure $exception) {
}

Expand Down

0 comments on commit feeec2d

Please sign in to comment.