Asserts that two values are equal.
mixed $expected The first value to compare:
mixed $actual The second value to compare:
float $delta The allowed numerical distance between two values to: consider them equal
bool $canonicalize If set to TRUE, arrays are sorted before: comparison
bool $ignoreCase If set to TRUE, upper- and lowercasing is: ignored when comparing string values
PHPUnit_Framework_ComparisonFailure Thrown when the comparison fails. Contains information about the specific errors that lead to the failure.
Overrides PHPUnit_Framework_Comparator::assertEquals
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE) {
$expectedToCompare = $expected;
$actualToCompare = $actual;
// always compare as strings to avoid strange behaviour
// otherwise 0 == 'Foobar'
if (is_string($expected) || is_string($actual)) {
$expectedToCompare = (string) $expectedToCompare;
$actualToCompare = (string) $actualToCompare;
if ($ignoreCase) {
$expectedToCompare = strtolower($expectedToCompare);
$actualToCompare = strtolower($actualToCompare);
}
}
if ($expectedToCompare != $actualToCompare) {
if (is_string($expected) && is_string($actual)) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, PHPUnit_Util_Type::export($expected), PHPUnit_Util_Type::export($actual), FALSE, 'Failed asserting that two strings are equal.');
}
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, '', '', FALSE, sprintf('Failed asserting that %s matches expected %s.', PHPUnit_Util_Type::export($actual), PHPUnit_Util_Type::export($expected)));
}
}