123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- require_once(dirname(__FILE__) . '/browser.php');
- require_once(dirname(__FILE__) . '/xml.php');
- require_once(dirname(__FILE__) . '/test_case.php');
- class RemoteTestCase {
- var $_url;
- var $_dry_url;
- var $_size;
-
- function RemoteTestCase($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;
- }
-
- function &_createBrowser() {
- $browser = &new SimpleBrowser();
- return $browser;
- }
-
- function &_createParser(&$reporter) {
- $parser = &new SimpleTestXmlParser($reporter);
- return $parser;
- }
-
- 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;
- }
- }
- ?>
|