3 * base include file for SimpleTest
5 * @subpackage UnitTester
6 * @version $Id: detached.php 1784 2008-04-26 13:07:14Z pp11 $
10 * include other SimpleTest class files
12 require_once(dirname(__FILE__
) . '/xml.php');
13 require_once(dirname(__FILE__
) . '/shell_tester.php');
17 * Runs an XML formated test in a separate process.
19 * @subpackage UnitTester
21 class DetachedTestCase
{
27 * Sets the location of the remote test.
28 * @param string $command Test script.
29 * @param string $dry_command Script for dry run.
32 function __construct($command, $dry_command = false) {
33 $this->command
= $command;
34 $this->dry_command
= $dry_command ?
$dry_command : $command;
39 * Accessor for the test name for subclasses.
40 * @return string Name of the test.
44 return $this->command
;
48 * Runs the top level test for this class. Currently
49 * reads the data as a single chunk. I'll fix this
50 * once I have added iteration to the browser.
51 * @param SimpleReporter $reporter Target of test results.
52 * @returns boolean True if no failures.
55 function run(&$reporter) {
56 $shell = &new SimpleShell();
57 $shell->execute($this->command
);
58 $parser = &$this->createParser($reporter);
59 if (! $parser->parse($shell->getOutput())) {
60 trigger_error('Cannot parse incoming XML from [' . $this->command
. ']');
67 * Accessor for the number of subtests.
68 * @return integer Number of test cases.
72 if ($this->size
=== false) {
73 $shell = &new SimpleShell();
74 $shell->execute($this->dry_command
);
75 $reporter = &new SimpleReporter();
76 $parser = &$this->createParser($reporter);
77 if (! $parser->parse($shell->getOutput())) {
78 trigger_error('Cannot parse incoming XML from [' . $this->dry_command
. ']');
81 $this->size
= $reporter->getTestCaseCount();
87 * Creates the XML parser.
88 * @param SimpleReporter $reporter Target of test results.
89 * @return SimpleTestXmlListener XML reader.
92 protected function &createParser(&$reporter) {
93 return new SimpleTestXmlParser($reporter);