Skip to content

Commit

Permalink
Use the diff style provided by PHPUnit in the webrunner.
Browse files Browse the repository at this point in the history
Displaying actual vs expected messages when the result is an array or string.
Fixes #GH-699
  • Loading branch information
albertoleal authored and markstory committed Jun 26, 2012
1 parent 76f9317 commit 7d93c57
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

1 comment on commit 7d93c57

@dereuromark
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.