3 * base include file for SimpleTest
5 * @subpackage UnitTester
6 * @version $Id: remote.php 2011 2011-04-29 08:22:48Z pp11 $
10 * include other SimpleTest class files
12 require_once(dirname(__FILE__
) . '/browser.php');
13 require_once(dirname(__FILE__
) . '/xml.php');
14 require_once(dirname(__FILE__
) . '/test_case.php');
18 * Runs an XML formated test on a remote server.
20 * @subpackage UnitTester
22 class RemoteTestCase
{
28 * Sets the location of the remote test.
29 * @param string $url Test location.
30 * @param string $dry_url Location for dry run.
33 function __construct($url, $dry_url = false) {
35 $this->dry_url
= $dry_url ?
$dry_url : $url;
40 * Accessor for the test name for subclasses.
41 * @return string Name of the test.
49 * Runs the top level test for this class. Currently
50 * reads the data as a single chunk. I'll fix this
51 * once I have added iteration to the browser.
52 * @param SimpleReporter $reporter Target of test results.
53 * @returns boolean True if no failures.
56 function run($reporter) {
57 $browser = $this->createBrowser();
58 $xml = $browser->get($this->url
);
60 trigger_error('Cannot read remote test URL [' . $this->url
. ']');
63 $parser = $this->createParser($reporter);
64 if (! $parser->parse($xml)) {
65 trigger_error('Cannot parse incoming XML from [' . $this->url
. ']');
72 * Creates a new web browser object for fetching
74 * @return SimpleBrowser New browser.
77 protected function createBrowser() {
78 return new SimpleBrowser();
82 * Creates the XML parser.
83 * @param SimpleReporter $reporter Target of test results.
84 * @return SimpleTestXmlListener XML reader.
87 protected function createParser($reporter) {
88 return new SimpleTestXmlParser($reporter);
92 * Accessor for the number of subtests.
93 * @return integer Number of test cases.
97 if ($this->size
=== false) {
98 $browser = $this->createBrowser();
99 $xml = $browser->get($this->dry_url
);
101 trigger_error('Cannot read remote test URL [' . $this->dry_url
. ']');
104 $reporter = new SimpleReporter();
105 $parser = $this->createParser($reporter);
106 if (! $parser->parse($xml)) {
107 trigger_error('Cannot parse incoming XML from [' . $this->dry_url
. ']');
110 $this->size
= $reporter->getTestCaseCount();