123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- <?php
- require_once(dirname(__FILE__) . '/scorer.php');
- class HtmlReporter extends SimpleReporter {
- var $_character_set;
-
- function HtmlReporter($character_set = 'ISO-8859-1') {
- $this->SimpleReporter();
- $this->_character_set = $character_set;
- }
-
- function paintHeader($test_name) {
- $this->sendNoCacheHeaders();
- print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
- echo '<html style="height:100%;">';
- echo '<head>';
- echo '<title>Test Suite</title>';
- echo '</head>';
- echo '<body style="padding:0px;margin:0px;height:100%;">';
- echo '<div id="wrapper" style="width:90%;padding-left:5%;padding-bottom:10%;">';
- echo '<div id="header1">';
- echo '<div id="header3" style="min-height:100px;background:url(img/header-logo.png) no-repeat left;"><br/>';
- echo '<div id="header4" style="float:right;font-size:25px;color:#01933E;"><br/>';
- echo ''. date('Y - m - d').'';
- echo '</div>';
- echo '</div><br/>';
- echo '</div>';
- echo '<div id="header2" style="width:100%;border:2px solid #DDDDDD;">';
- echo '<div id="content2" style="background-image:url(img/bg-header4.png);background-repeat:repeat-x";>
- <h2><div style="font-size:18px;font-family:Tahoma,Geneva,sans-serif;color:#01933E;text-decoration:none;">These results showing how many functions have been tested in the code of chamilo 1.8.6.2</div></h2><br/>
- <div style="font-size:12px;font-family:Tahoma,Geneva,sans-serif;color:#01933E;">
- <p>This page showing the different types results than have been tested and showing the lines the problems.</p>
- <ol><li>This results show the amount of the tests than have been tested.</li>
- <li>This results show the amount of the tests than have passed.</li>
- <li>This results show the amount of the tests than have failed.</li>
- <li>This results show the amount of exceptions in the tests.</li></ol>
- <p>You can always find more information about simpletest on the website: http://www.lastcraft.com </p>
- <p>"Only a well software like Chamilo, is perfect when has been tested by excellent Testing Engineers".</p>
- </div></div>';
- echo '</div><br/>';
-
- }
-
-
- function sendNoCacheHeaders() {
- if (! headers_sent()) {
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
- }
- }
-
- function _getCss() {
- return ".fail { background-color: inherit; color: red; }" .
- ".pass { background-color: inherit; color: green; }" .
- " pre { background-color: lightgray; color: inherit; }";
-
- }
-
- function paintFooter($test_name) {
- $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
- echo '<div id="header5" style="background-color: '.$colour.';color: white;font-weight:bold;">';
- print "<style type=\"text/css\">\n";
- print $this->_getCss() . "\n";
- print "</style>\n";
- echo ' Test cases complete: ';
- echo $this->getTestCaseProgress() . '/' . $this->getTestCaseCount().'<br/><br/>';
- echo 'Passes: ' . $this->getPassCount() . ' ';
- echo 'Fails: ' . $this->getFailCount() . ' ';
- echo 'Exceptions: ' . $this->getExceptionCount() . ' ';
- echo '</div>';
- echo '</div>';
- echo '<div id="footer1" style= "height:6em;background-image:url(img/bg-footer.gif);background-repeat:repeat-x ">';
- echo '</div>';
- echo '</body>';
- echo '</html>';
- }
-
-
-
- function paintFail($message) {
- parent::paintFail($message);
- print "<span class=\"fail\">Fail</span>: ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . $this->_htmlEntities($message) . "<br />\n";
- }
-
- function paintError($message) {
- parent::paintError($message);
- print "<span class=\"fail\">Exception</span>: ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
- }
-
- function paintException($exception) {
- parent::paintException($exception);
- print "<span class=\"fail\">Exception</span>: ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- $message = 'Unexpected exception of type [' . get_class($exception) .
- '] with message ['. $exception->getMessage() .
- '] in ['. $exception->getFile() .
- ' line ' . $exception->getLine() . ']';
- print " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
- }
-
- function paintSkip($message) {
- parent::paintSkip($message);
- print "<span class=\"pass\">Skipped</span>: ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . $this->_htmlEntities($message) . "<br />\n";
- }
-
- function paintFormattedMessage($message) {
- print '<pre>' . $this->_htmlEntities($message) . '</pre>';
- }
-
- function _htmlEntities($message) {
- return htmlentities($message, ENT_COMPAT, $this->_character_set);
- }
- }
- class TextReporter extends SimpleReporter {
-
- function TextReporter() {
- $this->SimpleReporter();
- }
-
- function paintHeader($test_name) {
- if (! SimpleReporter::inCli()) {
- header('Content-type: text/plain');
- }
- print "$test_name\n";
- flush();
- }
-
- function paintFooter($test_name) {
- if ($this->getFailCount() + $this->getExceptionCount() == 0) {
- print "OK\n";
- } else {
- print "FAILURES!!!\n";
- }
- print "Test cases run: " . $this->getTestCaseProgress() .
- "/" . $this->getTestCaseCount() .
- ", Passes: " . $this->getPassCount() .
- ", Failures: " . $this->getFailCount() .
- ", Exceptions: " . $this->getExceptionCount() . "\n";
- }
-
- function paintFail($message) {
- parent::paintFail($message);
- print $this->getFailCount() . ") $message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- function paintError($message) {
- parent::paintError($message);
- print "Exception " . $this->getExceptionCount() . "!\n$message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- function paintException($exception) {
- parent::paintException($exception);
- $message = 'Unexpected exception of type [' . get_class($exception) .
- '] with message ['. $exception->getMessage() .
- '] in ['. $exception->getFile() .
- ' line ' . $exception->getLine() . ']';
- print "Exception " . $this->getExceptionCount() . "!\n$message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- function paintSkip($message) {
- parent::paintSkip($message);
- print "Skip: $message\n";
- }
-
- function paintFormattedMessage($message) {
- print "$message\n";
- flush();
- }
- }
- class SelectiveReporter extends SimpleReporterDecorator {
- var $_just_this_case = false;
- var $_just_this_test = false;
- var $_on;
-
- function SelectiveReporter(&$reporter, $just_this_case = false, $just_this_test = false) {
- if (isset($just_this_case) && $just_this_case) {
- $this->_just_this_case = strtolower($just_this_case);
- $this->_off();
- } else {
- $this->_on();
- }
- if (isset($just_this_test) && $just_this_test) {
- $this->_just_this_test = strtolower($just_this_test);
- }
- $this->SimpleReporterDecorator($reporter);
- }
-
- function _matchesTestCase($test_case) {
- return $this->_just_this_case == strtolower($test_case);
- }
-
- function _shouldRunTest($test_case, $method) {
- if ($this->_isOn() || $this->_matchesTestCase($test_case)) {
- if ($this->_just_this_test) {
- return $this->_just_this_test == strtolower($method);
- } else {
- return true;
- }
- }
- return false;
- }
-
- function _on() {
- $this->_on = true;
- }
-
- function _off() {
- $this->_on = false;
- }
-
- function _isOn() {
- return $this->_on;
- }
-
- function shouldInvoke($test_case, $method) {
- if ($this->_shouldRunTest($test_case, $method)) {
- return $this->_reporter->shouldInvoke($test_case, $method);
- }
- return false;
- }
-
- function paintGroupStart($test_case, $size) {
- if ($this->_just_this_case && $this->_matchesTestCase($test_case)) {
- $this->_on();
- }
- $this->_reporter->paintGroupStart($test_case, $size);
- }
-
- function paintGroupEnd($test_case) {
- $this->_reporter->paintGroupEnd($test_case);
- if ($this->_just_this_case && $this->_matchesTestCase($test_case)) {
- $this->_off();
- }
- }
- }
- class NoSkipsReporter extends SimpleReporterDecorator {
-
- function paintSkip($message) { }
- }
- ?>
|