Permalink
Browse files

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
  • Loading branch information...
1 parent 76f9317 commit 7d93c57bd32809825a4267fd0f65708df4dff944 @albertoleal albertoleal committed with markstory Jun 26, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php
@@ -248,9 +248,22 @@ public function paintFail($message, $test) {
$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";

1 comment on commit 7d93c57

Member

dereuromark commented on 7d93c57 Jul 2, 2012

I think there are some spaces in between (..$actualMsg etc) instead of tabs as indentation

Please sign in to comment.