From: Mark R. <ma...@us...> - 2007-03-14 15:15:37
|
Update of /cvsroot/simpletest/simpletest In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv4042 Modified Files: autorun.php test_case.php Log Message: changed autorun to use TestSuite rather than the deprecated GroupTest and changed label accessor of TestSuite to grab the name of the single running test case where necessary. this means autorun class names for a single test case can now be labelled properly in the reporter. Index: autorun.php =================================================================== RCS file: /cvsroot/simpletest/simpletest/autorun.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** autorun.php 14 Mar 2007 13:13:01 -0000 1.4 --- autorun.php 14 Mar 2007 15:15:24 -0000 1.5 *************** *** 30,34 **** $diff_classes = array_map('strtolower', $diff_classes); ! $group = new GroupTest(); if (preg_match_all('~class\s+(\w+)~', file_get_contents($file), $matches)) { --- 30,34 ---- $diff_classes = array_map('strtolower', $diff_classes); ! $suite = new TestSuite(); if (preg_match_all('~class\s+(\w+)~', file_get_contents($file), $matches)) { *************** *** 36,51 **** if(SimpleTest :: isTestCase($candidate) && in_array(strtolower($candidate), $diff_classes)) { ! $group->addTestCase(new $candidate); } } } ! if ($reporter = &SimpleTest :: preferred('SimpleReporter')) { ! $res = $group->run($reporter); } else { if (SimpleReporter::inCli()) { ! $res = $group->run(new TextReporter()); } else { ! $res = $group->run(new HtmlReporter()); } } --- 36,51 ---- if(SimpleTest :: isTestCase($candidate) && in_array(strtolower($candidate), $diff_classes)) { ! $suite->addTestCase(new $candidate); } } } ! if ($reporter = &SimpleTest :: preferred('SimpleReporter')) { ! $res = $suite->run($reporter); } else { if (SimpleReporter::inCli()) { ! $res = $suite->run(new TextReporter()); } else { ! $res = $suite->run(new HtmlReporter()); } } Index: test_case.php =================================================================== RCS file: /cvsroot/simpletest/simpletest/test_case.php,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** test_case.php 8 Mar 2007 00:57:43 -0000 1.37 --- test_case.php 14 Mar 2007 15:15:24 -0000 1.38 *************** *** 394,398 **** */ function TestSuite($label = false) { ! $this->_label = $label ? $label : get_class($this); $this->_test_cases = array(); $this->_old_track_errors = ini_get('track_errors'); --- 394,398 ---- */ function TestSuite($label = false) { ! $this->_label = $label; $this->_test_cases = array(); $this->_old_track_errors = ini_get('track_errors'); *************** *** 402,411 **** /** ! * Accessor for the test name for subclasses. * @return string Name of the test. * @access public */ function getLabel() { ! return $this->_label; } --- 402,417 ---- /** ! * Accessor for the test name for subclasses. If the suite ! * wraps a single test case the label defaults to the name of that test. * @return string Name of the test. * @access public */ function getLabel() { ! if (!$this->_label) { ! return ($this->getSize() == 1) ? ! get_class($this->_test_cases[0]) : get_class($this); ! } else { ! return $this->_label; ! } } |