Source for file xml.php
Documentation is available at xml.php
* base include file for SimpleTest
* @version $Id: xml.php 1723 2008-04-08 00:34:10Z lastcraft $
* include other SimpleTest class files
require_once(dirname(__FILE__
) .
'/scorer.php');
* Creates the XML needed for remote communication
* Sets up indentation and namespace.
* @param string $namespace Namespace to add to each tag.
* @param string $indent Indenting to add on each nesting.
function XmlReporter($namespace =
false, $indent =
' ') {
$this->_namespace =
($namespace ?
$namespace .
':' :
'');
* Calculates the pretty printing indent level
* from the current level of nesting.
* @param integer $offset Extra indenting level.
* @return string Leading space.
* Converts character string to parsed XML
* @param string text Unparsed character data.
* @return string Parsed character data.
array('&', '<', '>', '"', '\''),
array('&', '<', '>', '"', '''),
* Paints the start of a group test.
* @param string $test_name Name of test that is starting.
* @param integer $size Number of test cases starting.
print
"<" .
$this->_namespace .
"group size=\"$size\">\n";
* Paints the end of a group test.
* @param string $test_name Name of test that is ending.
* Paints the start of a test case.
* @param string $test_name Name of test that is starting.
* Paints the end of a test case.
* @param string $test_name Name of test that is ending.
* Paints the start of a test method.
* @param string $test_name Name of test that is starting.
* Paints the end of a test method.
* @param string $test_name Name of test that is ending.
* @param integer $progress Number of test cases ending.
* @param string $message Message to encode.
parent::paintPass($message);
* @param string $message Message to encode.
parent::paintFail($message);
* @param string $message Message to encode.
parent::paintError($message);
* Paints exception as XML.
* @param Exception $exception Exception to encode.
parent::paintException($exception);
$message =
'Unexpected exception of type [' .
get_class($exception) .
'] with message ['.
$exception->getMessage() .
'] in ['.
$exception->getFile() .
' line ' .
$exception->getLine() .
']';
* Paints the skipping message and tag.
* @param string $message Text to display in skip tag.
parent::paintSkip($message);
* Paints a simple supplementary message.
* @param string $message Text to display.
parent::paintMessage($message);
* Paints a formatted ASCII message such as a
* @param string $message Text to display.
parent::paintFormattedMessage($message);
print
"<![CDATA[$message]]>";
* Serialises the event object.
* @param string $type Event type as text.
* @param mixed $payload Message or object.
parent::paintSignal($type, $payload);
print
"<" .
$this->_namespace .
"signal type=\"$type\">";
print
"<![CDATA[" .
serialize($payload) .
"]]>";
* Paints the test document header.
* @param string $test_name First test top level
header('Content-type: text/xml');
print
"<?xml version=\"1.0\"";
"=\"www.lastcraft.com/SimpleTest/Beta3/Report\"";
* Paints the test document footer.
* @param string $test_name The top level test.
* Accumulator for incoming tag. Holds the
* incoming test structure information for
* later dispatch to the reporter.
* Sets the basic test information except
* @param hash $attributes Name value pairs.
* Sets the test case/method name.
* @param string $name Name of test.
* @return string Name of test.
* Accessor for attributes.
* @return hash All attributes.
* Accumulator for incoming method tag. Holds the
* incoming test structure information for
* later dispatch to the reporter.
* Sets the basic test information except
* @param hash $attributes Name value pairs.
* Signals the appropriate start event on the
* @param SimpleReporter $listener Target for events.
$listener->paintMethodStart($this->getName());
* Signals the appropriate end event on the
* @param SimpleReporter $listener Target for events.
$listener->paintMethodEnd($this->getName());
* Accumulator for incoming case tag. Holds the
* incoming test structure information for
* later dispatch to the reporter.
* Sets the basic test information except
* @param hash $attributes Name value pairs.
* Signals the appropriate start event on the
* @param SimpleReporter $listener Target for events.
$listener->paintCaseStart($this->getName());
* Signals the appropriate end event on the
* @param SimpleReporter $listener Target for events.
$listener->paintCaseEnd($this->getName());
* Accumulator for incoming group tag. Holds the
* incoming test structure information for
* later dispatch to the reporter.
* Sets the basic test information except
* @param hash $attributes Name value pairs.
* Signals the appropriate start event on the
* @param SimpleReporter $listener Target for events.
* Signals the appropriate end event on the
* @param SimpleReporter $listener Target for events.
$listener->paintGroupEnd($this->getName());
* The size in the attributes.
* @return integer Value of size attribute or zero.
if (isset
($attributes['SIZE'])) {
return (integer)
$attributes['SIZE'];
* Parser for importing the output of the XmlReporter.
* Dispatches that output to another reporter.
* Loads a listener with the SimpleReporter
* @param SimpleReporter $listener Listener of tag events.
* Parses a block of XML sending the results to
* @param string $chunk Block of text to read.
* @return boolean True if valid XML.
* Sets up expat as the XML parser.
* @return resource Expat handle.
* Opens a new test nesting level.
* @return NestedXmlTag The group, case or method tag
function _pushNestingTag($nested) {
* Accessor for current test structure tag.
* @return NestedXmlTag The group, case or method tag
function &_getCurrentNestingTag() {
* @return NestedXmlTag The group, case or method tag
function _popNestingTag() {
* Test if tag is a leaf node with only text content.
* @param string $tag XML tag name.
* @return @boolean True if leaf, false if nesting.
'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'SKIP', 'MESSAGE', 'FORMATTED', 'SIGNAL'));
* Handler for start of event element.
* @param resource $expat Parser handle.
* @param string $tag Element name.
* @param hash $attributes Name value pairs.
* Attributes without content
} elseif ($tag ==
'CASE') {
} elseif ($tag ==
'TEST') {
* @param resource $expat Parser handle.
* @param string $tag Element name.
if (in_array($tag, array('GROUP', 'CASE', 'TEST'))) {
$nesting_tag =
$this->_popNestingTag();
} elseif ($tag ==
'NAME') {
$nesting_tag =
&$this->_getCurrentNestingTag();
} elseif ($tag ==
'PASS') {
} elseif ($tag ==
'FAIL') {
} elseif ($tag ==
'EXCEPTION') {
} elseif ($tag ==
'SKIP') {
} elseif ($tag ==
'SIGNAL') {
} elseif ($tag ==
'MESSAGE') {
} elseif ($tag ==
'FORMATTED') {
* Content between start and end elements.
* @param resource $expat Parser handle.
* @param string $text Usually output messages.
* XML and Doctype handler. Discards all such content.
* @param resource $expat Parser handle.
* @param string $default Text of default content.
Documentation generated on Sun, 04 May 2008 09:22:31 -0500 by phpDocumentor 1.3.0