Source for file reporter.php
Documentation is available at reporter.php
* base include file for SimpleTest
* @version $Id: reporter.php 1702 2008-03-25 00:08:04Z lastcraft $
* include other SimpleTest class files
require_once(dirname(__FILE__
) .
'/scorer.php');
* Sample minimal test displayer. Generates only
* failure messages and a pass count.
* Does nothing yet. The first output will
* be sent on the first test start. For use
* 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.
print
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
print
"<html>\n<head>\n<title>$test_name</title>\n";
print
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" .
print
"<style type=\"text/css\">\n";
print
"</head>\n<body>\n";
print
"<h1>$test_name</h1>\n";
* Send the headers necessary to ensure the page is
* reloaded on every request. Otherwise you could be
* scratching your head over out of date test data.
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);
* Paints the CSS. Add additional styles here.
* @return string CSS code as text.
return ".fail { background-color: inherit; color: red; }" .
".pass { background-color: inherit; color: green; }" .
" pre { background-color: lightgray; color: inherit; }";
* Paints the end of the test with a summary of
* the passes and failures.
* @param string $test_name Name class of test.
print
"padding: 8px; margin-top: 1em; background-color: $colour; color: white;";
print
" test cases complete:\n";
print
"<strong>" .
$this->getPassCount() .
"</strong> passes, ";
print
"<strong>" .
$this->getFailCount() .
"</strong> fails and ";
print
"</body>\n</html>\n";
* Paints the test failure with a breadcrumbs
* trail of the nesting test suites below the
* @param string $message Failure message displayed in
* the context of the other tests.
parent::paintFail($message);
print
"<span class=\"fail\">Fail</span>: ";
print
implode(" -> ", $breadcrumb);
* @param string $message Message is ignored.
parent::paintError($message);
print
"<span class=\"fail\">Exception</span>: ";
print
implode(" -> ", $breadcrumb);
print
" -> <strong>" .
$this->_htmlEntities($message) .
"</strong><br />\n";
* Paints a PHP exception.
* @param Exception $exception Exception to display.
parent::paintException($exception);
print
"<span class=\"fail\">Exception</span>: ";
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";
* Prints the message for skipping tests.
* @param string $message Text of skip condition.
parent::paintSkip($message);
print
"<span class=\"pass\">Skipped</span>: ";
print
implode(" -> ", $breadcrumb);
* Paints formatted text such as dumped variables.
* @param string $message Text to show.
* Character set adjusted entity conversion.
* @param string $message Plain text or Unicode message.
* @return string Browser readable message.
* Sample minimal test displayer. Generates only
* failure messages and a pass count. For command
* line use. I've tried to make it look like JUnit,
* but I wanted to output the errors as they arrived
* which meant dropping the dots.
* Does nothing yet. The first output will
* be sent on the first test start.
* @param string $test_name Name class of test.
header('Content-type: text/plain');
* Paints the end of the test with a summary of
* the passes and failures.
* @param string $test_name Name class of test.
* Paints the test failure as a stack trace.
* @param string $message Failure message displayed in
* the context of the other tests.
parent::paintFail($message);
* Paints a PHP error or exception.
* @param string $message Message to be shown.
parent::paintError($message);
* Paints a PHP error or exception.
* @param Exception $exception Exception to describe.
parent::paintException($exception);
$message =
'Unexpected exception of type [' .
get_class($exception) .
'] with message ['.
$exception->getMessage() .
'] in ['.
$exception->getFile() .
' line ' .
$exception->getLine() .
']';
* Prints the message for skipping tests.
* @param string $message Text of skip condition.
parent::paintSkip($message);
print
"Skip: $message\n";
* Paints formatted text such as dumped variables.
* @param string $message Text to show.
* Runs just a single test group, a single case or
* even a single test within that case.
* Selects the test case or group to be run,
* and optionally a specific test.
* @param SimpleScorer $reporter Reporter to receive events.
* @param string $just_this_case Only this case or group will run.
* @param string $just_this_test Only this test method will run.
function SelectiveReporter(&$reporter, $just_this_case =
false, $just_this_test =
false) {
if (isset
($just_this_case) &&
$just_this_case) {
if (isset
($just_this_test) &&
$just_this_test) {
* Compares criteria to actual the case/group name.
* @param string $test_case The incoming test.
* @return boolean True if matched.
* Compares criteria to actual the test name. If no
* name was specified at the beginning, then all tests
* @param string $method The incoming test method.
* @return boolean True if matched.
* Switch on testing for the group or subgroup.
* Switch off testing for the group or subgroup.
* Is this group actually being tested?
* @return boolean True if the current test group is active.
* Veto everything that doesn't match the method wanted.
* @param string $test_case Name of test case.
* @param string $method Name of test method.
* @return boolean True if test should be run.
return $this->_reporter->shouldInvoke($test_case, $method);
* Paints the start of a group test.
* @param string $test_case Name of test or other label.
* @param integer $size Number of test cases starting.
$this->_reporter->paintGroupStart($test_case, $size);
* Paints the end of a group test.
* @param string $test_case Name of test or other label.
* Suppresses skip messages.
* @param string $message Text of skip condition.
Documentation generated on Sun, 04 May 2008 09:22:01 -0500 by phpDocumentor 1.3.0