| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Optional include file for SimpleTest 4 * @package SimpleTest 5 * @subpackage UnitTester 6 * @version $Id: default_reporter.php,v 1.3 2007/05/28 18:27:37 lastcraft Exp $ 7 */ 8 9 /**#@+ 10 * include other SimpleTest class files 11 */ 12 require_once(dirname(__FILE__) . '/scorer.php'); 13 require_once(dirname(__FILE__) . '/reporter.php'); 14 require_once(dirname(__FILE__) . '/xml.php'); 15 /**#@-*/ 16 17 /** 18 * Parser for command line arguments. Extracts 19 * the a specific test to run and engages XML 20 * reporting when necessary. 21 * @package SimpleTest 22 * @subpackage UnitTester 23 */ 24 class SimpleCommandLineParser { 25 var $_to_property = array( 26 'case' => '_case', 'c' => '_case', 27 'test' => '_test', 't' => '_test', 28 'xml' => '_xml', 'x' => '_xml'); 29 var $_case = ''; 30 var $_test = ''; 31 var $_xml = false; 32 33 function SimpleCommandLineParser($arguments) { 34 if (! is_array($arguments)) { 35 return; 36 } 37 foreach ($arguments as $i => $argument) { 38 if (preg_match('/^--?(test|case|t|c)=(.+)$/', $argument, $matches)) { 39 $property = $this->_to_property[$matches[1]]; 40 $this->$property = $matches[2]; 41 } elseif (preg_match('/^--?(test|case|t|c)$/', $argument, $matches)) { 42 $property = $this->_to_property[$matches[1]]; 43 if (isset($arguments[$i + 1])) { 44 $this->$property = $arguments[$i + 1]; 45 } 46 } elseif (preg_match('/^--?(xml|x)$/', $argument)) { 47 $this->_xml = true; 48 } 49 } 50 } 51 52 function getTest() { 53 return $this->_test; 54 } 55 56 function getTestCase() { 57 return $this->_case; 58 } 59 60 function isXml() { 61 return $this->_xml; 62 } 63 } 64 65 /** 66 * The default reporter used by SimpleTest's autorun 67 * feature. 68 * @package SimpleTest 69 * @subpackage UnitTester 70 */ 71 class DefaultReporter extends SimpleReporterDecorator { 72 73 /** 74 * Assembles the appopriate reporter for the environment. 75 */ 76 function DefaultReporter() { 77 if (SimpleReporter::inCli()) { 78 global $argv; 79 $parser = new SimpleCommandLineParser($argv); 80 $reporter_class = $parser->isXml() ? 'XmlReporter' : 'TextReporter'; 81 $reporter = &new SelectiveReporter( 82 new $reporter_class(), $parser->getTestCase(), $parser->getTest()); 83 } else { 84 $reporter = &new SelectiveReporter(new HtmlReporter(), @$_GET['c'], @$_GET['t']); 85 } 86 $this->SimpleReporterDecorator($reporter); 87 } 88 } 89 ?>
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 |