| [ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * base include file for SimpleTest 4 * @package SimpleTest 5 * @subpackage UnitTester 6 * @version $Id: remote.php 1397 2006-09-07 07:55:53Z wei $ 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 protected $_url; 24 protected $_dry_url; 25 protected $_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 return new SimpleBrowser(); 79 } 80 81 /** 82 * Creates the XML parser. 83 * @param SimpleReporter $reporter Target of test results. 84 * @return SimpleTestXmlListener XML reader. 85 * @access protected 86 */ 87 function &_createParser($reporter) { 88 return new SimpleTestXmlParser($reporter); 89 } 90 91 /** 92 * Accessor for the number of subtests. 93 * @return integer Number of test cases. 94 * @access public 95 */ 96 function getSize() { 97 if ($this->_size === false) { 98 $browser = $this->_createBrowser(); 99 $xml = $browser->get($this->_dry_url); 100 if (! $xml) { 101 trigger_error('Cannot read remote test URL [' . $this->_dry_url . ']'); 102 return false; 103 } 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 . ']'); 108 return false; 109 } 110 $this->_size = $reporter->getTestCaseCount(); 111 } 112 return $this->_size; 113 } 114 } 115 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |