|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00012 require_once(dirname(__FILE__) . '/xml.php'); 00013 require_once(dirname(__FILE__) . '/shell_tester.php'); 00021 class DetachedTestCase { 00022 var $_command; 00023 var $_dry_command; 00024 var $_size; 00025 00032 function DetachedTestCase($command, $dry_command = false) { 00033 $this->_command = $command; 00034 $this->_dry_command = $dry_command ? $dry_command : $command; 00035 $this->_size = false; 00036 } 00037 00043 function getLabel() { 00044 return $this->_command; 00045 } 00046 00055 function run(&$reporter) { 00056 $shell = new SimpleShell(); 00057 $shell->execute($this->_command); 00058 $parser = &$this->_createParser($reporter); 00059 if (! $parser->parse($shell->getOutput())) { 00060 trigger_error('Cannot parse incoming XML from [' . $this->_command . ']'); 00061 return false; 00062 } 00063 return true; 00064 } 00065 00071 function getSize() { 00072 if ($this->_size === false) { 00073 $shell = new SimpleShell(); 00074 $shell->execute($this->_dry_command); 00075 $reporter = new SimpleReporter(); 00076 $parser = &$this->_createParser($reporter); 00077 if (! $parser->parse($shell->getOutput())) { 00078 trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']'); 00079 return false; 00080 } 00081 $this->_size = $reporter->getTestCaseCount(); 00082 } 00083 return $this->_size; 00084 } 00085 00092 function &_createParser(&$reporter) { 00093 return new SimpleTestXmlParser($reporter); 00094 } 00095 } 00096 ?>