Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/simpletestlib/remote.php
Go to the documentation of this file.
00001 <?php
00012 require_once(dirname(__FILE__) . '/browser.php');
00013 require_once(dirname(__FILE__) . '/xml.php');
00014 require_once(dirname(__FILE__) . '/test_case.php');
00022 class RemoteTestCase {
00023     var $_url;
00024     var $_dry_url;
00025     var $_size;
00026     
00033     function RemoteTestCase($url, $dry_url = false) {
00034         $this->_url = $url;
00035         $this->_dry_url = $dry_url ? $dry_url : $url;
00036         $this->_size = false;
00037     }
00038     
00044     function getLabel() {
00045         return $this->_url;
00046     }
00047 
00056     function run(&$reporter) {
00057         $browser = &$this->_createBrowser();
00058         $xml = $browser->get($this->_url);
00059         if (! $xml) {
00060             trigger_error('Cannot read remote test URL [' . $this->_url . ']');
00061             return false;
00062         }
00063         $parser = &$this->_createParser($reporter);
00064         if (! $parser->parse($xml)) {
00065             trigger_error('Cannot parse incoming XML from [' . $this->_url . ']');
00066             return false;
00067         }
00068         return true;
00069     }
00070     
00077     function &_createBrowser() {
00078         $browser = new SimpleBrowser();
00079         return $browser;
00080     }
00081     
00088     function &_createParser(&$reporter) {
00089         $parser = new SimpleTestXmlParser($reporter);
00090         return $parser;
00091     }
00092     
00098     function getSize() {
00099         if ($this->_size === false) {
00100             $browser = &$this->_createBrowser();
00101             $xml = $browser->get($this->_dry_url);
00102             if (! $xml) {
00103                 trigger_error('Cannot read remote test URL [' . $this->_dry_url . ']');
00104                 return false;
00105             }
00106             $reporter = new SimpleReporter();
00107             $parser = &$this->_createParser($reporter);
00108             if (! $parser->parse($xml)) {
00109                 trigger_error('Cannot parse incoming XML from [' . $this->_dry_url . ']');
00110                 return false;
00111             }
00112             $this->_size = $reporter->getTestCaseCount();
00113         }
00114         return $this->_size;
00115     }
00116 }
00117 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations