Skip to content

Commit

Permalink
Improve comparison of DOMNode objects
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 23, 2014
1 parent 6a604dd commit 7dadedf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Framework/Comparator/DOMNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ public function accepts($expected, $actual)
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
{
$expectedXML = $expected->C14N();
$actualXML = $actual->C14N();
$expectedAsString = $this->domToText($expected);
$actualAsString = $this->domToText($actual);

if ($ignoreCase === true) {
$expectedXML = strtolower($expectedXML);
$actualXML = strtolower($actualXML);
$expectedAsString = strtolower($expectedAsString);
$actualAsString = strtolower($actualAsString);
}

if ($expectedXML !== $actualXML) {
if ($expectedAsString !== $actualAsString) {
if ($expected instanceof DOMDocument) {
$type = 'documents';
} else {
Expand All @@ -103,8 +103,8 @@ public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = f
throw new PHPUnit_Framework_ComparisonFailure(
$expected,
$actual,
$this->domToText($expected),
$this->domToText($actual),
$expectedAsString,
$actualAsString,
false,
sprintf('Failed asserting that two DOM %s are equal.', $type)
);
Expand Down

0 comments on commit 7dadedf

Please sign in to comment.