Use the diff style provided by PHPUnit in the webrunner.

Displaying actual vs expected messages when the result is an array or string.
Fixes #GH-699
This commit is contained in:
Alberto Leal 2012-06-26 00:12:54 -03:00 committed by mark_story
parent 76f93178a8
commit 7d93c57bd3

View file

@ -248,9 +248,22 @@ class CakeHtmlReporter extends CakeBaseReporter {
$trace = $this->_getStackTrace($message);
$testName = get_class($test) . '(' . $test->getName() . ')';
$failure = $message->getComparisonFailure();
if (is_object($failure)) {
$actualMsg = $message->getComparisonFailure()->getActualAsString();
$expectedMsg = $message->getComparisonFailure()->getExpectedAsString();
}
echo "<li class='fail'>\n";
echo "<span>Failed</span>";
echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString()) . "</pre></div>\n";
echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString());
if ((is_string($actualMsg) && is_string($expectedMsg)) || (is_array($actualMsg) && is_array($expectedMsg))) {
echo "<br />" . PHPUnit_Util_Diff::diff($expectedMsg, $actualMsg);
}
echo "</pre></div>\n";
echo "<div class='msg'>" . __d('cake_dev', 'Test case: %s', $testName) . "</div>\n";
echo "<div class='msg'>" . __d('cake_dev', 'Stack trace:') . '<br />' . $trace . "</div>\n";
echo "</li>\n";