mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Making the HTML Test reporter look a little more aestheticly pleasing.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6798 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
925e022e4f
commit
285a3af40a
3 changed files with 186 additions and 37 deletions
|
@ -32,46 +32,184 @@
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class CakeHtmlReporter extends HtmlReporter {
|
class CakeHtmlReporter extends SimpleReporter {
|
||||||
/**
|
var $_character_set;
|
||||||
* Does nothing yet. The first output will
|
var $_show_passes = false;
|
||||||
* be sent on the first test start. For use
|
|
||||||
* by a web browser.
|
/**
|
||||||
* @access public
|
* Does nothing yet. The first output will
|
||||||
*/
|
* be sent on the first test start. For use
|
||||||
function CakeHtmlReporter($characterSet = 'UTF-8') {
|
* by a web browser.
|
||||||
parent::HtmlReporter($characterSet);
|
* @access public
|
||||||
}
|
*/
|
||||||
/**
|
function CakeHtmlReporter($character_set = 'ISO-8859-1') {
|
||||||
* Paints the top of the web page setting the
|
if (isset($_GET['show_passes']) && $_GET['show_passes']) {
|
||||||
* title to the name of the starting test.
|
$this->_show_passes = true;
|
||||||
* @param string $test_name Name class of test.
|
}
|
||||||
* @access public
|
$this->SimpleReporter();
|
||||||
*/
|
$this->_character_set = $character_set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints the top of the web page setting the
|
||||||
|
* title to the name of the starting test.
|
||||||
|
* @param string $test_name Name class of test.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
function paintHeader($testName) {
|
function paintHeader($testName) {
|
||||||
$this->sendNoCacheHeaders();
|
$this->sendNoCacheHeaders();
|
||||||
$baseUrl = BASE;
|
$baseUrl = BASE;
|
||||||
print "<h2>$testName</h2>\n";
|
print "<h2>$testName</h2>\n";
|
||||||
|
print "<ul class='tests'>\n";
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Paints the end of the test with a summary of
|
/**
|
||||||
* the passes and failures.
|
* Send the headers necessary to ensure the page is
|
||||||
* @param string $test_name Name class of test.
|
* reloaded on every request. Otherwise you could be
|
||||||
* @access public
|
* scratching your head over out of date test data.
|
||||||
*
|
* @access public
|
||||||
*/
|
* @static
|
||||||
function paintFooter($testName) {
|
*/
|
||||||
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
function sendNoCacheHeaders() {
|
||||||
print "<div style=\"";
|
if (! headers_sent()) {
|
||||||
print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||||
print "\">";
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||||
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||||
print " test cases complete:\n";
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
header("Pragma: no-cache");
|
||||||
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
}
|
||||||
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
}
|
||||||
print "</div>\n";
|
|
||||||
|
/**
|
||||||
|
* Paints the end of the test with a summary of
|
||||||
|
* the passes and failures.
|
||||||
|
* @param string $test_name Name class of test.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintFooter($test_name) {
|
||||||
|
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
||||||
|
print "</ul>\n";
|
||||||
|
print "<div style=\"";
|
||||||
|
print "padding: 8px; margin: 1em 0; background-color: $colour; color: white;";
|
||||||
|
print "\">";
|
||||||
|
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
||||||
|
print " test cases complete:\n";
|
||||||
|
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
||||||
|
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
||||||
|
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
||||||
|
print "</div>\n";
|
||||||
|
print "</body>\n</html>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints the test failure with a breadcrumbs
|
||||||
|
* trail of the nesting test suites below the
|
||||||
|
* top level test.
|
||||||
|
* @param string $message Failure message displayed in
|
||||||
|
* the context of the other tests.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintFail($message) {
|
||||||
|
parent::paintFail($message);
|
||||||
|
print "<li class='fail'>\n";
|
||||||
|
print "<span>Failed</span>";
|
||||||
|
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
|
array_shift($breadcrumb);
|
||||||
|
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints the test pass with a breadcrumbs
|
||||||
|
* trail of the nesting test suites below the
|
||||||
|
* top level test.
|
||||||
|
* @param string $message Pass message displayed in
|
||||||
|
* the context of the other tests.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintPass($message) {
|
||||||
|
parent::paintPass($message);
|
||||||
|
if ($this->_show_passes) {
|
||||||
|
print "<li class='pass'>\n";
|
||||||
|
print "<span>Passed</span> ";
|
||||||
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
|
array_shift($breadcrumb);
|
||||||
|
print implode(" -> ", $breadcrumb);
|
||||||
|
print "<br />" . $this->_htmlEntities($message) . "\n";
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints a PHP error.
|
||||||
|
* @param string $message Message is ignored.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintError($message) {
|
||||||
|
parent::paintError($message);
|
||||||
|
print "<li class='fail'>\n";
|
||||||
|
print "<span>Error</span>";
|
||||||
|
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
|
array_shift($breadcrumb);
|
||||||
|
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints a PHP exception.
|
||||||
|
* @param Exception $exception Exception to display.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintException($exception) {
|
||||||
|
parent::paintException($exception);
|
||||||
|
print "<li class='fail'>\n";
|
||||||
|
print "<span>Exception</span>";
|
||||||
|
$message = 'Unexpected exception of type [' . get_class($exception) .
|
||||||
|
'] with message ['. $exception->getMessage() .
|
||||||
|
'] in ['. $exception->getFile() .
|
||||||
|
' line ' . $exception->getLine() . ']';
|
||||||
|
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
|
array_shift($breadcrumb);
|
||||||
|
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
|
print "</li>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the message for skipping tests.
|
||||||
|
* @param string $message Text of skip condition.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintSkip($message) {
|
||||||
|
parent::paintSkip($message);
|
||||||
|
print "<li class='skipped'>\n";
|
||||||
|
print "<span>Skipped</span> ";
|
||||||
|
print $this->_htmlEntities($message);
|
||||||
|
print "</li>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paints formatted text such as dumped variables.
|
||||||
|
* @param string $message Text to show.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintFormattedMessage($message) {
|
||||||
|
print '<pre>' . $this->_htmlEntities($message) . '</pre>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Character set adjusted entity conversion.
|
||||||
|
* @param string $message Plain text or Unicode message.
|
||||||
|
* @return string Browser readable message.
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function _htmlEntities($message) {
|
||||||
|
return htmlentities($message, ENT_COMPAT, $this->_character_set);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -36,9 +36,20 @@
|
||||||
h3 {font-size: 170%; padding-top: 1em}
|
h3 {font-size: 170%; padding-top: 1em}
|
||||||
a {font-size: 120%}
|
a {font-size: 120%}
|
||||||
li {line-height: 140%}
|
li {line-height: 140%}
|
||||||
.fail { background-color: inherit; color: red; }
|
.test-menu {float:left; margin-right: 24px;}
|
||||||
.test-menu {float:left; margin-right: 20px;}
|
|
||||||
.test-results {float:left; width: 67%;}
|
.test-results {float:left; width: 67%;}
|
||||||
|
ul.tests {margin: 0; font-size:12px;}
|
||||||
|
ul.tests li {list-style: none; margin: 14px 0; padding-left: 20px;}
|
||||||
|
ul.tests li {background: url("http://www.famfamfam.com/lab/icons/silk/icons/accept.png") no-repeat;}
|
||||||
|
ul.tests li.error {background: url("http://www.famfamfam.com/lab/icons/silk/icons/exclamation.png") no-repeat;}
|
||||||
|
ul.tests li.fail {background: url("http://www.famfamfam.com/lab/icons/silk/icons/cancel.png") no-repeat;}
|
||||||
|
ul.tests li.skipped {background: url("http://www.famfamfam.com/lab/icons/silk/icons/information.png") no-repeat;}
|
||||||
|
ul.tests li span { font-size:14px; text-transform: uppercase; display:block; color: black; font-weight: bold; }
|
||||||
|
ul.tests li.pass span, ul.tests li.skipped span { display:inline;}
|
||||||
|
ul.tests li.fail span { color: red; }
|
||||||
|
ul.tests li.pass span { color: green; }
|
||||||
|
ul.tests li div { margin: 5px 0 8px 0; }
|
||||||
|
ul.tests li div.msg { font-weight: bold; }
|
||||||
#content {overflow: auto}
|
#content {overflow: auto}
|
||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
|
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
|
||||||
|
|
|
@ -443,7 +443,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
$show = '?show=cases';
|
$show = '?show=cases';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a></p>\n";
|
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a> | <a href='" . $_SERVER['REQUEST_URI'] . "&show_passes=1'>Show Passes</a></p>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue