Laravel version update
Laravel version update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Comparator package.
|
||||
* This file is part of sebastian/comparator.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -21,8 +21,9 @@ class DOMNodeComparator extends ObjectComparator
|
||||
/**
|
||||
* Returns whether the comparator can compare two values.
|
||||
*
|
||||
* @param mixed $expected The first value to compare
|
||||
* @param mixed $actual The second value to compare
|
||||
* @param mixed $expected The first value to compare
|
||||
* @param mixed $actual The second value to compare
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function accepts($expected, $actual)
|
||||
@@ -33,29 +34,22 @@ class DOMNodeComparator extends ObjectComparator
|
||||
/**
|
||||
* Asserts that two values are equal.
|
||||
*
|
||||
* @param mixed $expected The first value to compare
|
||||
* @param mixed $actual The second value to compare
|
||||
* @param float $delta The allowed numerical distance between two values to
|
||||
* consider them equal
|
||||
* @param bool $canonicalize If set to TRUE, arrays are sorted before
|
||||
* comparison
|
||||
* @param bool $ignoreCase If set to TRUE, upper- and lowercasing is
|
||||
* ignored when comparing string values
|
||||
* @throws ComparisonFailure Thrown when the comparison
|
||||
* fails. Contains information about the
|
||||
* specific errors that lead to the failure.
|
||||
* @param mixed $expected First value to compare
|
||||
* @param mixed $actual Second value to compare
|
||||
* @param float $delta Allowed numerical distance between two values to consider them equal
|
||||
* @param bool $canonicalize Arrays are sorted before comparison when set to true
|
||||
* @param bool $ignoreCase Case is ignored when set to true
|
||||
* @param array $processed List of already processed elements (used to prevent infinite recursion)
|
||||
*
|
||||
* @throws ComparisonFailure
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
|
||||
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = [])
|
||||
{
|
||||
$expectedAsString = $this->nodeToText($expected, true, $ignoreCase);
|
||||
$actualAsString = $this->nodeToText($actual, true, $ignoreCase);
|
||||
|
||||
if ($expectedAsString !== $actualAsString) {
|
||||
if ($expected instanceof DOMDocument) {
|
||||
$type = 'documents';
|
||||
} else {
|
||||
$type = 'nodes';
|
||||
}
|
||||
$type = $expected instanceof DOMDocument ? 'documents' : 'nodes';
|
||||
|
||||
throw new ComparisonFailure(
|
||||
$expected,
|
||||
@@ -63,7 +57,7 @@ class DOMNodeComparator extends ObjectComparator
|
||||
$expectedAsString,
|
||||
$actualAsString,
|
||||
false,
|
||||
sprintf("Failed asserting that two DOM %s are equal.\n", $type)
|
||||
\sprintf("Failed asserting that two DOM %s are equal.\n", $type)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -71,40 +65,23 @@ class DOMNodeComparator extends ObjectComparator
|
||||
/**
|
||||
* Returns the normalized, whitespace-cleaned, and indented textual
|
||||
* representation of a DOMNode.
|
||||
*
|
||||
* @param DOMNode $node
|
||||
* @param bool $canonicalize
|
||||
* @param bool $ignoreCase
|
||||
* @return string
|
||||
*/
|
||||
private function nodeToText(DOMNode $node, $canonicalize, $ignoreCase)
|
||||
private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase): string
|
||||
{
|
||||
if ($canonicalize) {
|
||||
$document = new DOMDocument;
|
||||
$document->loadXML($node->C14N());
|
||||
@$document->loadXML($node->C14N());
|
||||
|
||||
$node = $document;
|
||||
}
|
||||
|
||||
if ($node instanceof DOMDocument) {
|
||||
$document = $node;
|
||||
} else {
|
||||
$document = $node->ownerDocument;
|
||||
}
|
||||
$document = $node instanceof DOMDocument ? $node : $node->ownerDocument;
|
||||
|
||||
$document->formatOutput = true;
|
||||
$document->normalizeDocument();
|
||||
|
||||
if ($node instanceof DOMDocument) {
|
||||
$text = $node->saveXML();
|
||||
} else {
|
||||
$text = $document->saveXML($node);
|
||||
}
|
||||
$text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node);
|
||||
|
||||
if ($ignoreCase) {
|
||||
$text = strtolower($text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
return $ignoreCase ? $text : \strtolower($text);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user