| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * base include file for SimpleTest 4 * @package SimpleTest 5 * @subpackage UnitTester 6 * @version $Id: remote.php 5999 2007-06-18 13:13:08Z pachanga $ 7 */ 8 9 /**#@+ 10 * include other SimpleTest class files 11 */ 12 require_once(dirname(__FILE__) . '/browser.php'); 13 require_once(dirname(__FILE__) . '/xml.php'); 14 require_once(dirname(__FILE__) . '/test_case.php'); 15 /**#@-*/ 16 17 /** 18 * Runs an XML formated test on a remote server. 19 * @package SimpleTest 20 * @subpackage UnitTester 21 */ 22 class RemoteTestCase { 23 var $_url; 24 var $_dry_url; 25 var $_size; 26 27 /** 28 * Sets the location of the remote test. 29 * @param string $url Test location. 30 * @param string $dry_url Location for dry run. 31 * @access public 32 */ 33 function RemoteTestCase($url, $dry_url = false) { 34 $this->_url = $url; 35 $this->_dry_url = $dry_url ? $dry_url : $url; 36 $this->_size = false; 37 } 38 39 /** 40 * Accessor for the test name for subclasses. 41 * @return string Name of the test. 42 * @access public 43 */ 44 function getLabel() { 45 return $this->_url; 46 } 47 48 /** 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. 54 * @access public 55 */ 56 function run(&$reporter) { 57 $browser = &$this->_createBrowser(); 58 $xml = $browser->get($this->_url); 59 if (! $xml) { 60 trigger_error('Cannot read remote test URL [' . $this->_url . ']'); 61 return false; 62 } 63 $parser = &$this->_createParser($reporter); 64 if (! $parser->parse($xml)) { 65 trigger_error('Cannot parse incoming XML from [' . $this->_url . ']'); 66 return false; 67 } 68 return true; 69 } 70 71 /** 72 * Creates a new web browser object for fetching 73 * the XML report. 74 * @return SimpleBrowser New browser. 75 * @access protected 76 */ 77 function &_createBrowser() { 78 $browser = &new SimpleBrowser(); 79 return $browser; 80 } 81 82 /** 83 * Creates the XML parser. 84 * @param SimpleReporter $reporter Target of test results. 85 * @return SimpleTestXmlListener XML reader. 86 * @access protected 87 */ 88 function &_createParser(&$reporter) { 89 $parser = &new SimpleTestXmlParser($reporter); 90 return $parser; 91 } 92 93 /** 94 * Accessor for the number of subtests. 95 * @return integer Number of test cases. 96 * @access public 97 */ 98 function getSize() { 99 if ($this->_size === false) { 100 $browser = &$this->_createBrowser(); 101 $xml = $browser->get($this->_dry_url); 102 if (! $xml) { 103 trigger_error('Cannot read remote test URL [' . $this->_dry_url . ']'); 104 return false; 105 } 106 $reporter = &new SimpleReporter(); 107 $parser = &$this->_createParser($reporter); 108 if (! $parser->parse($xml)) { 109 trigger_error('Cannot parse incoming XML from [' . $this->_dry_url . ']'); 110 return false; 111 } 112 $this->_size = $reporter->getTestCaseCount(); 113 } 114 return $this->_size; 115 } 116 } 117 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |