123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
-
-
-
- require_once(dirname(__FILE__) . '/browser.php');
- require_once(dirname(__FILE__) . '/xml.php');
- require_once(dirname(__FILE__) . '/test_case.php');
-
-
-
- class RemoteTestCase {
- private $url;
- private $dry_url;
- private $size;
-
-
-
- function __construct($url, $dry_url = false) {
- $this->url = $url;
- $this->dry_url = $dry_url ? $dry_url : $url;
- $this->size = false;
- }
-
-
-
- function getLabel() {
- return $this->url;
- }
-
-
-
- function run($reporter) {
- $browser = $this->createBrowser();
- $xml = $browser->get($this->url);
- if (! $xml) {
- trigger_error('Cannot read remote test URL [' . $this->url . ']');
- return false;
- }
- $parser = $this->createParser($reporter);
- if (! $parser->parse($xml)) {
- trigger_error('Cannot parse incoming XML from [' . $this->url . ']');
- return false;
- }
- return true;
- }
-
-
-
- protected function createBrowser() {
- return new SimpleBrowser();
- }
-
-
-
- protected function createParser($reporter) {
- return new SimpleTestXmlParser($reporter);
- }
-
-
-
- function getSize() {
- if ($this->size === false) {
- $browser = $this->createBrowser();
- $xml = $browser->get($this->dry_url);
- if (! $xml) {
- trigger_error('Cannot read remote test URL [' . $this->dry_url . ']');
- return false;
- }
- $reporter = new SimpleReporter();
- $parser = $this->createParser($reporter);
- if (! $parser->parse($xml)) {
- trigger_error('Cannot parse incoming XML from [' . $this->dry_url . ']');
- return false;
- }
- $this->size = $reporter->getTestCaseCount();
- }
- return $this->size;
- }
- }
- ?>
|