From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- buildscripts/Benchmark/Iterate.php | 334 +++--- buildscripts/Benchmark/Profiler.php | 894 +++++++------- buildscripts/Benchmark/Timer.php | 638 +++++----- buildscripts/Benchmark/doc/timer_example.php | 36 +- .../PHPUnit2/Extensions/ExceptionTestCase.php | 244 ++-- .../PHPUnit2/Extensions/PerformanceTestCase.php | 256 ++-- buildscripts/PHPUnit2/Extensions/RepeatedTest.php | 276 ++--- buildscripts/PHPUnit2/Extensions/TestDecorator.php | 348 +++--- buildscripts/PHPUnit2/Extensions/TestSetup.php | 308 ++--- buildscripts/PHPUnit2/Framework/Assert.php | 1252 ++++++++++---------- .../PHPUnit2/Framework/AssertionFailedError.php | 160 +-- .../PHPUnit2/Framework/ComparisonFailure.php | 306 ++--- buildscripts/PHPUnit2/Framework/Error.php | 176 +-- buildscripts/PHPUnit2/Framework/IncompleteTest.php | 144 +-- .../PHPUnit2/Framework/IncompleteTestError.php | 150 +-- buildscripts/PHPUnit2/Framework/Test.php | 174 +-- buildscripts/PHPUnit2/Framework/TestCase.php | 584 ++++----- buildscripts/PHPUnit2/Framework/TestFailure.php | 308 ++--- buildscripts/PHPUnit2/Framework/TestListener.php | 270 ++--- buildscripts/PHPUnit2/Framework/TestResult.php | 894 +++++++------- buildscripts/PHPUnit2/Framework/TestSuite.php | 1108 ++++++++--------- buildscripts/PHPUnit2/Framework/Warning.php | 188 +-- buildscripts/PHPUnit2/Runner/BaseTestRunner.php | 566 ++++----- .../PHPUnit2/Runner/IncludePathTestCollector.php | 368 +++--- .../PHPUnit2/Runner/StandardTestSuiteLoader.php | 258 ++-- buildscripts/PHPUnit2/Runner/TestCollector.php | 154 +-- buildscripts/PHPUnit2/Runner/TestSuiteLoader.php | 170 +-- buildscripts/PHPUnit2/Runner/Version.php | 180 +-- buildscripts/PHPUnit2/TextUI/ResultPrinter.php | 712 +++++------ buildscripts/PHPUnit2/TextUI/TestRunner.php | 1244 +++++++++---------- .../PHPUnit2/Util/CodeCoverage/Renderer.php | 450 +++---- .../PHPUnit2/Util/CodeCoverage/Renderer/HTML.php | 382 +++--- .../PHPUnit2/Util/CodeCoverage/Renderer/Text.php | 250 ++-- buildscripts/PHPUnit2/Util/ErrorHandler.php | 154 +-- buildscripts/PHPUnit2/Util/Fileloader.php | 218 ++-- buildscripts/PHPUnit2/Util/Filter.php | 526 ++++---- buildscripts/PHPUnit2/Util/Log/PEAR.php | 440 +++---- buildscripts/PHPUnit2/Util/Log/XML.php | 712 +++++------ buildscripts/PHPUnit2/Util/Printer.php | 232 ++-- buildscripts/PHPUnit2/Util/Skeleton.php | 680 +++++------ .../PHPUnit2/Util/TestDox/NamePrettifier.php | 330 +++--- .../PHPUnit2/Util/TestDox/ResultPrinter.php | 598 +++++----- .../PHPUnit2/Util/TestDox/ResultPrinter/HTML.php | 240 ++-- .../PHPUnit2/Util/TestDox/ResultPrinter/Text.php | 204 ++-- buildscripts/chmbuilder/ChmQuickstartBuilder.php | 876 +++++++------- buildscripts/chmbuilder/build.php | 158 +-- buildscripts/chmbuilder/build_child.php | 12 +- buildscripts/chmbuilder/classes/pages/ClassDoc.php | 456 +++---- buildscripts/chmbuilder/classes/pages/Classes.php | 38 +- .../chmbuilder/classes/pages/MainLayout.php | 14 +- buildscripts/chmbuilder/index.php | 12 +- buildscripts/classtree/DWExtension.php | 508 ++++---- buildscripts/classtree/build.php | 516 ++++---- buildscripts/index/api_index.php | 240 ++-- buildscripts/index/build.php | 130 +- buildscripts/index/quickstart_index.php | 212 ++-- buildscripts/index/search.php | 70 +- buildscripts/jGrouseDoc/skins/common/js/jgdoc.js | 478 ++++---- buildscripts/jGrouseDoc/skins/common/js/jgindex.js | 192 +-- buildscripts/jGrouseDoc/skins/common/js/navTree.js | 426 +++---- buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js | 650 +++++----- .../jGrouseDoc/skins/noframes/js/navTree.js | 818 ++++++------- .../phing/tasks/ext/ioncube/IoncubeComment.php | 86 +- .../simpletest/SimpleTestCountResultFormatter.php | 102 +- .../ext/simpletest/SimpleTestFormatterElement.php | 250 ++-- .../simpletest/SimpleTestPlainResultFormatter.php | 188 +-- .../ext/simpletest/SimpleTestResultFormatter.php | 322 ++--- .../SimpleTestSummaryResultFormatter.php | 106 +- .../classes/phing/tasks/ext/svn/SvnBaseTask.php | 358 +++--- .../system/condition/ReferenceExistsCondition.php | 104 +- buildscripts/phing/tasks/ManualIndexTask.php | 74 +- buildscripts/phing/tasks/PradoDocTask.php | 296 ++--- buildscripts/phing/tasks/PradoPackageTask.php | 280 ++--- buildscripts/phing/tasks/PradoQuickStartDocs.php | 168 +-- buildscripts/phing/tasks/PradoSimpleTestTask.php | 78 +- buildscripts/phing/tasks/PradoTestTask.php | 34 +- buildscripts/phing/tasks/QuickstartIndexTask.php | 62 +- buildscripts/phpbuilder/build.php | 294 ++--- buildscripts/texbuilder/Page2Tex.php | 694 +++++------ buildscripts/texbuilder/quickstart/build.php | 162 +-- buildscripts/texbuilder/quickstart/pages.php | 356 +++--- buildscripts/texbuilder/sqlmap/build.php | 162 +-- buildscripts/texbuilder/sqlmap/pages.php | 122 +- buildscripts/texbuilder/time-tracker/pages.php | 34 +- 84 files changed, 14127 insertions(+), 14127 deletions(-) (limited to 'buildscripts') diff --git a/buildscripts/Benchmark/Iterate.php b/buildscripts/Benchmark/Iterate.php index acf1ec08..f09dcb76 100644 --- a/buildscripts/Benchmark/Iterate.php +++ b/buildscripts/Benchmark/Iterate.php @@ -1,167 +1,167 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to the New BSD license, That is bundled | -// | with this package in the file LICENSE, and is available through | -// | the world-wide-web at | -// | http://www.opensource.org/licenses/bsd-license.php | -// | If you did not receive a copy of the new BSDlicense and are unable | -// | to obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: Iterate.php,v 1.12 2006/02/17 16:29:44 toggg Exp $ -// - -require_once 'Benchmark/Timer.php'; - -/** - * Provides timing and profiling information. - * - * Example 1 - * - * - * '; - * } - * - * $benchmark->run(100, 'foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * Example 2 - * - * - * '; - * } - * } - * - * $benchmark->run(100, 'myclass::foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * Example 3 - * - * - * '; - * } - * } - * - * $o = new MyClass(); - * - * $benchmark->run(100, 'o->foo', 'test'); - * $result = $benchmark->get(); - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Benchmarking - * @package Benchmark - */ -class Benchmark_Iterate extends Benchmark_Timer { - /** - * Benchmarks a function or method. - * - * @access public - */ - function run() { - $arguments = func_get_args(); - $iterations = array_shift($arguments); - $function_name = array_shift($arguments); - - if (strstr($function_name, '::')) { - $function_name = explode('::', $function_name); - $objectmethod = $function_name[1]; - } - - if (strstr($function_name, '->')) { - $function_name = explode('->', $function_name); - $objectname = $function_name[0]; - - $object = $GLOBALS[$objectname]; - $objectmethod = $function_name[1]; - - for ($i = 1; $i <= $iterations; $i++) { - $this->setMarker('start_' . $i); - call_user_func_array(array($object, $function_name[1]), $arguments); - $this->setMarker('end_' . $i); - } - - return(0); - } - - for ($i = 1; $i <= $iterations; $i++) { - $this->setMarker('start_' . $i); - call_user_func_array($function_name, $arguments); - $this->setMarker('end_' . $i); - } - } - - /** - * Returns benchmark result. - * - * $result[x ] = execution time of iteration x - * $result['mean' ] = mean execution time - * $result['iterations'] = number of iterations - * - * @return array - * @access public - */ - function get($simple_output = false) { - $result = array(); - $total = 0; - - $iterations = count($this->markers)/2; - - for ($i = 1; $i <= $iterations; $i++) { - $time = $this->timeElapsed('start_'.$i , 'end_'.$i); - - if (extension_loaded('bcmath')) { - $total = bcadd($total, $time, 6); - } else { - $total = $total + $time; - } - - if (!$simple_output) { - $result[$i] = $time; - } - } - - if (extension_loaded('bcmath')) { - $result['mean'] = bcdiv($total, $iterations, 6); - } else { - $result['mean'] = $total / $iterations; - } - - $result['iterations'] = $iterations; - - return $result; - } -} +. | +// +------------------------------------------------------------------------+ +// | This source file is subject to the New BSD license, That is bundled | +// | with this package in the file LICENSE, and is available through | +// | the world-wide-web at | +// | http://www.opensource.org/licenses/bsd-license.php | +// | If you did not receive a copy of the new BSDlicense and are unable | +// | to obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +------------------------------------------------------------------------+ +// +// $Id: Iterate.php,v 1.12 2006/02/17 16:29:44 toggg Exp $ +// + +require_once 'Benchmark/Timer.php'; + +/** + * Provides timing and profiling information. + * + * Example 1 + * + * + * '; + * } + * + * $benchmark->run(100, 'foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * Example 2 + * + * + * '; + * } + * } + * + * $benchmark->run(100, 'myclass::foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * Example 3 + * + * + * '; + * } + * } + * + * $o = new MyClass(); + * + * $benchmark->run(100, 'o->foo', 'test'); + * $result = $benchmark->get(); + * ?> + * + * + * @author Sebastian Bergmann + * @copyright Copyright © 2002-2005 Sebastian Bergmann + * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 + * @category Benchmarking + * @package Benchmark + */ +class Benchmark_Iterate extends Benchmark_Timer { + /** + * Benchmarks a function or method. + * + * @access public + */ + function run() { + $arguments = func_get_args(); + $iterations = array_shift($arguments); + $function_name = array_shift($arguments); + + if (strstr($function_name, '::')) { + $function_name = explode('::', $function_name); + $objectmethod = $function_name[1]; + } + + if (strstr($function_name, '->')) { + $function_name = explode('->', $function_name); + $objectname = $function_name[0]; + + $object = $GLOBALS[$objectname]; + $objectmethod = $function_name[1]; + + for ($i = 1; $i <= $iterations; $i++) { + $this->setMarker('start_' . $i); + call_user_func_array(array($object, $function_name[1]), $arguments); + $this->setMarker('end_' . $i); + } + + return(0); + } + + for ($i = 1; $i <= $iterations; $i++) { + $this->setMarker('start_' . $i); + call_user_func_array($function_name, $arguments); + $this->setMarker('end_' . $i); + } + } + + /** + * Returns benchmark result. + * + * $result[x ] = execution time of iteration x + * $result['mean' ] = mean execution time + * $result['iterations'] = number of iterations + * + * @return array + * @access public + */ + function get($simple_output = false) { + $result = array(); + $total = 0; + + $iterations = count($this->markers)/2; + + for ($i = 1; $i <= $iterations; $i++) { + $time = $this->timeElapsed('start_'.$i , 'end_'.$i); + + if (extension_loaded('bcmath')) { + $total = bcadd($total, $time, 6); + } else { + $total = $total + $time; + } + + if (!$simple_output) { + $result[$i] = $time; + } + } + + if (extension_loaded('bcmath')) { + $result['mean'] = bcdiv($total, $iterations, 6); + } else { + $result['mean'] = $total / $iterations; + } + + $result['iterations'] = $iterations; + + return $result; + } +} diff --git a/buildscripts/Benchmark/Profiler.php b/buildscripts/Benchmark/Profiler.php index e9108a84..001f1959 100644 --- a/buildscripts/Benchmark/Profiler.php +++ b/buildscripts/Benchmark/Profiler.php @@ -1,447 +1,447 @@ -. | -// +----------------------------------------------------------------------+ -// | This source file is subject to the New BSD license, That is bundled | -// | with this package in the file LICENSE, and is available through | -// | the world-wide-web at | -// | http://www.opensource.org/licenses/bsd-license.php | -// | If you did not receive a copy of the new BSDlicense and are unable | -// | to obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// -// $Id: Profiler.php,v 1.19 2006/03/01 19:26:09 anant Exp $ -// - -require_once 'PEAR.php'; - -/** - * Provides timing and profiling information. - * - * Example 1: Automatic profiling start, stop, and output. - * - * - * enterSection('myFunction'); - * //do something - * $profiler->leaveSection('myFunction'); - * return; - * } - * - * //do something - * myFunction(); - * //do more - * ?> - * - * - * Example 2: Manual profiling start, stop, and output. - * - * - * enterSection('myFunction'); - * //do something - * $profiler->leaveSection('myFunction'); - * return; - * } - * - * $profiler->start(); - * //do something - * myFunction(); - * //do more - * $profiler->stop(); - * $profiler->display(); - * ?> - * - * - * @author Matthias Englert - * @copyright Copyright © 2002-2005 Matthias Englert - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Benchmarking - * @package Benchmark - * @since 1.2.0 - */ -class Benchmark_Profiler extends PEAR { - /** - * Contains the total ex. time of each section - * - * @var array - * @access private - */ - var $_sections = array(); - - /** - * Calling stack - * - * @var array - * @access private - */ - var $_stack = array(); - - /** - * Notes how often a section was entered - * - * @var array - * @access private - */ - var $_numberOfCalls = array(); - - /** - * Notes for each section how much time is spend in sub-sections - * - * @var array - * @access private - */ - var $_subSectionsTime = array(); - - /** - * Notes for each section how often it calls which section - * - * @var array - * @access private - */ - var $_calls = array(); - - /** - * Notes for each section how often it was called by which section - * - * @var array - * @access private - */ - var $_callers = array(); - - /** - * Auto-starts and stops profiler - * - * @var boolean - * @access private - */ - var $_auto = FALSE; - - /** - * Max marker name length for non-html output - * - * @var integer - * @access private - */ - var $_maxStringLength = 0; - - /** - * Constructor, starts profiling recording - * - * @access public - */ - function Benchmark_Profiler($auto = FALSE) { - $this->_auto = $auto; - - if ($this->_auto) { - $this->start(); - } - - $this->PEAR(); - } - - /** - * Destructor, stops profiling recording - * - * @access private - */ - function _Benchmark_Profiler() { - if (isset($this->_auto) && $this->_auto) { - $this->stop(); - $this->display(); - } - } - - /** - * Returns profiling informations for a given section. - * - * @param string $section - * @return array - * @access public - */ - function getSectionInformations($section = 'Global') { - if (isset($this->_sections[$section])) { - $calls = array(); - - if (isset($this->_calls[$section])) { - $calls = $this->_calls[$section]; - } - - $callers = array(); - - if (isset($this->_callers[$section])) { - $callers = $this->_callers[$section]; - } - - $informations = array(); - - $informations['time'] = $this->_sections[$section]; - if (isset($this->_sections['Global'])) { - $informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', ''); - } else { - $informations['percentage'] = 'N/A'; - } - $informations['calls'] = $calls; - $informations['num_calls'] = $this->_numberOfCalls[$section]; - $informations['callers'] = $callers; - - if (isset($this->_subSectionsTime[$section])) { - $informations['netto_time'] = $this->_sections[$section] - $this->_subSectionsTime[$section]; - } else { - $informations['netto_time'] = $this->_sections[$section]; - } - - return $informations; - } else { - $this->raiseError("The section '$section' does not exists.\n", NULL, PEAR_ERROR_TRIGGER, E_USER_WARNING); - } - } - - /** - * Returns profiling informations for all sections. - * - * @return array - * @access public - */ - function getAllSectionsInformations() { - $informations = array(); - - foreach($this->_sections as $section => $time) { - $informations[$section] = $this->getSectionInformations($section); - } - - return $informations; - } - - /** - * Returns formatted profiling information. - * - * @param string output format (auto, plain or html), default auto - * @see display() - * @access private - */ - function _getOutput($format) { - - /* Quickly find out the maximun length: Ineffecient, but will do for now! */ - $informations = $this->getAllSectionsInformations(); - $names = array_keys($informations); - - $maxLength = 0; - foreach ($names as $name) - { - if ($maxLength < strlen($name)) { - $maxLength = strlen($name); - } - } - $this->_maxStringLength = $maxLength; - - if ($format == 'auto') { - if (function_exists('version_compare') && - version_compare(phpversion(), '4.1', 'ge')) { - $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain'; - } else { - global $HTTP_SERVER_VARS; - $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain'; - } - } - - if ($format == 'html') { - $out = ''."\n"; - $out .= - ''. - ''. - ''. - ''. - "\n"; - } else { - $dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT); - $out .= str_pad('Section', $this->_maxStringLength + 10); - $out .= str_pad("Total Ex Time", 22); - $out .= str_pad("Netto Ex Time", 22); - $out .= str_pad("#Calls", 10); - $out .= "Percentage\n"; - $out .= $dashes; - } - - foreach($informations as $name => $values) { - $percentage = $values['percentage']; - $calls_str = ""; - - foreach($values['calls'] as $key => $val) { - if ($calls_str) { - $calls_str .= ", "; - } - - $calls_str .= "$key ($val)"; - } - - $callers_str = ""; - - foreach($values['callers'] as $key => $val) { - if ($callers_str) { - $callers_str .= ", "; - } - - $callers_str .= "$key ($val)"; - } - - if ($format == 'html') { - $out .= ""; - if (is_numeric($values['percentage'])) { - $out .= "\n"; - } else { - $out .= "\n"; - } - $out .= ""; - } else { - $out .= str_pad($name, $this->_maxStringLength + 10); - $out .= str_pad($values['time'], 22); - $out .= str_pad($values['netto_time'], 22); - $out .= str_pad($values['num_calls'], 10); - if (is_numeric($values['percentage'])) { - $out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT); - } else { - $out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT); - } - } - } - - if ($format == 'html') { - return $out . '
 total ex. timenetto ex. time#calls%callscallers
$name{$values['time']}{$values['netto_time']}{$values['num_calls']}{$values['percentage']}%{$values['percentage']}$calls_str$callers_str
'; - } else { - return $out; - } - } - - /** - * Returns formatted profiling information. - * - * @param string output format (auto, plain or html), default auto - * @access public - */ - function display($format = 'auto') { - echo $this->_getOutput($format); - } - - /** - * Enters "Global" section. - * - * @see enterSection(), stop() - * @access public - */ - function start() { - $this->enterSection('Global'); - } - - /** - * Leaves "Global" section. - * - * @see leaveSection(), start() - * @access public - */ - function stop() { - $this->leaveSection('Global'); - } - - /** - * Enters code section. - * - * @param string name of the code section - * @see start(), leaveSection() - * @access public - */ - function enterSection($name) { - if (count($this->_stack)) { - if (isset($this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]])) { - $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]]++; - } else { - $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]] = 1; - } - - if (isset($this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name])) { - $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name]++; - } else { - $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name] = 1; - } - } else { - if ($name != 'Global') { - $this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE); - } - } - - if (isset($this->_numberOfCalls[$name])) { - $this->_numberOfCalls[$name]++; - } else { - $this->_numberOfCalls[$name] = 1; - } - - array_push($this->_stack, array("name" => $name, "time" => $this->_getMicrotime())); - } - - /** - * Leaves code section. - * - * @param string name of the marker to be set - * @see stop(), enterSection() - * @access public - */ - function leaveSection($name) { - $microtime = $this->_getMicrotime(); - - if (!count($this->_stack)) { - $this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE); - } - - $x = array_pop($this->_stack); - - if ($x["name"] != $name) { - $this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE); - } - - if (isset($this->_sections[$name])) { - $this->_sections[$name] += $microtime - $x["time"]; - } else { - $this->_sections[$name] = $microtime - $x["time"]; - } - - $parent = array_pop($this->_stack); - - if (isset($parent)) { - if (isset($this->_subSectionsTime[$parent['name']])) { - $this->_subSectionsTime[$parent['name']] += $microtime - $x['time']; - } else { - $this->_subSectionsTime[$parent['name']] = $microtime - $x['time']; - } - - array_push($this->_stack, $parent); - } - } - - /** - * Wrapper for microtime(). - * - * @return float - * @access private - * @since 1.3.0 - */ - function _getMicrotime() { - $microtime = explode(' ', microtime()); - return $microtime[1] . substr($microtime[0], 1); - } -} +. | +// +----------------------------------------------------------------------+ +// | This source file is subject to the New BSD license, That is bundled | +// | with this package in the file LICENSE, and is available through | +// | the world-wide-web at | +// | http://www.opensource.org/licenses/bsd-license.php | +// | If you did not receive a copy of the new BSDlicense and are unable | +// | to obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// +// $Id: Profiler.php,v 1.19 2006/03/01 19:26:09 anant Exp $ +// + +require_once 'PEAR.php'; + +/** + * Provides timing and profiling information. + * + * Example 1: Automatic profiling start, stop, and output. + * + * + * enterSection('myFunction'); + * //do something + * $profiler->leaveSection('myFunction'); + * return; + * } + * + * //do something + * myFunction(); + * //do more + * ?> + * + * + * Example 2: Manual profiling start, stop, and output. + * + * + * enterSection('myFunction'); + * //do something + * $profiler->leaveSection('myFunction'); + * return; + * } + * + * $profiler->start(); + * //do something + * myFunction(); + * //do more + * $profiler->stop(); + * $profiler->display(); + * ?> + * + * + * @author Matthias Englert + * @copyright Copyright © 2002-2005 Matthias Englert + * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 + * @category Benchmarking + * @package Benchmark + * @since 1.2.0 + */ +class Benchmark_Profiler extends PEAR { + /** + * Contains the total ex. time of each section + * + * @var array + * @access private + */ + var $_sections = array(); + + /** + * Calling stack + * + * @var array + * @access private + */ + var $_stack = array(); + + /** + * Notes how often a section was entered + * + * @var array + * @access private + */ + var $_numberOfCalls = array(); + + /** + * Notes for each section how much time is spend in sub-sections + * + * @var array + * @access private + */ + var $_subSectionsTime = array(); + + /** + * Notes for each section how often it calls which section + * + * @var array + * @access private + */ + var $_calls = array(); + + /** + * Notes for each section how often it was called by which section + * + * @var array + * @access private + */ + var $_callers = array(); + + /** + * Auto-starts and stops profiler + * + * @var boolean + * @access private + */ + var $_auto = FALSE; + + /** + * Max marker name length for non-html output + * + * @var integer + * @access private + */ + var $_maxStringLength = 0; + + /** + * Constructor, starts profiling recording + * + * @access public + */ + function Benchmark_Profiler($auto = FALSE) { + $this->_auto = $auto; + + if ($this->_auto) { + $this->start(); + } + + $this->PEAR(); + } + + /** + * Destructor, stops profiling recording + * + * @access private + */ + function _Benchmark_Profiler() { + if (isset($this->_auto) && $this->_auto) { + $this->stop(); + $this->display(); + } + } + + /** + * Returns profiling informations for a given section. + * + * @param string $section + * @return array + * @access public + */ + function getSectionInformations($section = 'Global') { + if (isset($this->_sections[$section])) { + $calls = array(); + + if (isset($this->_calls[$section])) { + $calls = $this->_calls[$section]; + } + + $callers = array(); + + if (isset($this->_callers[$section])) { + $callers = $this->_callers[$section]; + } + + $informations = array(); + + $informations['time'] = $this->_sections[$section]; + if (isset($this->_sections['Global'])) { + $informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', ''); + } else { + $informations['percentage'] = 'N/A'; + } + $informations['calls'] = $calls; + $informations['num_calls'] = $this->_numberOfCalls[$section]; + $informations['callers'] = $callers; + + if (isset($this->_subSectionsTime[$section])) { + $informations['netto_time'] = $this->_sections[$section] - $this->_subSectionsTime[$section]; + } else { + $informations['netto_time'] = $this->_sections[$section]; + } + + return $informations; + } else { + $this->raiseError("The section '$section' does not exists.\n", NULL, PEAR_ERROR_TRIGGER, E_USER_WARNING); + } + } + + /** + * Returns profiling informations for all sections. + * + * @return array + * @access public + */ + function getAllSectionsInformations() { + $informations = array(); + + foreach($this->_sections as $section => $time) { + $informations[$section] = $this->getSectionInformations($section); + } + + return $informations; + } + + /** + * Returns formatted profiling information. + * + * @param string output format (auto, plain or html), default auto + * @see display() + * @access private + */ + function _getOutput($format) { + + /* Quickly find out the maximun length: Ineffecient, but will do for now! */ + $informations = $this->getAllSectionsInformations(); + $names = array_keys($informations); + + $maxLength = 0; + foreach ($names as $name) + { + if ($maxLength < strlen($name)) { + $maxLength = strlen($name); + } + } + $this->_maxStringLength = $maxLength; + + if ($format == 'auto') { + if (function_exists('version_compare') && + version_compare(phpversion(), '4.1', 'ge')) { + $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain'; + } else { + global $HTTP_SERVER_VARS; + $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain'; + } + } + + if ($format == 'html') { + $out = ''."\n"; + $out .= + ''. + ''. + ''. + ''. + "\n"; + } else { + $dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT); + $out .= str_pad('Section', $this->_maxStringLength + 10); + $out .= str_pad("Total Ex Time", 22); + $out .= str_pad("Netto Ex Time", 22); + $out .= str_pad("#Calls", 10); + $out .= "Percentage\n"; + $out .= $dashes; + } + + foreach($informations as $name => $values) { + $percentage = $values['percentage']; + $calls_str = ""; + + foreach($values['calls'] as $key => $val) { + if ($calls_str) { + $calls_str .= ", "; + } + + $calls_str .= "$key ($val)"; + } + + $callers_str = ""; + + foreach($values['callers'] as $key => $val) { + if ($callers_str) { + $callers_str .= ", "; + } + + $callers_str .= "$key ($val)"; + } + + if ($format == 'html') { + $out .= ""; + if (is_numeric($values['percentage'])) { + $out .= "\n"; + } else { + $out .= "\n"; + } + $out .= ""; + } else { + $out .= str_pad($name, $this->_maxStringLength + 10); + $out .= str_pad($values['time'], 22); + $out .= str_pad($values['netto_time'], 22); + $out .= str_pad($values['num_calls'], 10); + if (is_numeric($values['percentage'])) { + $out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT); + } else { + $out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT); + } + } + } + + if ($format == 'html') { + return $out . '
 total ex. timenetto ex. time#calls%callscallers
$name{$values['time']}{$values['netto_time']}{$values['num_calls']}{$values['percentage']}%{$values['percentage']}$calls_str$callers_str
'; + } else { + return $out; + } + } + + /** + * Returns formatted profiling information. + * + * @param string output format (auto, plain or html), default auto + * @access public + */ + function display($format = 'auto') { + echo $this->_getOutput($format); + } + + /** + * Enters "Global" section. + * + * @see enterSection(), stop() + * @access public + */ + function start() { + $this->enterSection('Global'); + } + + /** + * Leaves "Global" section. + * + * @see leaveSection(), start() + * @access public + */ + function stop() { + $this->leaveSection('Global'); + } + + /** + * Enters code section. + * + * @param string name of the code section + * @see start(), leaveSection() + * @access public + */ + function enterSection($name) { + if (count($this->_stack)) { + if (isset($this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]])) { + $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]]++; + } else { + $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]] = 1; + } + + if (isset($this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name])) { + $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name]++; + } else { + $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name] = 1; + } + } else { + if ($name != 'Global') { + $this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE); + } + } + + if (isset($this->_numberOfCalls[$name])) { + $this->_numberOfCalls[$name]++; + } else { + $this->_numberOfCalls[$name] = 1; + } + + array_push($this->_stack, array("name" => $name, "time" => $this->_getMicrotime())); + } + + /** + * Leaves code section. + * + * @param string name of the marker to be set + * @see stop(), enterSection() + * @access public + */ + function leaveSection($name) { + $microtime = $this->_getMicrotime(); + + if (!count($this->_stack)) { + $this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE); + } + + $x = array_pop($this->_stack); + + if ($x["name"] != $name) { + $this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE); + } + + if (isset($this->_sections[$name])) { + $this->_sections[$name] += $microtime - $x["time"]; + } else { + $this->_sections[$name] = $microtime - $x["time"]; + } + + $parent = array_pop($this->_stack); + + if (isset($parent)) { + if (isset($this->_subSectionsTime[$parent['name']])) { + $this->_subSectionsTime[$parent['name']] += $microtime - $x['time']; + } else { + $this->_subSectionsTime[$parent['name']] = $microtime - $x['time']; + } + + array_push($this->_stack, $parent); + } + } + + /** + * Wrapper for microtime(). + * + * @return float + * @access private + * @since 1.3.0 + */ + function _getMicrotime() { + $microtime = explode(' ', microtime()); + return $microtime[1] . substr($microtime[0], 1); + } +} diff --git a/buildscripts/Benchmark/Timer.php b/buildscripts/Benchmark/Timer.php index d713e6b2..feee38c2 100644 --- a/buildscripts/Benchmark/Timer.php +++ b/buildscripts/Benchmark/Timer.php @@ -1,319 +1,319 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to the New BSD license, That is bundled | -// | with this package in the file LICENSE, and is available through | -// | the world-wide-web at | -// | http://www.opensource.org/licenses/bsd-license.php | -// | If you did not receive a copy of the new BSDlicense and are unable | -// | to obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +------------------------------------------------------------------------+ -// -// $Id: Timer.php,v 1.16 2006/03/01 13:41:39 matthias Exp $ -// - -require_once 'PEAR.php'; - -/** - * Provides timing and profiling information. - * - * Example 1: Automatic profiling start, stop, and output. - * - * - * setMarker('Marker 1'); - * ?> - * - * - * Example 2: Manual profiling start, stop, and output. - * - * - * start(); - * $timer->setMarker('Marker 1'); - * $timer->stop(); - * - * $timer->display(); // to output html formated - * // AND/OR : - * $profiling = $timer->getProfiling(); // get the profiler info as an associative array - * ?> - * - * - * @author Sebastian Bergmann - * @author Ludovico Magnocavallo - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Benchmarking - * @package Benchmark - */ -class Benchmark_Timer extends PEAR { - /** - * Contains the markers. - * - * @var array - * @access private - */ - var $markers = array(); - - /** - * Auto-start and stop timer. - * - * @var boolean - * @access private - */ - var $auto = FALSE; - - /** - * Max marker name length for non-html output. - * - * @var integer - * @access private - */ - var $maxStringLength = 0; - - /** - * Constructor. - * - * @param boolean $auto - * @access public - */ - function Benchmark_Timer($auto = FALSE) { - $this->auto = $auto; - - if ($this->auto) { - $this->start(); - } - - $this->PEAR(); - } - - /** - * Destructor. - * - * @access private - */ - function _Benchmark_Timer() { - if ($this->auto) { - $this->stop(); - $this->display(); - } - } - - /** - * Set "Start" marker. - * - * @see setMarker(), stop() - * @access public - */ - function start() { - $this->setMarker('Start'); - } - - /** - * Set "Stop" marker. - * - * @see setMarker(), start() - * @access public - */ - function stop() { - $this->setMarker('Stop'); - } - - /** - * Set marker. - * - * @param string $name Name of the marker to be set. - * @see start(), stop() - * @access public - */ - function setMarker($name) { - $this->markers[$name] = $this->_getMicrotime(); - } - - /** - * Returns the time elapsed betweens two markers. - * - * @param string $start start marker, defaults to "Start" - * @param string $end end marker, defaults to "Stop" - * @return double $time_elapsed time elapsed between $start and $end - * @access public - */ - function timeElapsed($start = 'Start', $end = 'Stop') { - if ($end == 'Stop' && !isset($this->markers['Stop'])) { - $this->markers['Stop'] = $this->_getMicrotime(); - } - - if (extension_loaded('bcmath')) { - return bcsub($this->markers[$end], $this->markers[$start], 6); - } else { - return $this->markers[$end] - $this->markers[$start]; - } - } - - /** - * Returns profiling information. - * - * $profiling[x]['name'] = name of marker x - * $profiling[x]['time'] = time index of marker x - * $profiling[x]['diff'] = execution time from marker x-1 to this marker x - * $profiling[x]['total'] = total execution time up to marker x - * - * @return array - * @access public - */ - function getProfiling() { - $i = $total = 0; - $result = array(); - $temp = reset($this->markers); - $this->maxStringLength = 0; - - foreach ($this->markers as $marker => $time) { - if (extension_loaded('bcmath')) { - $diff = bcsub($time, $temp, 6); - $total = bcadd($total, $diff, 6); - } else { - $diff = $time - $temp; - $total = $total + $diff; - } - - $result[$i]['name'] = $marker; - $result[$i]['time'] = $time; - $result[$i]['diff'] = $diff; - $result[$i]['total'] = $total; - - $this->maxStringLength = (strlen($marker) > $this->maxStringLength ? strlen($marker) + 1 : $this->maxStringLength); - - $temp = $time; - $i++; - } - - $result[0]['diff'] = '-'; - $result[0]['total'] = '-'; - $this->maxStringLength = (strlen('total') > $this->maxStringLength ? strlen('total') : $this->maxStringLength); - $this->maxStringLength += 2; - - return $result; - } - - /** - * Return formatted profiling information. - * - * @param boolean $showTotal Optionnaly includes total in output, default no - * @param string $format output format (auto, plain or html), default auto - * @return string - * @see getProfiling() - * @access public - */ - function getOutput($showTotal = FALSE, $format = 'auto') { - if ($format == 'auto') { - if (function_exists('version_compare') && - version_compare(phpversion(), '4.1', 'ge')) - { - $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain'; - } else { - global $HTTP_SERVER_VARS; - $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain'; - } - } - - $total = $this->TimeElapsed(); - $result = $this->getProfiling(); - $dashes = ''; - - if ($format == 'html') { - $out = ''."\n"; - $out .= ''. - ($showTotal ? - '' - : '')."\n"; - } else { - $dashes = $out = str_pad("\n", - $this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT); - $out .= str_pad('marker', $this->maxStringLength) . - str_pad("time index", 22) . - str_pad("ex time", 16) . - str_pad("perct ", 8) . - ($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" . - $dashes; - } - - foreach ($result as $k => $v) { - $perc = (($v['diff'] * 100) / $total); - $tperc = (($v['total'] * 100) / $total); - - if ($format == 'html') { - $out .= "". - ($showTotal ? - "" : ''). - "\n"; - } else { - $out .= str_pad($v['name'], $this->maxStringLength, ' ') . - str_pad($v['time'], 22) . - str_pad($v['diff'], 14) . - str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) . - ($showTotal ? ' '. - str_pad($v['total'], 14) . - str_pad(number_format($tperc, 2, '.', '')."%", - 8, ' ', STR_PAD_LEFT) : ''). - "\n"; - } - - $out .= $dashes; - } - - if ($format == 'html') { - $out .= "".($showTotal ? "" : "")."\n"; - $out .= "
 time indexex time%elapsed%
" . $v['name'] . - "" . $v['time'] . - "" . $v['diff'] . - "" . number_format($perc, 2, '.', '') . - "%" . $v['total'] . - "" . - number_format($tperc, 2, '.', '') . - "%
total-${total}100.00%--
\n"; - } else { - $out .= str_pad('total', $this->maxStringLength); - $out .= str_pad('-', 22); - $out .= str_pad($total, 15); - $out .= "100.00%\n"; - $out .= $dashes; - } - - return $out; - } - - /** - * Prints the information returned by getOutput(). - * - * @param boolean $showTotal Optionnaly includes total in output, default no - * @param string $format output format (auto, plain or html), default auto - * @see getOutput() - * @access public - */ - function display($showTotal = FALSE, $format = 'auto') { - print $this->getOutput($showTotal, $format); - } - - /** - * Wrapper for microtime(). - * - * @return float - * @access private - * @since 1.3.0 - */ - function _getMicrotime() { - $microtime = explode(' ', microtime()); - return $microtime[1] . substr($microtime[0], 1); - } -} +. | +// +------------------------------------------------------------------------+ +// | This source file is subject to the New BSD license, That is bundled | +// | with this package in the file LICENSE, and is available through | +// | the world-wide-web at | +// | http://www.opensource.org/licenses/bsd-license.php | +// | If you did not receive a copy of the new BSDlicense and are unable | +// | to obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +------------------------------------------------------------------------+ +// +// $Id: Timer.php,v 1.16 2006/03/01 13:41:39 matthias Exp $ +// + +require_once 'PEAR.php'; + +/** + * Provides timing and profiling information. + * + * Example 1: Automatic profiling start, stop, and output. + * + * + * setMarker('Marker 1'); + * ?> + * + * + * Example 2: Manual profiling start, stop, and output. + * + * + * start(); + * $timer->setMarker('Marker 1'); + * $timer->stop(); + * + * $timer->display(); // to output html formated + * // AND/OR : + * $profiling = $timer->getProfiling(); // get the profiler info as an associative array + * ?> + * + * + * @author Sebastian Bergmann + * @author Ludovico Magnocavallo + * @copyright Copyright © 2002-2005 Sebastian Bergmann + * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 + * @category Benchmarking + * @package Benchmark + */ +class Benchmark_Timer extends PEAR { + /** + * Contains the markers. + * + * @var array + * @access private + */ + var $markers = array(); + + /** + * Auto-start and stop timer. + * + * @var boolean + * @access private + */ + var $auto = FALSE; + + /** + * Max marker name length for non-html output. + * + * @var integer + * @access private + */ + var $maxStringLength = 0; + + /** + * Constructor. + * + * @param boolean $auto + * @access public + */ + function Benchmark_Timer($auto = FALSE) { + $this->auto = $auto; + + if ($this->auto) { + $this->start(); + } + + $this->PEAR(); + } + + /** + * Destructor. + * + * @access private + */ + function _Benchmark_Timer() { + if ($this->auto) { + $this->stop(); + $this->display(); + } + } + + /** + * Set "Start" marker. + * + * @see setMarker(), stop() + * @access public + */ + function start() { + $this->setMarker('Start'); + } + + /** + * Set "Stop" marker. + * + * @see setMarker(), start() + * @access public + */ + function stop() { + $this->setMarker('Stop'); + } + + /** + * Set marker. + * + * @param string $name Name of the marker to be set. + * @see start(), stop() + * @access public + */ + function setMarker($name) { + $this->markers[$name] = $this->_getMicrotime(); + } + + /** + * Returns the time elapsed betweens two markers. + * + * @param string $start start marker, defaults to "Start" + * @param string $end end marker, defaults to "Stop" + * @return double $time_elapsed time elapsed between $start and $end + * @access public + */ + function timeElapsed($start = 'Start', $end = 'Stop') { + if ($end == 'Stop' && !isset($this->markers['Stop'])) { + $this->markers['Stop'] = $this->_getMicrotime(); + } + + if (extension_loaded('bcmath')) { + return bcsub($this->markers[$end], $this->markers[$start], 6); + } else { + return $this->markers[$end] - $this->markers[$start]; + } + } + + /** + * Returns profiling information. + * + * $profiling[x]['name'] = name of marker x + * $profiling[x]['time'] = time index of marker x + * $profiling[x]['diff'] = execution time from marker x-1 to this marker x + * $profiling[x]['total'] = total execution time up to marker x + * + * @return array + * @access public + */ + function getProfiling() { + $i = $total = 0; + $result = array(); + $temp = reset($this->markers); + $this->maxStringLength = 0; + + foreach ($this->markers as $marker => $time) { + if (extension_loaded('bcmath')) { + $diff = bcsub($time, $temp, 6); + $total = bcadd($total, $diff, 6); + } else { + $diff = $time - $temp; + $total = $total + $diff; + } + + $result[$i]['name'] = $marker; + $result[$i]['time'] = $time; + $result[$i]['diff'] = $diff; + $result[$i]['total'] = $total; + + $this->maxStringLength = (strlen($marker) > $this->maxStringLength ? strlen($marker) + 1 : $this->maxStringLength); + + $temp = $time; + $i++; + } + + $result[0]['diff'] = '-'; + $result[0]['total'] = '-'; + $this->maxStringLength = (strlen('total') > $this->maxStringLength ? strlen('total') : $this->maxStringLength); + $this->maxStringLength += 2; + + return $result; + } + + /** + * Return formatted profiling information. + * + * @param boolean $showTotal Optionnaly includes total in output, default no + * @param string $format output format (auto, plain or html), default auto + * @return string + * @see getProfiling() + * @access public + */ + function getOutput($showTotal = FALSE, $format = 'auto') { + if ($format == 'auto') { + if (function_exists('version_compare') && + version_compare(phpversion(), '4.1', 'ge')) + { + $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain'; + } else { + global $HTTP_SERVER_VARS; + $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain'; + } + } + + $total = $this->TimeElapsed(); + $result = $this->getProfiling(); + $dashes = ''; + + if ($format == 'html') { + $out = ''."\n"; + $out .= ''. + ($showTotal ? + '' + : '')."\n"; + } else { + $dashes = $out = str_pad("\n", + $this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT); + $out .= str_pad('marker', $this->maxStringLength) . + str_pad("time index", 22) . + str_pad("ex time", 16) . + str_pad("perct ", 8) . + ($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" . + $dashes; + } + + foreach ($result as $k => $v) { + $perc = (($v['diff'] * 100) / $total); + $tperc = (($v['total'] * 100) / $total); + + if ($format == 'html') { + $out .= "". + ($showTotal ? + "" : ''). + "\n"; + } else { + $out .= str_pad($v['name'], $this->maxStringLength, ' ') . + str_pad($v['time'], 22) . + str_pad($v['diff'], 14) . + str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) . + ($showTotal ? ' '. + str_pad($v['total'], 14) . + str_pad(number_format($tperc, 2, '.', '')."%", + 8, ' ', STR_PAD_LEFT) : ''). + "\n"; + } + + $out .= $dashes; + } + + if ($format == 'html') { + $out .= "".($showTotal ? "" : "")."\n"; + $out .= "
 time indexex time%elapsed%
" . $v['name'] . + "" . $v['time'] . + "" . $v['diff'] . + "" . number_format($perc, 2, '.', '') . + "%" . $v['total'] . + "" . + number_format($tperc, 2, '.', '') . + "%
total-${total}100.00%--
\n"; + } else { + $out .= str_pad('total', $this->maxStringLength); + $out .= str_pad('-', 22); + $out .= str_pad($total, 15); + $out .= "100.00%\n"; + $out .= $dashes; + } + + return $out; + } + + /** + * Prints the information returned by getOutput(). + * + * @param boolean $showTotal Optionnaly includes total in output, default no + * @param string $format output format (auto, plain or html), default auto + * @see getOutput() + * @access public + */ + function display($showTotal = FALSE, $format = 'auto') { + print $this->getOutput($showTotal, $format); + } + + /** + * Wrapper for microtime(). + * + * @return float + * @access private + * @since 1.3.0 + */ + function _getMicrotime() { + $microtime = explode(' ', microtime()); + return $microtime[1] . substr($microtime[0], 1); + } +} diff --git a/buildscripts/Benchmark/doc/timer_example.php b/buildscripts/Benchmark/doc/timer_example.php index 93dd05c6..ff9de936 100644 --- a/buildscripts/Benchmark/doc/timer_example.php +++ b/buildscripts/Benchmark/doc/timer_example.php @@ -1,18 +1,18 @@ -start(); -wait(10); -$timer->setMarker('Mark1'); -echo "Elapsed time between Start and Mark1: " . - $timer->timeElapsed('Start', 'Mark1') . "\n"; -wait(50); -$timer->stop(); -$timer->display(); +start(); +wait(10); +$timer->setMarker('Mark1'); +echo "Elapsed time between Start and Mark1: " . + $timer->timeElapsed('Start', 'Mark1') . "\n"; +wait(50); +$timer->stop(); +$timer->display(); diff --git a/buildscripts/PHPUnit2/Extensions/ExceptionTestCase.php b/buildscripts/PHPUnit2/Extensions/ExceptionTestCase.php index 80afd1b5..ababf9c5 100644 --- a/buildscripts/PHPUnit2/Extensions/ExceptionTestCase.php +++ b/buildscripts/PHPUnit2/Extensions/ExceptionTestCase.php @@ -1,122 +1,122 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ExceptionTestCase.php,v 1.15.2.6 2006/02/20 07:42:59 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/TestCase.php'; - -/** - * A TestCase that expects a specified Exception to be thrown. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Extensions_ExceptionTestCase extends PHPUnit2_Framework_TestCase { - /** - * The name of the expected Exception. - * - * @var mixed - * @access private - */ - private $expectedException = NULL; - - /** - * @return string - * @access public - * @since Method available since Release 2.2.0 - */ - public function getExpectedException() { - return $this->expectedException; - } - - /** - * @param mixed $exceptionName - * @access public - * @since Method available since Release 2.2.0 - */ - public function setExpectedException($exceptionName) { - if ((is_string($exceptionName) && class_exists($exceptionName)) || $exceptionName === NULL) { - $this->expectedException = $exceptionName; - } - } - - /** - * @access protected - */ - protected function runTest() { - try { - parent::runTest(); - } - - catch (Exception $e) { - if ($this->expectedException !== NULL && - $e instanceof $this->expectedException) { - return; - } else { - throw $e; - } - } - - if ($this->expectedException !== NULL) { - $this->fail('Expected exception ' . $this->expectedException); - } - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: ExceptionTestCase.php,v 1.15.2.6 2006/02/20 07:42:59 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/TestCase.php'; + +/** + * A TestCase that expects a specified Exception to be thrown. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Extensions_ExceptionTestCase extends PHPUnit2_Framework_TestCase { + /** + * The name of the expected Exception. + * + * @var mixed + * @access private + */ + private $expectedException = NULL; + + /** + * @return string + * @access public + * @since Method available since Release 2.2.0 + */ + public function getExpectedException() { + return $this->expectedException; + } + + /** + * @param mixed $exceptionName + * @access public + * @since Method available since Release 2.2.0 + */ + public function setExpectedException($exceptionName) { + if ((is_string($exceptionName) && class_exists($exceptionName)) || $exceptionName === NULL) { + $this->expectedException = $exceptionName; + } + } + + /** + * @access protected + */ + protected function runTest() { + try { + parent::runTest(); + } + + catch (Exception $e) { + if ($this->expectedException !== NULL && + $e instanceof $this->expectedException) { + return; + } else { + throw $e; + } + } + + if ($this->expectedException !== NULL) { + $this->fail('Expected exception ' . $this->expectedException); + } + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Extensions/PerformanceTestCase.php b/buildscripts/PHPUnit2/Extensions/PerformanceTestCase.php index 38b249a6..4d10f062 100644 --- a/buildscripts/PHPUnit2/Extensions/PerformanceTestCase.php +++ b/buildscripts/PHPUnit2/Extensions/PerformanceTestCase.php @@ -1,128 +1,128 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: PerformanceTestCase.php,v 1.15.2.5 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.1.0 - */ - -require_once 'PHPUnit2/Framework/TestCase.php'; - -require_once 'Benchmark/Timer.php'; - -/** - * A TestCase that expects a TestCase to be executed - * meeting a given time limit. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Extensions_PerformanceTestCase extends PHPUnit2_Framework_TestCase { - /** - * @var integer - * @access private - */ - private $maxRunningTime = 0; - - /** - * @access protected - */ - protected function runTest() { - $timer = new Benchmark_Timer; - - $timer->start(); - parent::runTest(); - $timer->stop(); - - if ($this->maxRunningTime != 0 && - $timer->timeElapsed() > $this->maxRunningTime) { - $this->fail( - sprintf( - 'expected running time: <= %s but was: %s', - - $this->maxRunningTime, - $timer->timeElapsed() - ) - ); - } - } - - /** - * @param integer $maxRunningTime - * @throws Exception - * @access public - * @since Method available since Release 2.3.0 - */ - public function setMaxRunningTime($maxRunningTime) { - if (is_integer($maxRunningTime) && - $maxRunningTime >= 0) { - $this->maxRunningTime = $maxRunningTime; - } else { - throw new Exception; - } - } - - /** - * @return integer - * @access public - * @since Method available since Release 2.3.0 - */ - public function getMaxRunningTime() { - return $this->maxRunningTime; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: PerformanceTestCase.php,v 1.15.2.5 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.1.0 + */ + +require_once 'PHPUnit2/Framework/TestCase.php'; + +require_once 'Benchmark/Timer.php'; + +/** + * A TestCase that expects a TestCase to be executed + * meeting a given time limit. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Extensions_PerformanceTestCase extends PHPUnit2_Framework_TestCase { + /** + * @var integer + * @access private + */ + private $maxRunningTime = 0; + + /** + * @access protected + */ + protected function runTest() { + $timer = new Benchmark_Timer; + + $timer->start(); + parent::runTest(); + $timer->stop(); + + if ($this->maxRunningTime != 0 && + $timer->timeElapsed() > $this->maxRunningTime) { + $this->fail( + sprintf( + 'expected running time: <= %s but was: %s', + + $this->maxRunningTime, + $timer->timeElapsed() + ) + ); + } + } + + /** + * @param integer $maxRunningTime + * @throws Exception + * @access public + * @since Method available since Release 2.3.0 + */ + public function setMaxRunningTime($maxRunningTime) { + if (is_integer($maxRunningTime) && + $maxRunningTime >= 0) { + $this->maxRunningTime = $maxRunningTime; + } else { + throw new Exception; + } + } + + /** + * @return integer + * @access public + * @since Method available since Release 2.3.0 + */ + public function getMaxRunningTime() { + return $this->maxRunningTime; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Extensions/RepeatedTest.php b/buildscripts/PHPUnit2/Extensions/RepeatedTest.php index c23b0915..b842aa1b 100644 --- a/buildscripts/PHPUnit2/Extensions/RepeatedTest.php +++ b/buildscripts/PHPUnit2/Extensions/RepeatedTest.php @@ -1,138 +1,138 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: RepeatedTest.php,v 1.15.2.4 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Extensions/TestDecorator.php'; - -/** - * A Decorator that runs a test repeatedly. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Extensions_RepeatedTest extends PHPUnit2_Extensions_TestDecorator { - /** - * @var integer - * @access private - */ - private $timesRepeat = 1; - - /** - * Constructor. - * - * @param PHPUnit2_Framework_Test $test - * @param integer $timesRepeat - * @throws Exception - * @access public - */ - public function __construct(PHPUnit2_Framework_Test $test, $timesRepeat = 1) { - parent::__construct($test); - - if (is_integer($timesRepeat) && - $timesRepeat >= 0) { - $this->timesRepeat = $timesRepeat; - } else { - throw new Exception( - 'Argument 2 must be a positive integer.' - ); - } - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - * @access public - */ - public function countTestCases() { - return $this->timesRepeat * $this->test->countTestCases(); - } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @throws Exception - * @access public - */ - public function run($result = NULL) { - if ($result === NULL) { - $result = $this->createResult(); - } - - // XXX: Workaround for missing ability to declare type-hinted parameters as optional. - else if (!($result instanceof PHPUnit2_Framework_TestResult)) { - throw new Exception( - 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' - ); - } - - for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) { - $this->test->run($result); - } - - return $result; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: RepeatedTest.php,v 1.15.2.4 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Extensions/TestDecorator.php'; + +/** + * A Decorator that runs a test repeatedly. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Extensions_RepeatedTest extends PHPUnit2_Extensions_TestDecorator { + /** + * @var integer + * @access private + */ + private $timesRepeat = 1; + + /** + * Constructor. + * + * @param PHPUnit2_Framework_Test $test + * @param integer $timesRepeat + * @throws Exception + * @access public + */ + public function __construct(PHPUnit2_Framework_Test $test, $timesRepeat = 1) { + parent::__construct($test); + + if (is_integer($timesRepeat) && + $timesRepeat >= 0) { + $this->timesRepeat = $timesRepeat; + } else { + throw new Exception( + 'Argument 2 must be a positive integer.' + ); + } + } + + /** + * Counts the number of test cases that + * will be run by this test. + * + * @return integer + * @access public + */ + public function countTestCases() { + return $this->timesRepeat * $this->test->countTestCases(); + } + + /** + * Runs the decorated test and collects the + * result in a TestResult. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @throws Exception + * @access public + */ + public function run($result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); + } + + // XXX: Workaround for missing ability to declare type-hinted parameters as optional. + else if (!($result instanceof PHPUnit2_Framework_TestResult)) { + throw new Exception( + 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' + ); + } + + for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) { + $this->test->run($result); + } + + return $result; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Extensions/TestDecorator.php b/buildscripts/PHPUnit2/Extensions/TestDecorator.php index 3557eeca..ebca6e1f 100644 --- a/buildscripts/PHPUnit2/Extensions/TestDecorator.php +++ b/buildscripts/PHPUnit2/Extensions/TestDecorator.php @@ -1,174 +1,174 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestDecorator.php,v 1.14.2.4 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/Assert.php'; -require_once 'PHPUnit2/Framework/Test.php'; -require_once 'PHPUnit2/Framework/TestResult.php'; - -/** - * A Decorator for Tests. - * - * Use TestDecorator as the base class for defining new - * test decorators. Test decorator subclasses can be introduced - * to add behaviour before or after a test is run. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Extensions_TestDecorator extends PHPUnit2_Framework_Assert implements PHPUnit2_Framework_Test { - /** - * The Test to be decorated. - * - * @var object - * @access protected - */ - protected $test = NULL; - - /** - * Constructor. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function __construct(PHPUnit2_Framework_Test $test) { - $this->test = $test; - } - - /** - * Returns a string representation of the test. - * - * @return string - * @access public - */ - public function toString() { - return $this->test->toString(); - } - - /** - * Runs the test and collects the - * result in a TestResult. - * - * @param PHPUnit2_Framework_TestResult $result - * @access public - */ - public function basicRun(PHPUnit2_Framework_TestResult $result) { - $this->test->run($result); - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - * @access public - */ - public function countTestCases() { - return $this->test->countTestCases(); - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit2_Framework_TestResult - * @access protected - */ - protected function createResult() { - return new PHPUnit2_Framework_TestResult; - } - - /** - * Returns the test to be run. - * - * @return PHPUnit2_Framework_Test - * @access public - */ - public function getTest() { - return $this->test; - } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @throws Exception - * @access public - */ - public function run($result = NULL) { - if ($result === NULL) { - $result = $this->createResult(); - } - - // XXX: Workaround for missing ability to declare type-hinted parameters as optional. - else if (!($result instanceof PHPUnit2_Framework_TestResult)) { - throw new Exception( - 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' - ); - } - - $this->basicRun($result); - - return $result; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestDecorator.php,v 1.14.2.4 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/Assert.php'; +require_once 'PHPUnit2/Framework/Test.php'; +require_once 'PHPUnit2/Framework/TestResult.php'; + +/** + * A Decorator for Tests. + * + * Use TestDecorator as the base class for defining new + * test decorators. Test decorator subclasses can be introduced + * to add behaviour before or after a test is run. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Extensions_TestDecorator extends PHPUnit2_Framework_Assert implements PHPUnit2_Framework_Test { + /** + * The Test to be decorated. + * + * @var object + * @access protected + */ + protected $test = NULL; + + /** + * Constructor. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function __construct(PHPUnit2_Framework_Test $test) { + $this->test = $test; + } + + /** + * Returns a string representation of the test. + * + * @return string + * @access public + */ + public function toString() { + return $this->test->toString(); + } + + /** + * Runs the test and collects the + * result in a TestResult. + * + * @param PHPUnit2_Framework_TestResult $result + * @access public + */ + public function basicRun(PHPUnit2_Framework_TestResult $result) { + $this->test->run($result); + } + + /** + * Counts the number of test cases that + * will be run by this test. + * + * @return integer + * @access public + */ + public function countTestCases() { + return $this->test->countTestCases(); + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit2_Framework_TestResult + * @access protected + */ + protected function createResult() { + return new PHPUnit2_Framework_TestResult; + } + + /** + * Returns the test to be run. + * + * @return PHPUnit2_Framework_Test + * @access public + */ + public function getTest() { + return $this->test; + } + + /** + * Runs the decorated test and collects the + * result in a TestResult. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @throws Exception + * @access public + */ + public function run($result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); + } + + // XXX: Workaround for missing ability to declare type-hinted parameters as optional. + else if (!($result instanceof PHPUnit2_Framework_TestResult)) { + throw new Exception( + 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' + ); + } + + $this->basicRun($result); + + return $result; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Extensions/TestSetup.php b/buildscripts/PHPUnit2/Extensions/TestSetup.php index 4d28f931..153cfcf1 100644 --- a/buildscripts/PHPUnit2/Extensions/TestSetup.php +++ b/buildscripts/PHPUnit2/Extensions/TestSetup.php @@ -1,154 +1,154 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestSetup.php,v 1.13.2.6 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/Extensions/TestDecorator.php'; - -/** - * A Decorator to set up and tear down additional fixture state. - * Subclass TestSetup and insert it into your tests when you want - * to set up additional state once before the tests are run. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Extensions_TestSetup extends PHPUnit2_Extensions_TestDecorator { - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @throws Exception - * @access public - */ - public function run($result = NULL) { - if ($result === NULL) { - $result = $this->createResult(); - } - - // XXX: Workaround for missing ability to declare type-hinted parameters as optional. - else if (!($result instanceof PHPUnit2_Framework_TestResult)) { - throw new Exception( - 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' - ); - } - - $this->setUp(); - $this->copyFixtureToTest(); - $this->basicRun($result); - $this->tearDown(); - - return $result; - } - - /** - * Copies the fixture set up by setUp() to the test. - * - * @access private - * @since Method available since Release 2.3.0 - */ - private function copyFixtureToTest() { - $object = new ReflectionClass($this); - - foreach ($object->getProperties() as $property) { - $name = $property->getName(); - - if ($name != 'test') { - $this->doCopyFixtureToTest($this->test, $name, $this->$name); - } - } - } - - /** - * @access private - * @since Method available since Release 2.3.0 - */ - private function doCopyFixtureToTest($object, $name, &$value) { - if ($object instanceof PHPUnit2_Framework_TestSuite) { - foreach ($object->tests() as $test) { - $this->doCopyFixtureToTest($test, $name, $value); - } - } else { - $object->$name =& $value; - } - } - - /** - * Sets up the fixture. Override to set up additional fixture - * state. - * - * @access protected - */ - protected function setUp() { - } - - /** - * Tears down the fixture. Override to tear down the additional - * fixture state. - * - * @access protected - */ - protected function tearDown() { - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestSetup.php,v 1.13.2.6 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/TestSuite.php'; +require_once 'PHPUnit2/Extensions/TestDecorator.php'; + +/** + * A Decorator to set up and tear down additional fixture state. + * Subclass TestSetup and insert it into your tests when you want + * to set up additional state once before the tests are run. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Extensions_TestSetup extends PHPUnit2_Extensions_TestDecorator { + /** + * Runs the decorated test and collects the + * result in a TestResult. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @throws Exception + * @access public + */ + public function run($result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); + } + + // XXX: Workaround for missing ability to declare type-hinted parameters as optional. + else if (!($result instanceof PHPUnit2_Framework_TestResult)) { + throw new Exception( + 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' + ); + } + + $this->setUp(); + $this->copyFixtureToTest(); + $this->basicRun($result); + $this->tearDown(); + + return $result; + } + + /** + * Copies the fixture set up by setUp() to the test. + * + * @access private + * @since Method available since Release 2.3.0 + */ + private function copyFixtureToTest() { + $object = new ReflectionClass($this); + + foreach ($object->getProperties() as $property) { + $name = $property->getName(); + + if ($name != 'test') { + $this->doCopyFixtureToTest($this->test, $name, $this->$name); + } + } + } + + /** + * @access private + * @since Method available since Release 2.3.0 + */ + private function doCopyFixtureToTest($object, $name, &$value) { + if ($object instanceof PHPUnit2_Framework_TestSuite) { + foreach ($object->tests() as $test) { + $this->doCopyFixtureToTest($test, $name, $value); + } + } else { + $object->$name =& $value; + } + } + + /** + * Sets up the fixture. Override to set up additional fixture + * state. + * + * @access protected + */ + protected function setUp() { + } + + /** + * Tears down the fixture. Override to tear down the additional + * fixture state. + * + * @access protected + */ + protected function tearDown() { + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/Assert.php b/buildscripts/PHPUnit2/Framework/Assert.php index 3465afea..ef79e883 100644 --- a/buildscripts/PHPUnit2/Framework/Assert.php +++ b/buildscripts/PHPUnit2/Framework/Assert.php @@ -1,626 +1,626 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Assert.php,v 1.45.2.4 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/ComparisonFailure.php'; - -/** - * A set of assert methods. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - * @static - */ -class PHPUnit2_Framework_Assert { - /** - * @var boolean - * @access private - * @static - */ - private static $looselyTyped = FALSE; - - /** - * Protect constructor since it is a static only class. - * - * @access protected - */ - protected function __construct() { - } - - /** - * Asserts that a haystack contains a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @access public - * @static - * @since Method available since Release 2.1.0 - */ - public static function assertContains($needle, $haystack, $message = '') { - self::doAssertContains($needle, $haystack, TRUE, $message); - } - - /** - * Asserts that a haystack does not contain a needle. - * - * @param mixed $needle - * @param mixed $haystack - * @param string $message - * @access public - * @static - * @since Method available since Release 2.1.0 - */ - public static function assertNotContains($needle, $haystack, $message = '') { - self::doAssertContains($needle, $haystack, FALSE, $message); - } - - /** - * @param mixed $needle - * @param mixed $haystack - * @param boolean $condition - * @param string $message - * @throws Exception - * @access private - * @static - * @since Method available since Release 2.2.0 - */ - private static function doAssertContains($needle, $haystack, $condition, $message) { - $found = FALSE; - - if (is_array($haystack) || - (is_object($haystack) && $haystack instanceof Iterator)) { - foreach ($haystack as $straw) { - if ($straw === $needle) { - $found = TRUE; - break; - } - } - } - - else if (is_string($needle) && is_string($haystack)) { - if (strpos($haystack, $needle) !== FALSE) { - $found = TRUE; - } - } - - else { - throw new Exception; - } - - if ($condition && !$found) { - self::fail( - sprintf( - '%s%s"%s" does not contain "%s"', - - $message, - ($message != '') ? ' ' : '', - self::objectToString($haystack), - self::objectToString($needle) - ) - ); - } - - else if (!$condition && $found) { - self::fail( - sprintf( - '%s%s"%s" contains "%s"', - - $message, - ($message != '') ? ' ' : '', - self::objectToString($haystack), - self::objectToString($needle) - ) - ); - } - } - - /** - * Asserts that two variables are equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param mixed $delta - * @access public - * @static - */ - public static function assertEquals($expected, $actual, $message = '', $delta = 0) { - self::doAssertEquals($expected, $actual, $delta, TRUE, $message); - } - - /** - * Asserts that two variables are not equal. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @param mixed $delta - * @access public - * @static - * @since Method available since Release 2.3.0 - */ - public static function assertNotEquals($expected, $actual, $message = '', $delta = 0) { - self::doAssertEquals($expected, $actual, $delta, FALSE, $message); - } - - /** - * @param mixed $expected - * @param mixed $actual - * @param mixed $delta - * @param boolean $condition - * @param string $message - * @access private - * @static - * @since Method available since Release 2.3.0 - */ - private static function doAssertEquals($expected, $actual, $delta, $condition, $message) { - $equal = FALSE; - - if (is_array($expected)) { - if (is_array($actual)) { - self::sortArrayRecursively($actual); - self::sortArrayRecursively($expected); - - if (self::$looselyTyped) { - $actual = self::convertToString($actual); - $expected = self::convertToString($expected); - } - - $equal = (serialize($expected) == serialize($actual)); - } - } - - else if (is_float($expected) && is_float($actual) && is_float($delta)) { - $equal = (abs($expected - $actual) <= $delta); - } - - else { - $equal = (serialize($expected) == serialize($actual)); - } - - if ($condition && !$equal) { - self::failNotSame( - $expected, - $actual, - $message - ); - } - - else if (!$condition && $equal) { - self::failSame( - $expected, - $actual, - $message - ); - } - } - - /** - * Asserts that a condition is true. - * - * @param boolean $condition - * @param string $message - * @throws Exception - * @access public - * @static - */ - public static function assertTrue($condition, $message = '') { - if (is_bool($condition)) { - if (!$condition) { - self::fail($message); - } - } else { - throw new Exception; - } - } - - /** - * Asserts that a condition is false. - * - * @param boolean $condition - * @param string $message - * @throws Exception - * @access public - * @static - */ - public static function assertFalse($condition, $message = '') { - if (is_bool($condition)) { - self::assertTrue(!$condition, $message); - } else { - throw new Exception; - } - } - - /** - * Asserts that a variable is not NULL. - * - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function assertNotNull($actual, $message = '') { - if (is_null($actual)) { - self::fail(self::format('NOT NULL', 'NULL', $message)); - } - } - - /** - * Asserts that a variable is NULL. - * - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function assertNull($actual, $message = '') { - if (!is_null($actual)) { - self::fail(self::format('NULL', 'NOT NULL', $message)); - } - } - - /** - * Asserts that two variables have the same type and value. - * Used on objects, it asserts that two variables reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function assertSame($expected, $actual, $message = '') { - if ($expected !== $actual) { - self::failNotSame($expected, $actual, $message); - } - } - - /** - * Asserts that two variables do not have the same type and value. - * Used on objects, it asserts that two variables do not reference - * the same object. - * - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function assertNotSame($expected, $actual, $message = '') { - if ($expected === $actual) { - self::failSame($expected, $actual, $message); - } - } - - /** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function assertType($expected, $actual, $message = '') { - self::doAssertType($expected, $actual, TRUE, $message); - } - - /** - * Asserts that a variable is not of a given type. - * - * @param string $expected - * @param mixed $actual - * @param string $message - * @access public - * @static - * @since Method available since Release 2.2.0 - */ - public static function assertNotType($expected, $actual, $message = '') { - self::doAssertType($expected, $actual, FALSE, $message); - } - - /** - * @param string $expected - * @param mixed $actual - * @param boolean $condition - * @param string $message - * @access private - * @static - * @since Method available since Release 2.2.0 - */ - private static function doAssertType($expected, $actual, $condition, $message) { - if (!is_string($expected)) { - throw new Exception; - } - - if (is_object($actual)) { - $result = $actual instanceof $expected; - } else { - $result = (gettype($actual) == $expected); - } - - if ($condition && !$result) { - self::failNotSame( - $expected, - $actual, - $message - ); - } - - else if (!$condition && $result) { - self::failSame( - $expected, - $actual, - $message - ); - } - } - - /** - * Asserts that a string matches a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - * @access public - * @static - */ - public static function assertRegExp($pattern, $string, $message = '') { - self::doAssertRegExp($pattern, $string, TRUE, $message); - } - - /** - * Asserts that a string does not match a given regular expression. - * - * @param string $pattern - * @param string $string - * @param string $message - * @access public - * @static - * @since Method available since Release 2.1.0 - */ - public static function assertNotRegExp($pattern, $string, $message = '') { - self::doAssertRegExp($pattern, $string, FALSE, $message); - } - - /** - * @param mixed $pattern - * @param mixed $string - * @param boolean $condition - * @param string $message - * @access private - * @static - * @since Method available since Release 2.2.0 - */ - private static function doAssertRegExp($pattern, $string, $condition, $message) { - if (!is_string($pattern) || !is_string($string)) { - throw new Exception; - } - - $result = preg_match($pattern, $string); - - if ($condition && !$result) { - self::fail( - sprintf( - '%s%s"%s" does not match pattern "%s"', - - $message, - ($message != '') ? ' ' : '', - $string, - $pattern - ) - ); - } - - else if (!$condition && $result) { - self::fail( - sprintf( - '%s%s"%s" matches pattern "%s"', - - $message, - ($message != '') ? ' ' : '', - $string, - $pattern - ) - ); - } - } - - /** - * Fails a test with the given message. - * - * @param string $message - * @throws PHPUnit2_Framework_AssertionFailedError - * @access public - * @static - */ - public static function fail($message = '') { - throw new PHPUnit2_Framework_AssertionFailedError($message); - } - - /** - * @param string $message - * @throws PHPUnit2_Framework_AssertionFailedError - * @access private - * @static - */ - private static function failSame($message) { - self::fail( - sprintf( - '%s%sexpected not same', - - $message, - ($message != '') ? ' ' : '' - ) - ); - } - - /** - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @throws PHPUnit2_Framework_AssertionFailedError - * @access private - * @static - */ - private static function failNotSame($expected, $actual, $message) { - if (is_string($expected) && is_string($actual)) { - throw new PHPUnit2_Framework_ComparisonFailure($expected, $actual, $message); - } - - self::fail( - sprintf( - '%s%sexpected same: <%s> was not: <%s>', - - $message, - ($message != '') ? ' ' : '', - self::objectToString($expected), - self::objectToString($actual) - ) - ); - } - - /** - * @param mixed $expected - * @param mixed $actual - * @param string $message - * @access public - * @static - */ - public static function format($expected, $actual, $message) { - return sprintf( - '%s%sexpected: <%s> but was: <%s>', - - $message, - ($message != '') ? ' ' : '', - self::objectToString($expected), - self::objectToString($actual) - ); - } - - /** - * @param boolean $looselyTyped - * @access public - * @static - */ - public static function setLooselyTyped($looselyTyped) { - if (is_bool($looselyTyped)) { - self::$looselyTyped = $looselyTyped; - } - } - - /** - * Converts a value to a string. - * - * @param mixed $value - * @access private - * @static - */ - private static function convertToString($value) { - foreach ($value as $k => $v) { - if (is_array($v)) { - $value[$k] = self::convertToString($value[$k]); - } else if (is_object($v)) { - $value[$k] = self::objectToString($value[$k]); - } else { - settype($value[$k], 'string'); - } - } - - return $value; - } - - /** - * @param mixed $object - * @return string - * @access private - * @static - */ - private static function objectToString($object) { - if (is_array($object) || is_object($object)) { - $object = serialize($object); - } - - return $object; - } - - /** - * Sorts an array recursively by its keys. - * - * @param array $array - * @access private - * @static - * @author Adam Maccabee Trachtenberg - */ - private static function sortArrayRecursively(&$array) { - ksort($array); - - foreach($array as $k => $v) { - if (is_array($v)) { - self::sortArrayRecursively($array[$k]); - } - } - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Assert.php,v 1.45.2.4 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/ComparisonFailure.php'; + +/** + * A set of assert methods. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + * @static + */ +class PHPUnit2_Framework_Assert { + /** + * @var boolean + * @access private + * @static + */ + private static $looselyTyped = FALSE; + + /** + * Protect constructor since it is a static only class. + * + * @access protected + */ + protected function __construct() { + } + + /** + * Asserts that a haystack contains a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @access public + * @static + * @since Method available since Release 2.1.0 + */ + public static function assertContains($needle, $haystack, $message = '') { + self::doAssertContains($needle, $haystack, TRUE, $message); + } + + /** + * Asserts that a haystack does not contain a needle. + * + * @param mixed $needle + * @param mixed $haystack + * @param string $message + * @access public + * @static + * @since Method available since Release 2.1.0 + */ + public static function assertNotContains($needle, $haystack, $message = '') { + self::doAssertContains($needle, $haystack, FALSE, $message); + } + + /** + * @param mixed $needle + * @param mixed $haystack + * @param boolean $condition + * @param string $message + * @throws Exception + * @access private + * @static + * @since Method available since Release 2.2.0 + */ + private static function doAssertContains($needle, $haystack, $condition, $message) { + $found = FALSE; + + if (is_array($haystack) || + (is_object($haystack) && $haystack instanceof Iterator)) { + foreach ($haystack as $straw) { + if ($straw === $needle) { + $found = TRUE; + break; + } + } + } + + else if (is_string($needle) && is_string($haystack)) { + if (strpos($haystack, $needle) !== FALSE) { + $found = TRUE; + } + } + + else { + throw new Exception; + } + + if ($condition && !$found) { + self::fail( + sprintf( + '%s%s"%s" does not contain "%s"', + + $message, + ($message != '') ? ' ' : '', + self::objectToString($haystack), + self::objectToString($needle) + ) + ); + } + + else if (!$condition && $found) { + self::fail( + sprintf( + '%s%s"%s" contains "%s"', + + $message, + ($message != '') ? ' ' : '', + self::objectToString($haystack), + self::objectToString($needle) + ) + ); + } + } + + /** + * Asserts that two variables are equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param mixed $delta + * @access public + * @static + */ + public static function assertEquals($expected, $actual, $message = '', $delta = 0) { + self::doAssertEquals($expected, $actual, $delta, TRUE, $message); + } + + /** + * Asserts that two variables are not equal. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @param mixed $delta + * @access public + * @static + * @since Method available since Release 2.3.0 + */ + public static function assertNotEquals($expected, $actual, $message = '', $delta = 0) { + self::doAssertEquals($expected, $actual, $delta, FALSE, $message); + } + + /** + * @param mixed $expected + * @param mixed $actual + * @param mixed $delta + * @param boolean $condition + * @param string $message + * @access private + * @static + * @since Method available since Release 2.3.0 + */ + private static function doAssertEquals($expected, $actual, $delta, $condition, $message) { + $equal = FALSE; + + if (is_array($expected)) { + if (is_array($actual)) { + self::sortArrayRecursively($actual); + self::sortArrayRecursively($expected); + + if (self::$looselyTyped) { + $actual = self::convertToString($actual); + $expected = self::convertToString($expected); + } + + $equal = (serialize($expected) == serialize($actual)); + } + } + + else if (is_float($expected) && is_float($actual) && is_float($delta)) { + $equal = (abs($expected - $actual) <= $delta); + } + + else { + $equal = (serialize($expected) == serialize($actual)); + } + + if ($condition && !$equal) { + self::failNotSame( + $expected, + $actual, + $message + ); + } + + else if (!$condition && $equal) { + self::failSame( + $expected, + $actual, + $message + ); + } + } + + /** + * Asserts that a condition is true. + * + * @param boolean $condition + * @param string $message + * @throws Exception + * @access public + * @static + */ + public static function assertTrue($condition, $message = '') { + if (is_bool($condition)) { + if (!$condition) { + self::fail($message); + } + } else { + throw new Exception; + } + } + + /** + * Asserts that a condition is false. + * + * @param boolean $condition + * @param string $message + * @throws Exception + * @access public + * @static + */ + public static function assertFalse($condition, $message = '') { + if (is_bool($condition)) { + self::assertTrue(!$condition, $message); + } else { + throw new Exception; + } + } + + /** + * Asserts that a variable is not NULL. + * + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function assertNotNull($actual, $message = '') { + if (is_null($actual)) { + self::fail(self::format('NOT NULL', 'NULL', $message)); + } + } + + /** + * Asserts that a variable is NULL. + * + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function assertNull($actual, $message = '') { + if (!is_null($actual)) { + self::fail(self::format('NULL', 'NOT NULL', $message)); + } + } + + /** + * Asserts that two variables have the same type and value. + * Used on objects, it asserts that two variables reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function assertSame($expected, $actual, $message = '') { + if ($expected !== $actual) { + self::failNotSame($expected, $actual, $message); + } + } + + /** + * Asserts that two variables do not have the same type and value. + * Used on objects, it asserts that two variables do not reference + * the same object. + * + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function assertNotSame($expected, $actual, $message = '') { + if ($expected === $actual) { + self::failSame($expected, $actual, $message); + } + } + + /** + * Asserts that a variable is of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function assertType($expected, $actual, $message = '') { + self::doAssertType($expected, $actual, TRUE, $message); + } + + /** + * Asserts that a variable is not of a given type. + * + * @param string $expected + * @param mixed $actual + * @param string $message + * @access public + * @static + * @since Method available since Release 2.2.0 + */ + public static function assertNotType($expected, $actual, $message = '') { + self::doAssertType($expected, $actual, FALSE, $message); + } + + /** + * @param string $expected + * @param mixed $actual + * @param boolean $condition + * @param string $message + * @access private + * @static + * @since Method available since Release 2.2.0 + */ + private static function doAssertType($expected, $actual, $condition, $message) { + if (!is_string($expected)) { + throw new Exception; + } + + if (is_object($actual)) { + $result = $actual instanceof $expected; + } else { + $result = (gettype($actual) == $expected); + } + + if ($condition && !$result) { + self::failNotSame( + $expected, + $actual, + $message + ); + } + + else if (!$condition && $result) { + self::failSame( + $expected, + $actual, + $message + ); + } + } + + /** + * Asserts that a string matches a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + * @access public + * @static + */ + public static function assertRegExp($pattern, $string, $message = '') { + self::doAssertRegExp($pattern, $string, TRUE, $message); + } + + /** + * Asserts that a string does not match a given regular expression. + * + * @param string $pattern + * @param string $string + * @param string $message + * @access public + * @static + * @since Method available since Release 2.1.0 + */ + public static function assertNotRegExp($pattern, $string, $message = '') { + self::doAssertRegExp($pattern, $string, FALSE, $message); + } + + /** + * @param mixed $pattern + * @param mixed $string + * @param boolean $condition + * @param string $message + * @access private + * @static + * @since Method available since Release 2.2.0 + */ + private static function doAssertRegExp($pattern, $string, $condition, $message) { + if (!is_string($pattern) || !is_string($string)) { + throw new Exception; + } + + $result = preg_match($pattern, $string); + + if ($condition && !$result) { + self::fail( + sprintf( + '%s%s"%s" does not match pattern "%s"', + + $message, + ($message != '') ? ' ' : '', + $string, + $pattern + ) + ); + } + + else if (!$condition && $result) { + self::fail( + sprintf( + '%s%s"%s" matches pattern "%s"', + + $message, + ($message != '') ? ' ' : '', + $string, + $pattern + ) + ); + } + } + + /** + * Fails a test with the given message. + * + * @param string $message + * @throws PHPUnit2_Framework_AssertionFailedError + * @access public + * @static + */ + public static function fail($message = '') { + throw new PHPUnit2_Framework_AssertionFailedError($message); + } + + /** + * @param string $message + * @throws PHPUnit2_Framework_AssertionFailedError + * @access private + * @static + */ + private static function failSame($message) { + self::fail( + sprintf( + '%s%sexpected not same', + + $message, + ($message != '') ? ' ' : '' + ) + ); + } + + /** + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @throws PHPUnit2_Framework_AssertionFailedError + * @access private + * @static + */ + private static function failNotSame($expected, $actual, $message) { + if (is_string($expected) && is_string($actual)) { + throw new PHPUnit2_Framework_ComparisonFailure($expected, $actual, $message); + } + + self::fail( + sprintf( + '%s%sexpected same: <%s> was not: <%s>', + + $message, + ($message != '') ? ' ' : '', + self::objectToString($expected), + self::objectToString($actual) + ) + ); + } + + /** + * @param mixed $expected + * @param mixed $actual + * @param string $message + * @access public + * @static + */ + public static function format($expected, $actual, $message) { + return sprintf( + '%s%sexpected: <%s> but was: <%s>', + + $message, + ($message != '') ? ' ' : '', + self::objectToString($expected), + self::objectToString($actual) + ); + } + + /** + * @param boolean $looselyTyped + * @access public + * @static + */ + public static function setLooselyTyped($looselyTyped) { + if (is_bool($looselyTyped)) { + self::$looselyTyped = $looselyTyped; + } + } + + /** + * Converts a value to a string. + * + * @param mixed $value + * @access private + * @static + */ + private static function convertToString($value) { + foreach ($value as $k => $v) { + if (is_array($v)) { + $value[$k] = self::convertToString($value[$k]); + } else if (is_object($v)) { + $value[$k] = self::objectToString($value[$k]); + } else { + settype($value[$k], 'string'); + } + } + + return $value; + } + + /** + * @param mixed $object + * @return string + * @access private + * @static + */ + private static function objectToString($object) { + if (is_array($object) || is_object($object)) { + $object = serialize($object); + } + + return $object; + } + + /** + * Sorts an array recursively by its keys. + * + * @param array $array + * @access private + * @static + * @author Adam Maccabee Trachtenberg + */ + private static function sortArrayRecursively(&$array) { + ksort($array); + + foreach($array as $k => $v) { + if (is_array($v)) { + self::sortArrayRecursively($array[$k]); + } + } + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/AssertionFailedError.php b/buildscripts/PHPUnit2/Framework/AssertionFailedError.php index d3db50ed..19bb1dc0 100644 --- a/buildscripts/PHPUnit2/Framework/AssertionFailedError.php +++ b/buildscripts/PHPUnit2/Framework/AssertionFailedError.php @@ -1,80 +1,80 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: AssertionFailedError.php,v 1.9.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * Thrown when an assertion failed. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_AssertionFailedError extends Exception { - /** - * Wrapper for getMessage() which is declared as final. - * - * @return string - * @access public - */ - public function toString() { - return $this->getMessage(); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: AssertionFailedError.php,v 1.9.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * Thrown when an assertion failed. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_AssertionFailedError extends Exception { + /** + * Wrapper for getMessage() which is declared as final. + * + * @return string + * @access public + */ + public function toString() { + return $this->getMessage(); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/ComparisonFailure.php b/buildscripts/PHPUnit2/Framework/ComparisonFailure.php index cc8e26e6..6e6e5b3d 100644 --- a/buildscripts/PHPUnit2/Framework/ComparisonFailure.php +++ b/buildscripts/PHPUnit2/Framework/ComparisonFailure.php @@ -1,153 +1,153 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ComparisonFailure.php,v 1.13.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/Assert.php'; -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; - -/** - * Thrown when an assertion for string equality failed. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_ComparisonFailure extends PHPUnit2_Framework_AssertionFailedError { - /** - * @var string - * @access private - */ - private $expected = ''; - - /** - * @var string - * @access private - */ - private $actual = ''; - - /** - * Constructs a comparison failure. - * - * @param string $expected - * @param string $actual - * @param string $message - * @access public - */ - public function __construct($expected, $actual, $message = '') { - parent::__construct($message); - - $this->expected = ($expected === NULL) ? 'NULL' : $expected; - $this->actual = ($actual === NULL) ? 'NULL' : $actual; - } - - /** - * Returns "..." in place of common prefix and "..." in - * place of common suffix between expected and actual. - * - * @return string - * @access public - */ - public function toString() { - $end = min(strlen($this->expected), strlen($this->actual)); - $i = 0; - $j = strlen($this->expected) - 1; - $k = strlen($this->actual) - 1; - - for (; $i < $end; $i++) { - if ($this->expected[$i] != $this->actual[$i]) { - break; - } - } - - for (; $k >= $i && $j >= $i; $k--,$j--) { - if ($this->expected[$j] != $this->actual[$k]) { - break; - } - } - - if ($j < $i && $k < $i) { - $expected = $this->expected; - $actual = $this->actual; - } else { - $expected = substr($this->expected, $i, ($j + 1 - $i)); - $actual = substr($this->actual, $i, ($k + 1 - $i));; - - if ($i <= $end && $i > 0) { - $expected = '...' . $expected; - $actual = '...' . $actual; - } - - if ($j < strlen($this->expected) - 1) { - $expected .= '...'; - } - - if ($k < strlen($this->actual) - 1) { - $actual .= '...'; - } - } - - return PHPUnit2_Framework_Assert::format( - $expected, - $actual, - parent::getMessage() - ); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: ComparisonFailure.php,v 1.13.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/Assert.php'; +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; + +/** + * Thrown when an assertion for string equality failed. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_ComparisonFailure extends PHPUnit2_Framework_AssertionFailedError { + /** + * @var string + * @access private + */ + private $expected = ''; + + /** + * @var string + * @access private + */ + private $actual = ''; + + /** + * Constructs a comparison failure. + * + * @param string $expected + * @param string $actual + * @param string $message + * @access public + */ + public function __construct($expected, $actual, $message = '') { + parent::__construct($message); + + $this->expected = ($expected === NULL) ? 'NULL' : $expected; + $this->actual = ($actual === NULL) ? 'NULL' : $actual; + } + + /** + * Returns "..." in place of common prefix and "..." in + * place of common suffix between expected and actual. + * + * @return string + * @access public + */ + public function toString() { + $end = min(strlen($this->expected), strlen($this->actual)); + $i = 0; + $j = strlen($this->expected) - 1; + $k = strlen($this->actual) - 1; + + for (; $i < $end; $i++) { + if ($this->expected[$i] != $this->actual[$i]) { + break; + } + } + + for (; $k >= $i && $j >= $i; $k--,$j--) { + if ($this->expected[$j] != $this->actual[$k]) { + break; + } + } + + if ($j < $i && $k < $i) { + $expected = $this->expected; + $actual = $this->actual; + } else { + $expected = substr($this->expected, $i, ($j + 1 - $i)); + $actual = substr($this->actual, $i, ($k + 1 - $i));; + + if ($i <= $end && $i > 0) { + $expected = '...' . $expected; + $actual = '...' . $actual; + } + + if ($j < strlen($this->expected) - 1) { + $expected .= '...'; + } + + if ($k < strlen($this->actual) - 1) { + $actual .= '...'; + } + } + + return PHPUnit2_Framework_Assert::format( + $expected, + $actual, + parent::getMessage() + ); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/Error.php b/buildscripts/PHPUnit2/Framework/Error.php index a4bd4fd2..2f3a3c16 100644 --- a/buildscripts/PHPUnit2/Framework/Error.php +++ b/buildscripts/PHPUnit2/Framework/Error.php @@ -1,88 +1,88 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Error.php,v 1.4.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.2.0 - */ - -/** - * Wrapper for PHP errors. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.2.0 - */ -class PHPUnit2_Framework_Error extends Exception { - /** - * Constructor. - * - * @param string $message - * @param integer $code - * @param string $file - * @param integer $line - * @param array $trace - * @access public - */ - public function __construct($message, $code, $file, $line, $trace) { - parent::__construct($message, $code); - - $this->file = $file; - $this->line = $line; - $this->trace = $trace; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Error.php,v 1.4.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.2.0 + */ + +/** + * Wrapper for PHP errors. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.2.0 + */ +class PHPUnit2_Framework_Error extends Exception { + /** + * Constructor. + * + * @param string $message + * @param integer $code + * @param string $file + * @param integer $line + * @param array $trace + * @access public + */ + public function __construct($message, $code, $file, $line, $trace) { + parent::__construct($message, $code); + + $this->file = $file; + $this->line = $line; + $this->trace = $trace; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/IncompleteTest.php b/buildscripts/PHPUnit2/Framework/IncompleteTest.php index 325e6411..0c0192a9 100644 --- a/buildscripts/PHPUnit2/Framework/IncompleteTest.php +++ b/buildscripts/PHPUnit2/Framework/IncompleteTest.php @@ -1,72 +1,72 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IncompleteTest.php,v 1.6.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * A marker interface for marking any exception/error as result of an unit - * test as incomplete implementation or currently not implemented. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit2_Framework_IncompleteTest { -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: IncompleteTest.php,v 1.6.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * A marker interface for marking any exception/error as result of an unit + * test as incomplete implementation or currently not implemented. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit2_Framework_IncompleteTest { +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/IncompleteTestError.php b/buildscripts/PHPUnit2/Framework/IncompleteTestError.php index 6c2a0660..e0170b69 100644 --- a/buildscripts/PHPUnit2/Framework/IncompleteTestError.php +++ b/buildscripts/PHPUnit2/Framework/IncompleteTestError.php @@ -1,75 +1,75 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IncompleteTestError.php,v 1.5.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/IncompleteTest.php'; - -/** - * Extension to PHPUnit2_Framework_AssertionFailedError to mark the special - * case of an incomplete test. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_IncompleteTestError extends PHPUnit2_Framework_AssertionFailedError implements PHPUnit2_Framework_IncompleteTest { -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: IncompleteTestError.php,v 1.5.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/IncompleteTest.php'; + +/** + * Extension to PHPUnit2_Framework_AssertionFailedError to mark the special + * case of an incomplete test. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_IncompleteTestError extends PHPUnit2_Framework_AssertionFailedError implements PHPUnit2_Framework_IncompleteTest { +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/Test.php b/buildscripts/PHPUnit2/Framework/Test.php index 1d198f1a..f0b98dc7 100644 --- a/buildscripts/PHPUnit2/Framework/Test.php +++ b/buildscripts/PHPUnit2/Framework/Test.php @@ -1,87 +1,87 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Test.php,v 1.12.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * A Test can be run and collect its results. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit2_Framework_Test { - /** - * Counts the number of test cases that will be run by this test. - * - * @return integer - * @access public - */ - public function countTestCases(); - - /** - * Runs a test and collects its result in a TestResult instance. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @access public - */ - public function run($result = NULL); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Test.php,v 1.12.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * A Test can be run and collect its results. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit2_Framework_Test { + /** + * Counts the number of test cases that will be run by this test. + * + * @return integer + * @access public + */ + public function countTestCases(); + + /** + * Runs a test and collects its result in a TestResult instance. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @access public + */ + public function run($result = NULL); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/TestCase.php b/buildscripts/PHPUnit2/Framework/TestCase.php index 80f56932..b8e6a22e 100644 --- a/buildscripts/PHPUnit2/Framework/TestCase.php +++ b/buildscripts/PHPUnit2/Framework/TestCase.php @@ -1,292 +1,292 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestCase.php,v 1.32.2.5 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/Assert.php'; -require_once 'PHPUnit2/Framework/Error.php'; -require_once 'PHPUnit2/Framework/Test.php'; -require_once 'PHPUnit2/Framework/TestResult.php'; - -/** - * A TestCase defines the fixture to run multiple tests. - * - * To define a TestCase - * - * 1) Implement a subclass of PHPUnit2_Framework_TestCase. - * 2) Define instance variables that store the state of the fixture. - * 3) Initialize the fixture state by overriding setUp(). - * 4) Clean-up after a test by overriding tearDown(). - * - * Each test runs in its own fixture so there can be no side effects - * among test runs. - * - * Here is an example: - * - * - * value1 = 2; - * $this->value2 = 3; - * } - * } - * ?> - * - * - * For each test implement a method which interacts with the fixture. - * Verify the expected results with assertions specified by calling - * assert with a boolean. - * - * - * assertTrue($this->value1 + $this->value2 == 5); - * } - * ?> - * - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - * @abstract - */ -abstract class PHPUnit2_Framework_TestCase extends PHPUnit2_Framework_Assert implements PHPUnit2_Framework_Test { - /** - * The name of the test case. - * - * @var string - * @access private - */ - private $name = NULL; - - /** - * Constructs a test case with the given name. - * - * @param string - * @access public - */ - public function __construct($name = NULL) { - if ($name !== NULL) { - $this->setName($name); - } - } - - /** - * Returns a string representation of the test case. - * - * @return string - * @access public - */ - public function toString() { - $class = new ReflectionClass($this); - - return sprintf( - '%s(%s)', - - $this->getName(), - $class->name - ); - } - - /** - * Counts the number of test cases executed by run(TestResult result). - * - * @return integer - * @access public - */ - public function countTestCases() { - return 1; - } - - /** - * Gets the name of a TestCase. - * - * @return string - * @access public - */ - public function getName() { - return $this->name; - } - - /** - * Runs the test case and collects the results in a TestResult object. - * If no TestResult object is passed a new one will be created. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @throws Exception - * @access public - */ - public function run($result = NULL) { - if ($result === NULL) { - $result = $this->createResult(); - } - - // XXX: Workaround for missing ability to declare type-hinted parameters as optional. - else if (!($result instanceof PHPUnit2_Framework_TestResult)) { - throw new Exception( - 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' - ); - } - - $result->run($this); - - return $result; - } - - /** - * Runs the bare test sequence. - * - * @access public - */ - public function runBare() { - $catchedException = NULL; - - $this->setUp(); - - try { - $this->runTest(); - } - - catch (Exception $e) { - $catchedException = $e; - } - - $this->tearDown(); - - // Workaround for missing "finally". - if ($catchedException !== NULL) { - throw $catchedException; - } - } - - /** - * Override to run the test and assert its state. - * - * @throws PHPUnit2_Framework_Error - * @access protected - */ - protected function runTest() { - if ($this->name === NULL) { - throw new PHPUnit2_Framework_Error( - 'PHPUnit2_Framework_TestCase::$name must not be NULL.' - ); - } - - try { - $class = new ReflectionClass($this); - $method = $class->getMethod($this->name); - } - - catch (ReflectionException $e) { - $this->fail($e->getMessage()); - } - - $method->invoke($this); - } - - /** - * Sets the name of a TestCase. - * - * @param string - * @access public - */ - public function setName($name) { - $this->name = $name; - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit2_Framework_TestResult - * @access protected - */ - protected function createResult() { - return new PHPUnit2_Framework_TestResult; - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() { - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() { - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestCase.php,v 1.32.2.5 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/Assert.php'; +require_once 'PHPUnit2/Framework/Error.php'; +require_once 'PHPUnit2/Framework/Test.php'; +require_once 'PHPUnit2/Framework/TestResult.php'; + +/** + * A TestCase defines the fixture to run multiple tests. + * + * To define a TestCase + * + * 1) Implement a subclass of PHPUnit2_Framework_TestCase. + * 2) Define instance variables that store the state of the fixture. + * 3) Initialize the fixture state by overriding setUp(). + * 4) Clean-up after a test by overriding tearDown(). + * + * Each test runs in its own fixture so there can be no side effects + * among test runs. + * + * Here is an example: + * + * + * value1 = 2; + * $this->value2 = 3; + * } + * } + * ?> + * + * + * For each test implement a method which interacts with the fixture. + * Verify the expected results with assertions specified by calling + * assert with a boolean. + * + * + * assertTrue($this->value1 + $this->value2 == 5); + * } + * ?> + * + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + * @abstract + */ +abstract class PHPUnit2_Framework_TestCase extends PHPUnit2_Framework_Assert implements PHPUnit2_Framework_Test { + /** + * The name of the test case. + * + * @var string + * @access private + */ + private $name = NULL; + + /** + * Constructs a test case with the given name. + * + * @param string + * @access public + */ + public function __construct($name = NULL) { + if ($name !== NULL) { + $this->setName($name); + } + } + + /** + * Returns a string representation of the test case. + * + * @return string + * @access public + */ + public function toString() { + $class = new ReflectionClass($this); + + return sprintf( + '%s(%s)', + + $this->getName(), + $class->name + ); + } + + /** + * Counts the number of test cases executed by run(TestResult result). + * + * @return integer + * @access public + */ + public function countTestCases() { + return 1; + } + + /** + * Gets the name of a TestCase. + * + * @return string + * @access public + */ + public function getName() { + return $this->name; + } + + /** + * Runs the test case and collects the results in a TestResult object. + * If no TestResult object is passed a new one will be created. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @throws Exception + * @access public + */ + public function run($result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); + } + + // XXX: Workaround for missing ability to declare type-hinted parameters as optional. + else if (!($result instanceof PHPUnit2_Framework_TestResult)) { + throw new Exception( + 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' + ); + } + + $result->run($this); + + return $result; + } + + /** + * Runs the bare test sequence. + * + * @access public + */ + public function runBare() { + $catchedException = NULL; + + $this->setUp(); + + try { + $this->runTest(); + } + + catch (Exception $e) { + $catchedException = $e; + } + + $this->tearDown(); + + // Workaround for missing "finally". + if ($catchedException !== NULL) { + throw $catchedException; + } + } + + /** + * Override to run the test and assert its state. + * + * @throws PHPUnit2_Framework_Error + * @access protected + */ + protected function runTest() { + if ($this->name === NULL) { + throw new PHPUnit2_Framework_Error( + 'PHPUnit2_Framework_TestCase::$name must not be NULL.' + ); + } + + try { + $class = new ReflectionClass($this); + $method = $class->getMethod($this->name); + } + + catch (ReflectionException $e) { + $this->fail($e->getMessage()); + } + + $method->invoke($this); + } + + /** + * Sets the name of a TestCase. + * + * @param string + * @access public + */ + public function setName($name) { + $this->name = $name; + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit2_Framework_TestResult + * @access protected + */ + protected function createResult() { + return new PHPUnit2_Framework_TestResult; + } + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + * @access protected + */ + protected function setUp() { + } + + /** + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + * + * @access protected + */ + protected function tearDown() { + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/TestFailure.php b/buildscripts/PHPUnit2/Framework/TestFailure.php index 4957e4e6..848fbfa1 100644 --- a/buildscripts/PHPUnit2/Framework/TestFailure.php +++ b/buildscripts/PHPUnit2/Framework/TestFailure.php @@ -1,154 +1,154 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestFailure.php,v 1.10.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/Test.php'; - -/** - * A TestFailure collects a failed test together with the caught exception. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_TestFailure { - /** - * @var PHPUnit2_Framework_Test - * @access protected - */ - protected $failedTest; - - /** - * @var Exception - * @access protected - */ - protected $thrownException; - - /** - * Constructs a TestFailure with the given test and exception. - * - * @param PHPUnit2_Framework_Test $failedTest - * @param Exception $thrownException - * @access public - */ - public function __construct(PHPUnit2_Framework_Test $failedTest, Exception $thrownException) { - $this->failedTest = $failedTest; - $this->thrownException = $thrownException; - } - - /** - * Returns a short description of the failure. - * - * @return string - * @access public - */ - public function toString() { - return sprintf( - '%s: %s', - - $this->failedTest, - $this->thrownException->getMessage() - ); - } - - /** - * Gets the failed test. - * - * @return Test - * @access public - */ - public function failedTest() { - return $this->failedTest; - } - - /** - * Gets the thrown exception. - * - * @return Exception - * @access public - */ - public function thrownException() { - return $this->thrownException; - } - - /** - * Returns the exception's message. - * - * @return string - * @access public - */ - public function exceptionMessage() { - return $this->thrownException()->getMessage(); - } - - /** - * Returns TRUE if the thrown exception - * is of type AssertionFailedError. - * - * @return boolean - * @access public - */ - public function isFailure() { - return ($this->thrownException() instanceof PHPUnit2_Framework_AssertionFailedError); - } -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestFailure.php,v 1.10.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/Test.php'; + +/** + * A TestFailure collects a failed test together with the caught exception. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_TestFailure { + /** + * @var PHPUnit2_Framework_Test + * @access protected + */ + protected $failedTest; + + /** + * @var Exception + * @access protected + */ + protected $thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + * + * @param PHPUnit2_Framework_Test $failedTest + * @param Exception $thrownException + * @access public + */ + public function __construct(PHPUnit2_Framework_Test $failedTest, Exception $thrownException) { + $this->failedTest = $failedTest; + $this->thrownException = $thrownException; + } + + /** + * Returns a short description of the failure. + * + * @return string + * @access public + */ + public function toString() { + return sprintf( + '%s: %s', + + $this->failedTest, + $this->thrownException->getMessage() + ); + } + + /** + * Gets the failed test. + * + * @return Test + * @access public + */ + public function failedTest() { + return $this->failedTest; + } + + /** + * Gets the thrown exception. + * + * @return Exception + * @access public + */ + public function thrownException() { + return $this->thrownException; + } + + /** + * Returns the exception's message. + * + * @return string + * @access public + */ + public function exceptionMessage() { + return $this->thrownException()->getMessage(); + } + + /** + * Returns TRUE if the thrown exception + * is of type AssertionFailedError. + * + * @return boolean + * @access public + */ + public function isFailure() { + return ($this->thrownException() instanceof PHPUnit2_Framework_AssertionFailedError); + } +} + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/TestListener.php b/buildscripts/PHPUnit2/Framework/TestListener.php index 79f11ffb..5a4dcb1a 100644 --- a/buildscripts/PHPUnit2/Framework/TestListener.php +++ b/buildscripts/PHPUnit2/Framework/TestListener.php @@ -1,135 +1,135 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestListener.php,v 1.11.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/TestSuite.php'; - -/** - * A Listener for test progress. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit2_Framework_TestListener { - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e); - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e); - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e); - - /** - * A test suite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite); - - /** - * A test suite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite); - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test); - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test); -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestListener.php,v 1.11.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/TestSuite.php'; + +/** + * A Listener for test progress. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit2_Framework_TestListener { + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e); + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e); + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e); + + /** + * A test suite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite); + + /** + * A test suite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite); + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test); + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test); +} + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/TestResult.php b/buildscripts/PHPUnit2/Framework/TestResult.php index 17adb529..0cb854c7 100644 --- a/buildscripts/PHPUnit2/Framework/TestResult.php +++ b/buildscripts/PHPUnit2/Framework/TestResult.php @@ -1,447 +1,447 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestResult.php,v 1.32.2.7 2006/02/25 09:44:23 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/IncompleteTest.php'; -require_once 'PHPUnit2/Framework/TestFailure.php'; -require_once 'PHPUnit2/Framework/TestListener.php'; -require_once 'PHPUnit2/Util/ErrorHandler.php'; -require_once 'PHPUnit2/Util/Filter.php'; - -/** - * A TestResult collects the results of executing a test case. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_TestResult { - /** - * @var array - * @access protected - */ - protected $errors = array(); - - /** - * @var array - * @access protected - */ - protected $failures = array(); - - /** - * @var array - * @access protected - */ - protected $notImplemented = array(); - - /** - * @var array - * @access protected - */ - protected $listeners = array(); - - /** - * @var integer - * @access protected - */ - protected $runTests = 0; - - /** - * Code Coverage information provided by Xdebug. - * - * @var array - * @access protected - */ - protected $codeCoverageInformation = array(); - - /** - * @var boolean - * @access protected - */ - protected $collectCodeCoverageInformation = FALSE; - - /** - * @var boolean - * @access private - */ - private $stop = FALSE; - - /** - * Registers a TestListener. - * - * @param PHPUnit2_Framework_TestListener - * @access public - */ - public function addListener(PHPUnit2_Framework_TestListener $listener) { - $this->listeners[] = $listener; - } - - /** - * Unregisters a TestListener. - * - * @param PHPUnit2_Framework_TestListener $listener - * @access public - */ - public function removeListener(PHPUnit2_Framework_TestListener $listener) { - for ($i = 0; $i < sizeof($this->listeners); $i++) { - if ($this->listeners[$i] === $listener) { - unset($this->listeners[$i]); - } - } - } - - /** - * Adds an error to the list of errors. - * The passed in exception caused the error. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - if ($e instanceof PHPUnit2_Framework_IncompleteTest) { - $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); - - foreach ($this->listeners as $listener) { - $listener->addIncompleteTest($test, $e); - } - } else { - $this->errors[] = new PHPUnit2_Framework_TestFailure($test, $e); - - foreach ($this->listeners as $listener) { - $listener->addError($test, $e); - } - } - } - - /** - * Adds a failure to the list of failures. - * The passed in exception caused the failure. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - if ($e instanceof PHPUnit2_Framework_IncompleteTest) { - $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); - - foreach ($this->listeners as $listener) { - $listener->addIncompleteTest($test, $e); - } - } else { - $this->failures[] = new PHPUnit2_Framework_TestFailure($test, $e); - - foreach ($this->listeners as $listener) { - $listener->addFailure($test, $e); - } - } - } - - /** - * Informs the result that a testsuite will be started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - foreach ($this->listeners as $listener) { - $listener->startTestSuite($suite); - } - } - - /** - * Informs the result that a testsuite was completed. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - foreach ($this->listeners as $listener) { - $listener->endTestSuite($suite); - } - } - - /** - * Informs the result that a test will be started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - $this->runTests += $test->countTestCases(); - - foreach ($this->listeners as $listener) { - $listener->startTest($test); - } - } - - /** - * Informs the result that a test was completed. - * - * @param PHPUnit2_Framework_Test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - foreach ($this->listeners as $listener) { - $listener->endTest($test); - } - } - - /** - * Returns TRUE if no incomplete test occured. - * - * @return boolean - * @access public - */ - public function allCompletlyImplemented() { - return $this->notImplementedCount() == 0; - } - - /** - * Gets the number of incomplete tests. - * - * @return integer - * @access public - */ - public function notImplementedCount() { - return sizeof($this->notImplemented); - } - - /** - * Returns an Enumeration for the incomplete tests. - * - * @return array - * @access public - */ - public function notImplemented() { - return $this->notImplemented; - } - - /** - * Gets the number of detected errors. - * - * @return integer - * @access public - */ - public function errorCount() { - return sizeof($this->errors); - } - - /** - * Returns an Enumeration for the errors. - * - * @return array - * @access public - */ - public function errors() { - return $this->errors; - } - - /** - * Gets the number of detected failures. - * - * @return integer - * @access public - */ - public function failureCount() { - return sizeof($this->failures); - } - - /** - * Returns an Enumeration for the failures. - * - * @return array - * @access public - */ - public function failures() { - return $this->failures; - } - - /** - * Enables or disables the collection of Code Coverage information. - * - * @param boolean $flag - * @throws Exception - * @access public - * @since Method available since Release 2.3.0 - */ - public function collectCodeCoverageInformation($flag) { - if (is_bool($flag)) { - $this->collectCodeCoverageInformation = $flag; - } else { - throw new Exception; - } - } - - /** - * Returns Code Coverage data per test case. - * - * Format of the result array: - * - * - * array( - * "testCase" => array( - * "/tested/code.php" => array( - * linenumber => flag - * ) - * ) - * ) - * - * - * flag < 0: Line is executable but was not executed. - * flag > 0: Line was executed. - * - * @return array - * @access public - */ - public function getCodeCoverageInformation() { - return $this->codeCoverageInformation; - } - - /** - * Runs a TestCase. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function run(PHPUnit2_Framework_Test $test) { - $this->startTest($test); - - set_error_handler('PHPUnit2_Util_ErrorHandler', E_USER_ERROR); - - $useXdebug = (extension_loaded('xdebug') && $this->collectCodeCoverageInformation); - - if ($useXdebug) { - xdebug_start_code_coverage(XDEBUG_CC_UNUSED); - } - - $globalsBackup = $GLOBALS; - - try { - $test->runBare(); - } - - catch (PHPUnit2_Framework_AssertionFailedError $e) { - $this->addFailure($test, $e); - } - - catch (Exception $e) { - $this->addError($test, $e); - } - - $GLOBALS = $globalsBackup; - - if ($useXdebug) { - $this->codeCoverageInformation[$test->getName()] = PHPUnit2_Util_Filter::getFilteredCodeCoverage( - xdebug_get_code_coverage() - ); - - xdebug_stop_code_coverage(); - } - - restore_error_handler(); - - $this->endTest($test); - } - - /** - * Gets the number of run tests. - * - * @return integer - * @access public - */ - public function runCount() { - return $this->runTests; - } - - /** - * Checks whether the test run should stop. - * - * @return boolean - * @access public - */ - public function shouldStop() { - return $this->stop; - } - - /** - * Marks that the test run should stop. - * - * @access public - */ - public function stop() { - $this->stop = TRUE; - } - - /** - * Returns whether the entire test was successful or not. - * - * @return boolean - * @access public - */ - public function wasSuccessful() { - return empty($this->errors) && empty($this->failures); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestResult.php,v 1.32.2.7 2006/02/25 09:44:23 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/IncompleteTest.php'; +require_once 'PHPUnit2/Framework/TestFailure.php'; +require_once 'PHPUnit2/Framework/TestListener.php'; +require_once 'PHPUnit2/Util/ErrorHandler.php'; +require_once 'PHPUnit2/Util/Filter.php'; + +/** + * A TestResult collects the results of executing a test case. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_TestResult { + /** + * @var array + * @access protected + */ + protected $errors = array(); + + /** + * @var array + * @access protected + */ + protected $failures = array(); + + /** + * @var array + * @access protected + */ + protected $notImplemented = array(); + + /** + * @var array + * @access protected + */ + protected $listeners = array(); + + /** + * @var integer + * @access protected + */ + protected $runTests = 0; + + /** + * Code Coverage information provided by Xdebug. + * + * @var array + * @access protected + */ + protected $codeCoverageInformation = array(); + + /** + * @var boolean + * @access protected + */ + protected $collectCodeCoverageInformation = FALSE; + + /** + * @var boolean + * @access private + */ + private $stop = FALSE; + + /** + * Registers a TestListener. + * + * @param PHPUnit2_Framework_TestListener + * @access public + */ + public function addListener(PHPUnit2_Framework_TestListener $listener) { + $this->listeners[] = $listener; + } + + /** + * Unregisters a TestListener. + * + * @param PHPUnit2_Framework_TestListener $listener + * @access public + */ + public function removeListener(PHPUnit2_Framework_TestListener $listener) { + for ($i = 0; $i < sizeof($this->listeners); $i++) { + if ($this->listeners[$i] === $listener) { + unset($this->listeners[$i]); + } + } + } + + /** + * Adds an error to the list of errors. + * The passed in exception caused the error. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addIncompleteTest($test, $e); + } + } else { + $this->errors[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addError($test, $e); + } + } + } + + /** + * Adds a failure to the list of failures. + * The passed in exception caused the failure. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addIncompleteTest($test, $e); + } + } else { + $this->failures[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addFailure($test, $e); + } + } + } + + /** + * Informs the result that a testsuite will be started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + foreach ($this->listeners as $listener) { + $listener->startTestSuite($suite); + } + } + + /** + * Informs the result that a testsuite was completed. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + foreach ($this->listeners as $listener) { + $listener->endTestSuite($suite); + } + } + + /** + * Informs the result that a test will be started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + $this->runTests += $test->countTestCases(); + + foreach ($this->listeners as $listener) { + $listener->startTest($test); + } + } + + /** + * Informs the result that a test was completed. + * + * @param PHPUnit2_Framework_Test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + foreach ($this->listeners as $listener) { + $listener->endTest($test); + } + } + + /** + * Returns TRUE if no incomplete test occured. + * + * @return boolean + * @access public + */ + public function allCompletlyImplemented() { + return $this->notImplementedCount() == 0; + } + + /** + * Gets the number of incomplete tests. + * + * @return integer + * @access public + */ + public function notImplementedCount() { + return sizeof($this->notImplemented); + } + + /** + * Returns an Enumeration for the incomplete tests. + * + * @return array + * @access public + */ + public function notImplemented() { + return $this->notImplemented; + } + + /** + * Gets the number of detected errors. + * + * @return integer + * @access public + */ + public function errorCount() { + return sizeof($this->errors); + } + + /** + * Returns an Enumeration for the errors. + * + * @return array + * @access public + */ + public function errors() { + return $this->errors; + } + + /** + * Gets the number of detected failures. + * + * @return integer + * @access public + */ + public function failureCount() { + return sizeof($this->failures); + } + + /** + * Returns an Enumeration for the failures. + * + * @return array + * @access public + */ + public function failures() { + return $this->failures; + } + + /** + * Enables or disables the collection of Code Coverage information. + * + * @param boolean $flag + * @throws Exception + * @access public + * @since Method available since Release 2.3.0 + */ + public function collectCodeCoverageInformation($flag) { + if (is_bool($flag)) { + $this->collectCodeCoverageInformation = $flag; + } else { + throw new Exception; + } + } + + /** + * Returns Code Coverage data per test case. + * + * Format of the result array: + * + * + * array( + * "testCase" => array( + * "/tested/code.php" => array( + * linenumber => flag + * ) + * ) + * ) + * + * + * flag < 0: Line is executable but was not executed. + * flag > 0: Line was executed. + * + * @return array + * @access public + */ + public function getCodeCoverageInformation() { + return $this->codeCoverageInformation; + } + + /** + * Runs a TestCase. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function run(PHPUnit2_Framework_Test $test) { + $this->startTest($test); + + set_error_handler('PHPUnit2_Util_ErrorHandler', E_USER_ERROR); + + $useXdebug = (extension_loaded('xdebug') && $this->collectCodeCoverageInformation); + + if ($useXdebug) { + xdebug_start_code_coverage(XDEBUG_CC_UNUSED); + } + + $globalsBackup = $GLOBALS; + + try { + $test->runBare(); + } + + catch (PHPUnit2_Framework_AssertionFailedError $e) { + $this->addFailure($test, $e); + } + + catch (Exception $e) { + $this->addError($test, $e); + } + + $GLOBALS = $globalsBackup; + + if ($useXdebug) { + $this->codeCoverageInformation[$test->getName()] = PHPUnit2_Util_Filter::getFilteredCodeCoverage( + xdebug_get_code_coverage() + ); + + xdebug_stop_code_coverage(); + } + + restore_error_handler(); + + $this->endTest($test); + } + + /** + * Gets the number of run tests. + * + * @return integer + * @access public + */ + public function runCount() { + return $this->runTests; + } + + /** + * Checks whether the test run should stop. + * + * @return boolean + * @access public + */ + public function shouldStop() { + return $this->stop; + } + + /** + * Marks that the test run should stop. + * + * @access public + */ + public function stop() { + $this->stop = TRUE; + } + + /** + * Returns whether the entire test was successful or not. + * + * @return boolean + * @access public + */ + public function wasSuccessful() { + return empty($this->errors) && empty($this->failures); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/TestSuite.php b/buildscripts/PHPUnit2/Framework/TestSuite.php index 3d5d670e..12c4ce5a 100644 --- a/buildscripts/PHPUnit2/Framework/TestSuite.php +++ b/buildscripts/PHPUnit2/Framework/TestSuite.php @@ -1,554 +1,554 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestSuite.php,v 1.26.2.11 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/Test.php'; -require_once 'PHPUnit2/Framework/TestCase.php'; -require_once 'PHPUnit2/Framework/TestResult.php'; -require_once 'PHPUnit2/Runner/BaseTestRunner.php'; -require_once 'PHPUnit2/Util/Fileloader.php'; - -/** - * A TestSuite is a composite of Tests. It runs a collection of test cases. - * - * Here is an example using the dynamic test definition. - * - * - * addTest(new MathTest('testPass')); - * ?> - * - * - * Alternatively, a TestSuite can extract the tests to be run automatically. - * To do so you pass a ReflectionClass instance for your - * PHPUnit2_Framework_TestCase class to the PHPUnit2_Framework_TestSuite - * constructor. - * - * - * - * - * - * This constructor creates a suite with all the methods starting with - * "test" that take no arguments. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_TestSuite implements PHPUnit2_Framework_Test { - /** - * The name of the test suite. - * - * @var string - * @access private - */ - private $name = ''; - - /** - * The tests in the test suite. - * - * @var array - * @access private - */ - private $tests = array(); - - /** - * Constructs a new TestSuite: - * - * - PHPUnit2_Framework_TestSuite() constructs an empty TestSuite. - * - * - PHPUnit2_Framework_TestSuite(ReflectionClass) constructs a - * TestSuite from the given class. - * - * - PHPUnit2_Framework_TestSuite(ReflectionClass, String) - * constructs a TestSuite from the given class with the given - * name. - * - * - PHPUnit2_Framework_TestSuite(String) either constructs a - * TestSuite from the given class (if the passed string is the - * name of an existing class) or constructs an empty TestSuite - * with the given name. - * - * @param mixed $theClass - * @param string $name - * @throws Exception - * @access public - */ - public function __construct($theClass = '', $name = '') { - $argumentsValid = FALSE; - - if (is_object($theClass) && - $theClass instanceof ReflectionClass) { - $argumentsValid = TRUE; - } - - else if (is_string($theClass) && $theClass !== '' && class_exists($theClass)) { - $argumentsValid = TRUE; - - if ($name == '') { - $name = $theClass; - } - - $theClass = new ReflectionClass($theClass); - } - - else if (is_string($theClass)) { - $this->setName($theClass); - return; - } - - if (!$argumentsValid) { - throw new Exception; - } - - if ($name != '') { - $this->setName($name); - } else { - $this->setName($theClass->getName()); - } - - $constructor = $theClass->getConstructor(); - - if ($constructor === NULL || - !$constructor->isPublic()) { - $this->addTest( - self::warning( - sprintf( - 'Class %s has no public constructor', - - $theClass->getName() - ) - ) - ); - - return; - } - - $methods = $theClass->getMethods(); - $names = array(); - - foreach ($methods as $method) { - $this->addTestMethod($method, $names, $theClass); - } - - if (empty($this->tests)) { - $this->addTest( - self::warning( - sprintf( - 'No tests found in %s', - - $theClass->getName() - ) - ) - ); - } - } - - /** - * Returns a string representation of the test suite. - * - * @return string - * @access public - */ - public function toString() { - return $this->getName(); - } - - /** - * Adds a test to the suite. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function addTest(PHPUnit2_Framework_Test $test) { - $this->tests[] = $test; - } - - /** - * Adds the tests from the given class to the suite. - * - * @param mixed $testClass - * @access public - */ - public function addTestSuite($testClass) { - if (is_string($testClass) && - class_exists($testClass)) { - $testClass = new ReflectionClass($testClass); - } - - if (is_object($testClass) && - $testClass instanceof ReflectionClass) { - $this->addTest(new PHPUnit2_Framework_TestSuite($testClass)); - } - } - - /** - * Wraps both addTest() and addTestSuite - * as well as the separate import statements for the user's convenience. - * - * If the named file cannot be read or there are no new tests that can be - * added, a PHPUnit2_Framework_Warning will be created instead, - * leaving the current test run untouched. - * - * @param string $filename - * @throws Exception - * @access public - * @since Method available since Release 2.3.0 - * @author Stefano F. Rausch - */ - public function addTestFile($filename) { - if (!is_string($filename) || !file_exists($filename)) { - throw new Exception; - } - - $declaredClasses = get_declared_classes(); - - PHPUnit2_Util_Fileloader::checkAndLoad($filename); - - $newClasses = array_values( - array_diff(get_declared_classes(), $declaredClasses) - ); - - $testsFound = 0; - - foreach ($newClasses as $class) { - if (preg_match('"Tests?$"', $class)) { - try { - $suiteMethod = new ReflectionMethod( - $class, PHPUnit2_Runner_BaseTestRunner::SUITE_METHODNAME - ); - - $this->addTest($suiteMethod->invoke(NULL)); - } catch (ReflectionException $e) { - $this->addTestSuite(new ReflectionClass($class)); - } - - $testsFound++; - } - } - - if ($testsFound == 0) { - $this->addTest( - new PHPUnit2_Framework_Warning('No tests found in file ' . $filename) - ); - } - } - - /** - * Wrapper for addTestFile() that adds multiple test files. - * - * @param Array $filenames - * @throws Exception - * @access public - * @since Method available since Release 2.3.0 - */ - public function addTestFiles($filenames) { - foreach ($filenames as $filename) { - $this->addTestFile($filename); - } - } - - /** - * Counts the number of test cases that will be run by this test. - * - * @return integer - * @access public - */ - public function countTestCases() { - $count = 0; - - foreach ($this->tests as $test) { - $count += $test->countTestCases(); - } - - return $count; - } - - /** - * @param ReflectionClass $theClass - * @param string $name - * @return PHPUnit2_Framework_Test - * @access public - * @static - */ - public static function createTest(ReflectionClass $theClass, $name) { - if (!$theClass->isInstantiable()) { - return self::warning( - sprintf( - 'Cannot instantiate test case %s.', - $theClass->getName() - ) - ); - } - - $constructor = $theClass->getConstructor(); - - if ($constructor !== NULL) { - $parameters = $constructor->getParameters(); - - if (sizeof($parameters) == 0) { - $test = $theClass->newInstance(); - - if ($test instanceof PHPUnit2_Framework_TestCase) { - $test->setName($name); - } - } - - else if (sizeof($parameters) == 1 && - $parameters[0]->getClass() === NULL) { - $test = $theClass->newInstance($name); - } - - else { - return self::warning( - sprintf( - 'Constructor of class %s is not TestCase($name) or TestCase().', - $theClass->getName() - ) - ); - } - } - - return $test; - } - - /** - * Creates a default TestResult object. - * - * @return PHPUnit2_Framework_TestResult - * @access protected - */ - protected function createResult() { - return new PHPUnit2_Framework_TestResult; - } - - /** - * Returns the name of the suite. - * - * @return string - * @access public - */ - public function getName() { - return $this->name; - } - - /** - * Runs the tests and collects their result in a TestResult. - * - * @param PHPUnit2_Framework_TestResult $result - * @return PHPUnit2_Framework_TestResult - * @throws Exception - * @access public - */ - public function run($result = NULL) { - if ($result === NULL) { - $result = $this->createResult(); - } - - // XXX: Workaround for missing ability to declare type-hinted parameters as optional. - else if (!($result instanceof PHPUnit2_Framework_TestResult)) { - throw new Exception( - 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' - ); - } - - $result->startTestSuite($this); - - foreach ($this->tests as $test) { - if ($result->shouldStop()) { - break; - } - - $this->runTest($test, $result); - } - - $result->endTestSuite($this); - - return $result; - } - - /** - * Runs a test. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_TestResult $testResult - * @access public - */ - public function runTest(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_TestResult $result) { - $test->run($result); - } - - /** - * Sets the name of the suite. - * - * @param string - * @access public - */ - public function setName($name) { - $this->name = $name; - } - - /** - * Returns the test at the given index. - * - * @param integer - * @return PHPUnit2_Framework_Test - * @access public - */ - public function testAt($index) { - if (isset($this->tests[$index])) { - return $this->tests[$index]; - } else { - return FALSE; - } - } - - /** - * Returns the number of tests in this suite. - * - * @return integer - * @access public - */ - public function testCount() { - return sizeof($this->tests); - } - - /** - * Returns the tests as an enumeration. - * - * @return array - * @access public - */ - public function tests() { - return $this->tests; - } - - /** - * @param ReflectionMethod $method - * @param array $names - * @param ReflectionClass $theClass - * @access private - */ - private function addTestMethod(ReflectionMethod $method, &$names, ReflectionClass $theClass) { - $name = $method->getName(); - - if (in_array($name, $names)) { - return; - } - - if ($this->isPublicTestMethod($method)) { - $names[] = $name; - - $this->addTest( - self::createTest( - $theClass, - $name - ) - ); - } - - else if ($this->isTestMethod($method)) { - $this->addTest( - self::warning( - sprintf( - 'Test method is not public: %s', - - $name - ) - ) - ); - } - } - - /** - * @param ReflectionMethod $method - * @return boolean - * @access private - */ - private function isPublicTestMethod(ReflectionMethod $method) { - return ($this->isTestMethod($method) && - $method->isPublic()); - } - - /** - * @param ReflectionMethod $method - * @return boolean - * @access private - */ - private function isTestMethod(ReflectionMethod $method) { - return (substr($method->name, 0, 4) == 'test'); - } - - /** - * @param string $message - * @return PHPUnit2_Framework_Warning - * @access private - */ - private static function warning($message) { - require_once 'PHPUnit2/Framework/Warning.php'; - return new PHPUnit2_Framework_Warning($message); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestSuite.php,v 1.26.2.11 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/Test.php'; +require_once 'PHPUnit2/Framework/TestCase.php'; +require_once 'PHPUnit2/Framework/TestResult.php'; +require_once 'PHPUnit2/Runner/BaseTestRunner.php'; +require_once 'PHPUnit2/Util/Fileloader.php'; + +/** + * A TestSuite is a composite of Tests. It runs a collection of test cases. + * + * Here is an example using the dynamic test definition. + * + * + * addTest(new MathTest('testPass')); + * ?> + * + * + * Alternatively, a TestSuite can extract the tests to be run automatically. + * To do so you pass a ReflectionClass instance for your + * PHPUnit2_Framework_TestCase class to the PHPUnit2_Framework_TestSuite + * constructor. + * + * + * + * + * + * This constructor creates a suite with all the methods starting with + * "test" that take no arguments. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_TestSuite implements PHPUnit2_Framework_Test { + /** + * The name of the test suite. + * + * @var string + * @access private + */ + private $name = ''; + + /** + * The tests in the test suite. + * + * @var array + * @access private + */ + private $tests = array(); + + /** + * Constructs a new TestSuite: + * + * - PHPUnit2_Framework_TestSuite() constructs an empty TestSuite. + * + * - PHPUnit2_Framework_TestSuite(ReflectionClass) constructs a + * TestSuite from the given class. + * + * - PHPUnit2_Framework_TestSuite(ReflectionClass, String) + * constructs a TestSuite from the given class with the given + * name. + * + * - PHPUnit2_Framework_TestSuite(String) either constructs a + * TestSuite from the given class (if the passed string is the + * name of an existing class) or constructs an empty TestSuite + * with the given name. + * + * @param mixed $theClass + * @param string $name + * @throws Exception + * @access public + */ + public function __construct($theClass = '', $name = '') { + $argumentsValid = FALSE; + + if (is_object($theClass) && + $theClass instanceof ReflectionClass) { + $argumentsValid = TRUE; + } + + else if (is_string($theClass) && $theClass !== '' && class_exists($theClass)) { + $argumentsValid = TRUE; + + if ($name == '') { + $name = $theClass; + } + + $theClass = new ReflectionClass($theClass); + } + + else if (is_string($theClass)) { + $this->setName($theClass); + return; + } + + if (!$argumentsValid) { + throw new Exception; + } + + if ($name != '') { + $this->setName($name); + } else { + $this->setName($theClass->getName()); + } + + $constructor = $theClass->getConstructor(); + + if ($constructor === NULL || + !$constructor->isPublic()) { + $this->addTest( + self::warning( + sprintf( + 'Class %s has no public constructor', + + $theClass->getName() + ) + ) + ); + + return; + } + + $methods = $theClass->getMethods(); + $names = array(); + + foreach ($methods as $method) { + $this->addTestMethod($method, $names, $theClass); + } + + if (empty($this->tests)) { + $this->addTest( + self::warning( + sprintf( + 'No tests found in %s', + + $theClass->getName() + ) + ) + ); + } + } + + /** + * Returns a string representation of the test suite. + * + * @return string + * @access public + */ + public function toString() { + return $this->getName(); + } + + /** + * Adds a test to the suite. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function addTest(PHPUnit2_Framework_Test $test) { + $this->tests[] = $test; + } + + /** + * Adds the tests from the given class to the suite. + * + * @param mixed $testClass + * @access public + */ + public function addTestSuite($testClass) { + if (is_string($testClass) && + class_exists($testClass)) { + $testClass = new ReflectionClass($testClass); + } + + if (is_object($testClass) && + $testClass instanceof ReflectionClass) { + $this->addTest(new PHPUnit2_Framework_TestSuite($testClass)); + } + } + + /** + * Wraps both addTest() and addTestSuite + * as well as the separate import statements for the user's convenience. + * + * If the named file cannot be read or there are no new tests that can be + * added, a PHPUnit2_Framework_Warning will be created instead, + * leaving the current test run untouched. + * + * @param string $filename + * @throws Exception + * @access public + * @since Method available since Release 2.3.0 + * @author Stefano F. Rausch + */ + public function addTestFile($filename) { + if (!is_string($filename) || !file_exists($filename)) { + throw new Exception; + } + + $declaredClasses = get_declared_classes(); + + PHPUnit2_Util_Fileloader::checkAndLoad($filename); + + $newClasses = array_values( + array_diff(get_declared_classes(), $declaredClasses) + ); + + $testsFound = 0; + + foreach ($newClasses as $class) { + if (preg_match('"Tests?$"', $class)) { + try { + $suiteMethod = new ReflectionMethod( + $class, PHPUnit2_Runner_BaseTestRunner::SUITE_METHODNAME + ); + + $this->addTest($suiteMethod->invoke(NULL)); + } catch (ReflectionException $e) { + $this->addTestSuite(new ReflectionClass($class)); + } + + $testsFound++; + } + } + + if ($testsFound == 0) { + $this->addTest( + new PHPUnit2_Framework_Warning('No tests found in file ' . $filename) + ); + } + } + + /** + * Wrapper for addTestFile() that adds multiple test files. + * + * @param Array $filenames + * @throws Exception + * @access public + * @since Method available since Release 2.3.0 + */ + public function addTestFiles($filenames) { + foreach ($filenames as $filename) { + $this->addTestFile($filename); + } + } + + /** + * Counts the number of test cases that will be run by this test. + * + * @return integer + * @access public + */ + public function countTestCases() { + $count = 0; + + foreach ($this->tests as $test) { + $count += $test->countTestCases(); + } + + return $count; + } + + /** + * @param ReflectionClass $theClass + * @param string $name + * @return PHPUnit2_Framework_Test + * @access public + * @static + */ + public static function createTest(ReflectionClass $theClass, $name) { + if (!$theClass->isInstantiable()) { + return self::warning( + sprintf( + 'Cannot instantiate test case %s.', + $theClass->getName() + ) + ); + } + + $constructor = $theClass->getConstructor(); + + if ($constructor !== NULL) { + $parameters = $constructor->getParameters(); + + if (sizeof($parameters) == 0) { + $test = $theClass->newInstance(); + + if ($test instanceof PHPUnit2_Framework_TestCase) { + $test->setName($name); + } + } + + else if (sizeof($parameters) == 1 && + $parameters[0]->getClass() === NULL) { + $test = $theClass->newInstance($name); + } + + else { + return self::warning( + sprintf( + 'Constructor of class %s is not TestCase($name) or TestCase().', + $theClass->getName() + ) + ); + } + } + + return $test; + } + + /** + * Creates a default TestResult object. + * + * @return PHPUnit2_Framework_TestResult + * @access protected + */ + protected function createResult() { + return new PHPUnit2_Framework_TestResult; + } + + /** + * Returns the name of the suite. + * + * @return string + * @access public + */ + public function getName() { + return $this->name; + } + + /** + * Runs the tests and collects their result in a TestResult. + * + * @param PHPUnit2_Framework_TestResult $result + * @return PHPUnit2_Framework_TestResult + * @throws Exception + * @access public + */ + public function run($result = NULL) { + if ($result === NULL) { + $result = $this->createResult(); + } + + // XXX: Workaround for missing ability to declare type-hinted parameters as optional. + else if (!($result instanceof PHPUnit2_Framework_TestResult)) { + throw new Exception( + 'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.' + ); + } + + $result->startTestSuite($this); + + foreach ($this->tests as $test) { + if ($result->shouldStop()) { + break; + } + + $this->runTest($test, $result); + } + + $result->endTestSuite($this); + + return $result; + } + + /** + * Runs a test. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_TestResult $testResult + * @access public + */ + public function runTest(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_TestResult $result) { + $test->run($result); + } + + /** + * Sets the name of the suite. + * + * @param string + * @access public + */ + public function setName($name) { + $this->name = $name; + } + + /** + * Returns the test at the given index. + * + * @param integer + * @return PHPUnit2_Framework_Test + * @access public + */ + public function testAt($index) { + if (isset($this->tests[$index])) { + return $this->tests[$index]; + } else { + return FALSE; + } + } + + /** + * Returns the number of tests in this suite. + * + * @return integer + * @access public + */ + public function testCount() { + return sizeof($this->tests); + } + + /** + * Returns the tests as an enumeration. + * + * @return array + * @access public + */ + public function tests() { + return $this->tests; + } + + /** + * @param ReflectionMethod $method + * @param array $names + * @param ReflectionClass $theClass + * @access private + */ + private function addTestMethod(ReflectionMethod $method, &$names, ReflectionClass $theClass) { + $name = $method->getName(); + + if (in_array($name, $names)) { + return; + } + + if ($this->isPublicTestMethod($method)) { + $names[] = $name; + + $this->addTest( + self::createTest( + $theClass, + $name + ) + ); + } + + else if ($this->isTestMethod($method)) { + $this->addTest( + self::warning( + sprintf( + 'Test method is not public: %s', + + $name + ) + ) + ); + } + } + + /** + * @param ReflectionMethod $method + * @return boolean + * @access private + */ + private function isPublicTestMethod(ReflectionMethod $method) { + return ($this->isTestMethod($method) && + $method->isPublic()); + } + + /** + * @param ReflectionMethod $method + * @return boolean + * @access private + */ + private function isTestMethod(ReflectionMethod $method) { + return (substr($method->name, 0, 4) == 'test'); + } + + /** + * @param string $message + * @return PHPUnit2_Framework_Warning + * @access private + */ + private static function warning($message) { + require_once 'PHPUnit2/Framework/Warning.php'; + return new PHPUnit2_Framework_Warning($message); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Framework/Warning.php b/buildscripts/PHPUnit2/Framework/Warning.php index 0ae885a4..6e5c072f 100644 --- a/buildscripts/PHPUnit2/Framework/Warning.php +++ b/buildscripts/PHPUnit2/Framework/Warning.php @@ -1,94 +1,94 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Warning.php,v 1.11.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/TestCase.php'; - -/** - * A warning. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Framework_Warning extends PHPUnit2_Framework_TestCase { - /** - * @var string - * @access private - */ - private $message = ''; - - /** - * @param string $message - * @access public - */ - public function __construct($message = '') { - $this->message = $message; - parent::__construct('Warning'); - } - - /** - * @access protected - */ - protected function runTest() { - $this->fail($this->message); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Warning.php,v 1.11.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/TestCase.php'; + +/** + * A warning. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Framework_Warning extends PHPUnit2_Framework_TestCase { + /** + * @var string + * @access private + */ + private $message = ''; + + /** + * @param string $message + * @access public + */ + public function __construct($message = '') { + $this->message = $message; + parent::__construct('Warning'); + } + + /** + * @access protected + */ + protected function runTest() { + $this->fail($this->message); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/BaseTestRunner.php b/buildscripts/PHPUnit2/Runner/BaseTestRunner.php index b9517e5a..189309b8 100644 --- a/buildscripts/PHPUnit2/Runner/BaseTestRunner.php +++ b/buildscripts/PHPUnit2/Runner/BaseTestRunner.php @@ -1,283 +1,283 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: BaseTestRunner.php,v 1.18.2.3 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/AssertionFailedError.php'; -require_once 'PHPUnit2/Framework/TestListener.php'; -require_once 'PHPUnit2/Runner/StandardTestSuiteLoader.php'; - -/** - * Base class for all test runners. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - * @abstract - */ -abstract class PHPUnit2_Runner_BaseTestRunner implements PHPUnit2_Framework_TestListener { - const STATUS_ERROR = 1; - const STATUS_FAILURE = 2; - const STATUS_INCOMPLETE = 3; - const SUITE_METHODNAME = 'suite'; - - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->testFailed(self::STATUS_ERROR, $test, $e); - } - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->testFailed(self::STATUS_FAILURE, $test, $e); - } - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { - $this->testFailed(self::STATUS_INCOMPLETE, $test, $e); - } - - /** - * A testsuite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A testsuite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - $this->testStarted($test->getName()); - } - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - $this->testEnded($test->getName()); - } - - /** - * Returns the loader to be used. - * - * @return PHPUnit2_Runner_TestSuiteLoader - * @access public - */ - public function getLoader() { - return new PHPUnit2_Runner_StandardTestSuiteLoader; - } - - /** - * Returns the Test corresponding to the given suite. - * This is a template method, subclasses override - * the runFailed() and clearStatus() methods. - * - * @param string $suiteClassName - * @param string $suiteClassFile - * @return PHPUnit2_Framework_Test - * @access public - */ - public function getTest($suiteClassName, $suiteClassFile = '') { - if ($suiteClassFile == $suiteClassName . '.php') { - $suiteClassFile = ''; - } - - try { - $testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile); - } - - catch (Exception $e) { - $this->runFailed($e->getMessage()); - return NULL; - } - - try { - $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); - - if (!$suiteMethod->isStatic()) { - $this->runFailed( - 'suite() method must be static.' - ); - - return NULL; - } - - try { - $test = $suiteMethod->invoke(NULL); - } - - catch (ReflectionException $e) { - $this->runFailed( - sprintf( - "Failed to invoke suite() method.\n%s", - - $e->getMessage() - ) - ); - - return NULL; - } - } - - catch (ReflectionException $e) { - $test = new PHPUnit2_Framework_TestSuite($testClass); - } - - $this->clearStatus(); - - return $test; - } - - /** - * Override to define how to handle a failed loading of - * a test suite. - * - * @param string $message - * @access protected - * @abstract - */ - protected abstract function runFailed($message); - - /** - * Returns the loaded ReflectionClass for a suite name. - * - * @param string $suiteClassName - * @param string $suiteClassFile - * @return ReflectionClass - * @access protected - */ - protected function loadSuiteClass($suiteClassName, $suiteClassFile = '') { - return $this->getLoader()->load($suiteClassName, $suiteClassFile); - } - - /** - * Clears the status message. - * - * @access protected - */ - protected function clearStatus() { - } - - /** - * A test started. - * - * @param string $testName - * @access public - * @abstract - */ - public abstract function testStarted($testName); - - /** - * A test ended. - * - * @param string $testName - * @access public - * @abstract - */ - public abstract function testEnded($testName); - - /** - * A test failed. - * - * @param integer $status - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - * @abstract - */ - public abstract function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: BaseTestRunner.php,v 1.18.2.3 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/TestListener.php'; +require_once 'PHPUnit2/Runner/StandardTestSuiteLoader.php'; + +/** + * Base class for all test runners. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + * @abstract + */ +abstract class PHPUnit2_Runner_BaseTestRunner implements PHPUnit2_Framework_TestListener { + const STATUS_ERROR = 1; + const STATUS_FAILURE = 2; + const STATUS_INCOMPLETE = 3; + const SUITE_METHODNAME = 'suite'; + + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + $this->testFailed(self::STATUS_ERROR, $test, $e); + } + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + $this->testFailed(self::STATUS_FAILURE, $test, $e); + } + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->testFailed(self::STATUS_INCOMPLETE, $test, $e); + } + + /** + * A testsuite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A testsuite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + $this->testStarted($test->getName()); + } + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + $this->testEnded($test->getName()); + } + + /** + * Returns the loader to be used. + * + * @return PHPUnit2_Runner_TestSuiteLoader + * @access public + */ + public function getLoader() { + return new PHPUnit2_Runner_StandardTestSuiteLoader; + } + + /** + * Returns the Test corresponding to the given suite. + * This is a template method, subclasses override + * the runFailed() and clearStatus() methods. + * + * @param string $suiteClassName + * @param string $suiteClassFile + * @return PHPUnit2_Framework_Test + * @access public + */ + public function getTest($suiteClassName, $suiteClassFile = '') { + if ($suiteClassFile == $suiteClassName . '.php') { + $suiteClassFile = ''; + } + + try { + $testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile); + } + + catch (Exception $e) { + $this->runFailed($e->getMessage()); + return NULL; + } + + try { + $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); + + if (!$suiteMethod->isStatic()) { + $this->runFailed( + 'suite() method must be static.' + ); + + return NULL; + } + + try { + $test = $suiteMethod->invoke(NULL); + } + + catch (ReflectionException $e) { + $this->runFailed( + sprintf( + "Failed to invoke suite() method.\n%s", + + $e->getMessage() + ) + ); + + return NULL; + } + } + + catch (ReflectionException $e) { + $test = new PHPUnit2_Framework_TestSuite($testClass); + } + + $this->clearStatus(); + + return $test; + } + + /** + * Override to define how to handle a failed loading of + * a test suite. + * + * @param string $message + * @access protected + * @abstract + */ + protected abstract function runFailed($message); + + /** + * Returns the loaded ReflectionClass for a suite name. + * + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + * @access protected + */ + protected function loadSuiteClass($suiteClassName, $suiteClassFile = '') { + return $this->getLoader()->load($suiteClassName, $suiteClassFile); + } + + /** + * Clears the status message. + * + * @access protected + */ + protected function clearStatus() { + } + + /** + * A test started. + * + * @param string $testName + * @access public + * @abstract + */ + public abstract function testStarted($testName); + + /** + * A test ended. + * + * @param string $testName + * @access public + * @abstract + */ + public abstract function testEnded($testName); + + /** + * A test failed. + * + * @param integer $status + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + * @abstract + */ + public abstract function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/IncludePathTestCollector.php b/buildscripts/PHPUnit2/Runner/IncludePathTestCollector.php index 116b20ed..b84f0e74 100644 --- a/buildscripts/PHPUnit2/Runner/IncludePathTestCollector.php +++ b/buildscripts/PHPUnit2/Runner/IncludePathTestCollector.php @@ -1,184 +1,184 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IncludePathTestCollector.php,v 1.13.2.5 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.1.0 - */ - -if (!class_exists('AppendIterator')) { - class AppendIterator implements Iterator { - private $iterators; - - public function __construct() { - $this->iterators = new ArrayIterator(); - } - - public function __call($func, $params) { - return call_user_func_array(array($this->getInnerIterator(), $func), $params); - } - - public function append(Iterator $it) { - $this->iterators->append($it); - } - - public function getInnerIterator() { - return $this->iterators->current(); - } - - public function rewind() { - $this->iterators->rewind(); - - if ($this->iterators->valid()) { - $this->getInnerIterator()->rewind(); - } - } - - public function valid() { - return $this->iterators->valid() && $this->getInnerIterator()->valid(); - } - - public function current() { - return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL; - } - - public function key() { - return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL; - } - - public function next() { - if (!$this->iterators->valid()) return; - $this->getInnerIterator()->next(); - - if ($this->getInnerIterator()->valid()) return; - $this->iterators->next(); - - while ($this->iterators->valid()) { - $this->getInnerIterator()->rewind(); - - if ($this->getInnerIterator()->valid()) return; - $this->iterators->next(); - } - } - } -} - -require_once 'PHPUnit2/Runner/TestCollector.php'; - -require_once 'PEAR/Config.php'; - -/** - * An implementation of a TestCollector that consults the - * include path set in the php.ini. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ - -class PHPUnit2_Runner_IncludePathTestCollector implements PHPUnit2_Runner_TestCollector { - /** - * @return array - * @access public - */ - public function collectTests() { - $config = new PEAR_Config; - $iterator = new AppendIterator; - $result = array(); - - if (substr(PHP_OS, 0, 3) == 'WIN') { - $delimiter = ';'; - } else { - $delimiter = ':'; - } - - $paths = explode($delimiter, ini_get('include_path')); - $paths[] = $config->get('test_dir'); - - foreach ($paths as $path) { - $iterator->append( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path) - ) - ); - } - - foreach ($iterator as $path => $file) { - if ($this->isTestClass($file)) { - if (substr(PHP_OS, 0, 3) == 'WIN') { - $path = str_replace('/', '\\', $path); - } - - $result[] = $path; - } - } - - return $result; - } - - /** - * Considers a file to contain a test class when it contains the - * pattern "Test" in its name and its name ends with ".php". - * - * @param string $classFileName - * @return boolean - * @access protected - */ - protected function isTestClass($classFileName) { - return (strpos($classFileName, 'Test') !== FALSE && substr($classFileName, -4) == '.php') ? TRUE : FALSE; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: IncludePathTestCollector.php,v 1.13.2.5 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.1.0 + */ + +if (!class_exists('AppendIterator')) { + class AppendIterator implements Iterator { + private $iterators; + + public function __construct() { + $this->iterators = new ArrayIterator(); + } + + public function __call($func, $params) { + return call_user_func_array(array($this->getInnerIterator(), $func), $params); + } + + public function append(Iterator $it) { + $this->iterators->append($it); + } + + public function getInnerIterator() { + return $this->iterators->current(); + } + + public function rewind() { + $this->iterators->rewind(); + + if ($this->iterators->valid()) { + $this->getInnerIterator()->rewind(); + } + } + + public function valid() { + return $this->iterators->valid() && $this->getInnerIterator()->valid(); + } + + public function current() { + return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL; + } + + public function key() { + return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL; + } + + public function next() { + if (!$this->iterators->valid()) return; + $this->getInnerIterator()->next(); + + if ($this->getInnerIterator()->valid()) return; + $this->iterators->next(); + + while ($this->iterators->valid()) { + $this->getInnerIterator()->rewind(); + + if ($this->getInnerIterator()->valid()) return; + $this->iterators->next(); + } + } + } +} + +require_once 'PHPUnit2/Runner/TestCollector.php'; + +require_once 'PEAR/Config.php'; + +/** + * An implementation of a TestCollector that consults the + * include path set in the php.ini. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ + +class PHPUnit2_Runner_IncludePathTestCollector implements PHPUnit2_Runner_TestCollector { + /** + * @return array + * @access public + */ + public function collectTests() { + $config = new PEAR_Config; + $iterator = new AppendIterator; + $result = array(); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $delimiter = ';'; + } else { + $delimiter = ':'; + } + + $paths = explode($delimiter, ini_get('include_path')); + $paths[] = $config->get('test_dir'); + + foreach ($paths as $path) { + $iterator->append( + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path) + ) + ); + } + + foreach ($iterator as $path => $file) { + if ($this->isTestClass($file)) { + if (substr(PHP_OS, 0, 3) == 'WIN') { + $path = str_replace('/', '\\', $path); + } + + $result[] = $path; + } + } + + return $result; + } + + /** + * Considers a file to contain a test class when it contains the + * pattern "Test" in its name and its name ends with ".php". + * + * @param string $classFileName + * @return boolean + * @access protected + */ + protected function isTestClass($classFileName) { + return (strpos($classFileName, 'Test') !== FALSE && substr($classFileName, -4) == '.php') ? TRUE : FALSE; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/StandardTestSuiteLoader.php b/buildscripts/PHPUnit2/Runner/StandardTestSuiteLoader.php index b0c359a0..e7fccfda 100644 --- a/buildscripts/PHPUnit2/Runner/StandardTestSuiteLoader.php +++ b/buildscripts/PHPUnit2/Runner/StandardTestSuiteLoader.php @@ -1,129 +1,129 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: StandardTestSuiteLoader.php,v 1.19.2.8 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Runner/TestSuiteLoader.php'; -require_once 'PHPUnit2/Util/Fileloader.php'; - -require_once 'PEAR/Config.php'; - -/** - * The standard test suite loader. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Runner_StandardTestSuiteLoader implements PHPUnit2_Runner_TestSuiteLoader { - /** - * @param string $suiteClassName - * @param string $suiteClassFile - * @return ReflectionClass - * @throws Exception - * @access public - */ - public function load($suiteClassName, $suiteClassFile = '') { - $suiteClassName = str_replace('.php', '', $suiteClassName); - $suiteClassFile = !empty($suiteClassFile) ? $suiteClassFile : str_replace('_', '/', $suiteClassName) . '.php'; - - if (!class_exists($suiteClassName)) { - if(!file_exists($suiteClassFile)) { - $config = new PEAR_Config; - - $includePaths = explode(PATH_SEPARATOR, get_include_path()); - $includePaths[] = $config->get('test_dir'); - - foreach ($includePaths as $includePath) { - $file = $includePath . DIRECTORY_SEPARATOR . $suiteClassFile; - - if (file_exists($file)) { - $suiteClassFile = $file; - break; - } - } - } - - PHPUnit2_Util_Fileloader::checkAndLoad($suiteClassFile); - } - - if (class_exists($suiteClassName)) { - return new ReflectionClass($suiteClassName); - } else { - throw new Exception( - sprintf( - 'Class %s could not be found in %s.', - - $suiteClassName, - $suiteClassFile - ) - ); - } - } - - /** - * @param ReflectionClass $aClass - * @return ReflectionClass - * @access public - */ - public function reload(ReflectionClass $aClass) { - return $aClass; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: StandardTestSuiteLoader.php,v 1.19.2.8 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Runner/TestSuiteLoader.php'; +require_once 'PHPUnit2/Util/Fileloader.php'; + +require_once 'PEAR/Config.php'; + +/** + * The standard test suite loader. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Runner_StandardTestSuiteLoader implements PHPUnit2_Runner_TestSuiteLoader { + /** + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + * @throws Exception + * @access public + */ + public function load($suiteClassName, $suiteClassFile = '') { + $suiteClassName = str_replace('.php', '', $suiteClassName); + $suiteClassFile = !empty($suiteClassFile) ? $suiteClassFile : str_replace('_', '/', $suiteClassName) . '.php'; + + if (!class_exists($suiteClassName)) { + if(!file_exists($suiteClassFile)) { + $config = new PEAR_Config; + + $includePaths = explode(PATH_SEPARATOR, get_include_path()); + $includePaths[] = $config->get('test_dir'); + + foreach ($includePaths as $includePath) { + $file = $includePath . DIRECTORY_SEPARATOR . $suiteClassFile; + + if (file_exists($file)) { + $suiteClassFile = $file; + break; + } + } + } + + PHPUnit2_Util_Fileloader::checkAndLoad($suiteClassFile); + } + + if (class_exists($suiteClassName)) { + return new ReflectionClass($suiteClassName); + } else { + throw new Exception( + sprintf( + 'Class %s could not be found in %s.', + + $suiteClassName, + $suiteClassFile + ) + ); + } + } + + /** + * @param ReflectionClass $aClass + * @return ReflectionClass + * @access public + */ + public function reload(ReflectionClass $aClass) { + return $aClass; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/TestCollector.php b/buildscripts/PHPUnit2/Runner/TestCollector.php index 38a9ce81..9c77e6da 100644 --- a/buildscripts/PHPUnit2/Runner/TestCollector.php +++ b/buildscripts/PHPUnit2/Runner/TestCollector.php @@ -1,77 +1,77 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestCollector.php,v 1.7.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * Collects Test class names to be presented - * by the TestSelector. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit2_Runner_TestCollector { - /** - * @return array - * @access public - */ - public function collectTests(); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestCollector.php,v 1.7.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * Collects Test class names to be presented + * by the TestSelector. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit2_Runner_TestCollector { + /** + * @return array + * @access public + */ + public function collectTests(); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/TestSuiteLoader.php b/buildscripts/PHPUnit2/Runner/TestSuiteLoader.php index 711a03d2..99b91a06 100644 --- a/buildscripts/PHPUnit2/Runner/TestSuiteLoader.php +++ b/buildscripts/PHPUnit2/Runner/TestSuiteLoader.php @@ -1,85 +1,85 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestSuiteLoader.php,v 1.11.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * An interface to define how a test suite should be loaded. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Interface available since Release 2.0.0 - */ -interface PHPUnit2_Runner_TestSuiteLoader { - /** - * @param string $suiteClassName - * @param string $suiteClassFile - * @return ReflectionClass - * @access public - */ - public function load($suiteClassName, $suiteClassFile = ''); - - /** - * @param ReflectionClass $aClass - * @return ReflectionClass - * @access public - */ - public function reload(ReflectionClass $aClass); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestSuiteLoader.php,v 1.11.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * An interface to define how a test suite should be loaded. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Interface available since Release 2.0.0 + */ +interface PHPUnit2_Runner_TestSuiteLoader { + /** + * @param string $suiteClassName + * @param string $suiteClassFile + * @return ReflectionClass + * @access public + */ + public function load($suiteClassName, $suiteClassFile = ''); + + /** + * @param ReflectionClass $aClass + * @return ReflectionClass + * @access public + */ + public function reload(ReflectionClass $aClass); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Runner/Version.php b/buildscripts/PHPUnit2/Runner/Version.php index 5a0f7785..49222c98 100644 --- a/buildscripts/PHPUnit2/Runner/Version.php +++ b/buildscripts/PHPUnit2/Runner/Version.php @@ -1,90 +1,90 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Version.php,v 1.7.2.2 2005/12/17 16:04:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * This class defines the current version of PHPUnit. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Runner_Version { - /** - * Returns the current version of PHPUnit. - * - * @return string - * @access public - * @static - */ - public static function id() { - return '@package_version@'; - } - - /** - * @return string - * @access public - * @static - */ - public static function getVersionString() { - return 'PHPUnit @package_version@ by Sebastian Bergmann.'; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Version.php,v 1.7.2.2 2005/12/17 16:04:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * This class defines the current version of PHPUnit. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Runner_Version { + /** + * Returns the current version of PHPUnit. + * + * @return string + * @access public + * @static + */ + public static function id() { + return '@package_version@'; + } + + /** + * @return string + * @access public + * @static + */ + public static function getVersionString() { + return 'PHPUnit @package_version@ by Sebastian Bergmann.'; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/TextUI/ResultPrinter.php b/buildscripts/PHPUnit2/TextUI/ResultPrinter.php index 32d3e667..d441e92c 100644 --- a/buildscripts/PHPUnit2/TextUI/ResultPrinter.php +++ b/buildscripts/PHPUnit2/TextUI/ResultPrinter.php @@ -1,356 +1,356 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ResultPrinter.php,v 1.20.2.5 2005/12/17 16:04:57 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -require_once 'PHPUnit2/Framework/TestListener.php'; -require_once 'PHPUnit2/Framework/TestFailure.php'; -require_once 'PHPUnit2/Util/Filter.php'; -require_once 'PHPUnit2/Util/Printer.php'; - -/** - * Prints the result of a TextUI TestRunner run. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_TextUI_ResultPrinter extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { - /** - * @var integer - * @access private - */ - private $column = 0; - - /** - * @var boolean - * @access private - */ - private $lastTestFailed = FALSE; - - /** - * @param PHPUnit2_Framework_TestResult $result - * @param float $runTime - * @access public - */ - public function printResult(PHPUnit2_Framework_TestResult $result, $timeElapsed) { - $this->printHeader($timeElapsed); - $this->printErrors($result); - $this->printFailures($result); - $this->printIncompletes($result); - $this->printFooter($result); - } - - /** - * @param array $defects - * @param integer $count - * @param string $type - * @access protected - */ - protected function printDefects($defects, $count, $type) { - if ($count == 0) { - return; - } - - $this->write( - sprintf( - "There %s %d %s%s:\n", - - ($count == 1) ? 'was' : 'were', - $count, - $type, - ($count == 1) ? '' : 's' - ) - ); - - $i = 1; - - foreach ($defects as $defect) { - $this->printDefect($defect, $i++); - } - } - - /** - * @param PHPUnit2_Framework_TestFailure $defect - * @param integer $count - * @access protected - */ - protected function printDefect(PHPUnit2_Framework_TestFailure $defect, $count) { - $this->printDefectHeader($defect, $count); - $this->printDefectTrace($defect); - } - - /** - * @param PHPUnit2_Framework_TestFailure $defect - * @param integer $count - * @access protected - */ - protected function printDefectHeader(PHPUnit2_Framework_TestFailure $defect, $count) { - $this->write( - sprintf( - "%d) %s\n", - - $count, - $defect->failedTest()->toString() - ) - ); - } - - /** - * @param PHPUnit2_Framework_TestFailure $defect - * @access protected - */ - protected function printDefectTrace(PHPUnit2_Framework_TestFailure $defect) { - $e = $defect->thrownException(); - $message = method_exists($e, 'toString') ? $e->toString() : $e->getMessage(); - - $this->write($message . "\n"); - - $this->write( - PHPUnit2_Util_Filter::getFilteredStacktrace( - $defect->thrownException() - ) - ); - } - - /** - * @param PHPUnit2_Framework_TestResult $result - * @access protected - */ - protected function printErrors(PHPUnit2_Framework_TestResult $result) { - $this->printDefects($result->errors(), $result->errorCount(), 'error'); - } - - /** - * @param PHPUnit2_Framework_TestResult $result - * @access protected - */ - protected function printFailures(PHPUnit2_Framework_TestResult $result) { - $this->printDefects($result->failures(), $result->failureCount(), 'failure'); - } - - /** - * @param PHPUnit2_Framework_TestResult $result - * @access protected - */ - protected function printIncompletes(PHPUnit2_Framework_TestResult $result) { - $this->printDefects($result->notImplemented(), $result->notImplementedCount(), 'incomplete test case'); - } - - /** - * @param float $timeElapsed - * @access protected - */ - protected function printHeader($timeElapsed) { - $this->write( - sprintf( - "\n\nTime: %s\n", - - $timeElapsed - ) - ); - } - - /** - * @param PHPUnit2_Framework_TestResult $result - * @access protected - */ - protected function printFooter(PHPUnit2_Framework_TestResult $result) { - if ($result->allCompletlyImplemented() && - $result->wasSuccessful()) { - $this->write( - sprintf( - "\nOK (%d test%s)\n", - - $result->runCount(), - ($result->runCount() == 1) ? '' : 's' - ) - ); - } - - else if (!$result->allCompletlyImplemented() && - $result->wasSuccessful()) { - $this->write( - sprintf( - "\nOK, but incomplete test cases!!!\nTests run: %d, Incomplete Tests: %d.\n", - - $result->runCount(), - $result->notImplementedCount() - ) - ); - } - - else { - $this->write( - sprintf( - "\nFAILURES!!!\nTests run: %d, Failures: %d, Errors: %d, Incomplete Tests: %d.\n", - - $result->runCount(), - $result->failureCount(), - $result->errorCount(), - $result->notImplementedCount() - ) - ); - } - } - - /** - * @access public - */ - public function printWaitPrompt() { - $this->write("\n to continue\n"); - } - - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->write('E'); - $this->nextColumn(); - - $this->lastTestFailed = TRUE; - } - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->write('F'); - $this->nextColumn(); - - $this->lastTestFailed = TRUE; - } - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { - $this->write('I'); - $this->nextColumn(); - - $this->lastTestFailed = TRUE; - } - - /** - * A testsuite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A testsuite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - } - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - if (!$this->lastTestFailed) { - $this->write('.'); - $this->nextColumn(); - } - - $this->lastTestFailed = FALSE; - } - - /** - * @access protected - */ - protected function nextColumn() { - if ($this->column++ >= 40) { - $this->column = 0; - $this->write("\n"); - } - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: ResultPrinter.php,v 1.20.2.5 2005/12/17 16:04:57 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +require_once 'PHPUnit2/Framework/TestListener.php'; +require_once 'PHPUnit2/Framework/TestFailure.php'; +require_once 'PHPUnit2/Util/Filter.php'; +require_once 'PHPUnit2/Util/Printer.php'; + +/** + * Prints the result of a TextUI TestRunner run. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_TextUI_ResultPrinter extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { + /** + * @var integer + * @access private + */ + private $column = 0; + + /** + * @var boolean + * @access private + */ + private $lastTestFailed = FALSE; + + /** + * @param PHPUnit2_Framework_TestResult $result + * @param float $runTime + * @access public + */ + public function printResult(PHPUnit2_Framework_TestResult $result, $timeElapsed) { + $this->printHeader($timeElapsed); + $this->printErrors($result); + $this->printFailures($result); + $this->printIncompletes($result); + $this->printFooter($result); + } + + /** + * @param array $defects + * @param integer $count + * @param string $type + * @access protected + */ + protected function printDefects($defects, $count, $type) { + if ($count == 0) { + return; + } + + $this->write( + sprintf( + "There %s %d %s%s:\n", + + ($count == 1) ? 'was' : 'were', + $count, + $type, + ($count == 1) ? '' : 's' + ) + ); + + $i = 1; + + foreach ($defects as $defect) { + $this->printDefect($defect, $i++); + } + } + + /** + * @param PHPUnit2_Framework_TestFailure $defect + * @param integer $count + * @access protected + */ + protected function printDefect(PHPUnit2_Framework_TestFailure $defect, $count) { + $this->printDefectHeader($defect, $count); + $this->printDefectTrace($defect); + } + + /** + * @param PHPUnit2_Framework_TestFailure $defect + * @param integer $count + * @access protected + */ + protected function printDefectHeader(PHPUnit2_Framework_TestFailure $defect, $count) { + $this->write( + sprintf( + "%d) %s\n", + + $count, + $defect->failedTest()->toString() + ) + ); + } + + /** + * @param PHPUnit2_Framework_TestFailure $defect + * @access protected + */ + protected function printDefectTrace(PHPUnit2_Framework_TestFailure $defect) { + $e = $defect->thrownException(); + $message = method_exists($e, 'toString') ? $e->toString() : $e->getMessage(); + + $this->write($message . "\n"); + + $this->write( + PHPUnit2_Util_Filter::getFilteredStacktrace( + $defect->thrownException() + ) + ); + } + + /** + * @param PHPUnit2_Framework_TestResult $result + * @access protected + */ + protected function printErrors(PHPUnit2_Framework_TestResult $result) { + $this->printDefects($result->errors(), $result->errorCount(), 'error'); + } + + /** + * @param PHPUnit2_Framework_TestResult $result + * @access protected + */ + protected function printFailures(PHPUnit2_Framework_TestResult $result) { + $this->printDefects($result->failures(), $result->failureCount(), 'failure'); + } + + /** + * @param PHPUnit2_Framework_TestResult $result + * @access protected + */ + protected function printIncompletes(PHPUnit2_Framework_TestResult $result) { + $this->printDefects($result->notImplemented(), $result->notImplementedCount(), 'incomplete test case'); + } + + /** + * @param float $timeElapsed + * @access protected + */ + protected function printHeader($timeElapsed) { + $this->write( + sprintf( + "\n\nTime: %s\n", + + $timeElapsed + ) + ); + } + + /** + * @param PHPUnit2_Framework_TestResult $result + * @access protected + */ + protected function printFooter(PHPUnit2_Framework_TestResult $result) { + if ($result->allCompletlyImplemented() && + $result->wasSuccessful()) { + $this->write( + sprintf( + "\nOK (%d test%s)\n", + + $result->runCount(), + ($result->runCount() == 1) ? '' : 's' + ) + ); + } + + else if (!$result->allCompletlyImplemented() && + $result->wasSuccessful()) { + $this->write( + sprintf( + "\nOK, but incomplete test cases!!!\nTests run: %d, Incomplete Tests: %d.\n", + + $result->runCount(), + $result->notImplementedCount() + ) + ); + } + + else { + $this->write( + sprintf( + "\nFAILURES!!!\nTests run: %d, Failures: %d, Errors: %d, Incomplete Tests: %d.\n", + + $result->runCount(), + $result->failureCount(), + $result->errorCount(), + $result->notImplementedCount() + ) + ); + } + } + + /** + * @access public + */ + public function printWaitPrompt() { + $this->write("\n to continue\n"); + } + + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + $this->write('E'); + $this->nextColumn(); + + $this->lastTestFailed = TRUE; + } + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + $this->write('F'); + $this->nextColumn(); + + $this->lastTestFailed = TRUE; + } + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->write('I'); + $this->nextColumn(); + + $this->lastTestFailed = TRUE; + } + + /** + * A testsuite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A testsuite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + } + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + if (!$this->lastTestFailed) { + $this->write('.'); + $this->nextColumn(); + } + + $this->lastTestFailed = FALSE; + } + + /** + * @access protected + */ + protected function nextColumn() { + if ($this->column++ >= 40) { + $this->column = 0; + $this->write("\n"); + } + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/TextUI/TestRunner.php b/buildscripts/PHPUnit2/TextUI/TestRunner.php index 63639a24..b21cfca4 100644 --- a/buildscripts/PHPUnit2/TextUI/TestRunner.php +++ b/buildscripts/PHPUnit2/TextUI/TestRunner.php @@ -1,622 +1,622 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestRunner.php,v 1.64.2.5 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -if (!defined('PHPUnit2_MAIN_METHOD')) { - define('PHPUnit2_MAIN_METHOD', 'PHPUnit2_TextUI_TestRunner::main'); -} - -require_once 'PHPUnit2/Framework/TestSuite.php'; -require_once 'PHPUnit2/Runner/Version.php'; -require_once 'PHPUnit2/Runner/BaseTestRunner.php'; -require_once 'PHPUnit2/TextUI/ResultPrinter.php'; -require_once 'PHPUnit2/Util/Fileloader.php'; - -require_once 'Console/Getopt.php'; -require_once 'Benchmark/Timer.php'; - -/** - * A TestRunner for the Command Line Interface (CLI) - * PHP SAPI Module. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_TextUI_TestRunner extends PHPUnit2_Runner_BaseTestRunner { - const SUCCESS_EXIT = 0; - const FAILURE_EXIT = 1; - const EXCEPTION_EXIT = 2; - - /** - * @var PHPUnit2_Runner_TestSuiteLoader - * @access private - */ - private $loader = NULL; - - /** - * @var PHPUnit2_TextUI_ResultPrinter - * @access private - */ - private $printer = NULL; - - /** - * @var boolean - * @access private - * @static - */ - private static $versionStringPrinted = FALSE; - - /** - * @access public - * @static - */ - public static function main() { - $aTestRunner = new PHPUnit2_TextUI_TestRunner; - - try { - $result = $aTestRunner->start($_SERVER['argv']); - - if (!$result->wasSuccessful()) { - exit(self::FAILURE_EXIT); - } - - exit(self::SUCCESS_EXIT); - } - - catch (Exception $e) { - self::printVersionString(); - print $e->getMessage(); - exit(self::EXCEPTION_EXIT); - } - } - - /** - * @param array $arguments - * @throws Exception - * @access protected - */ - protected function start($arguments) { - $coverageDataFile = FALSE; - $coverageHTMLFile = FALSE; - $coverageTextFile = FALSE; - $testdoxHTMLFile = FALSE; - $testdoxTextFile = FALSE; - $xmlLogfile = FALSE; - $wait = FALSE; - - $possibleOptions = array( - 'help', - 'loader=', - 'log-xml=', - 'skeleton', - 'testdox-html=', - 'testdox-text=', - 'version', - 'wait' - ); - - if (extension_loaded('xdebug')) { - $possibleOptions[] = 'coverage-data='; - $possibleOptions[] = 'coverage-html='; - $possibleOptions[] = 'coverage-text='; - } - - $options = Console_Getopt::getopt( - $arguments, - '', - $possibleOptions - ); - - if (PEAR::isError($options)) { - $this->showError($options->getMessage()); - } - - $test = isset($options[1][0]) ? $options[1][0] : FALSE; - $testFile = isset($options[1][1]) ? $options[1][1] : $test . '.php'; - - foreach ($options[0] as $option) { - switch ($option[0]) { - case '--coverage-data': { - $coverageDataFile = $option[1]; - } - break; - - case '--coverage-html': { - $coverageHTMLFile = $option[1]; - } - break; - - case '--coverage-text': { - $coverageTextFile = $option[1]; - } - break; - - case '--help': { - $this->showHelp(); - exit(self::SUCCESS_EXIT); - } - break; - - case '--testdox-html': { - $testdoxHTMLFile = $option[1]; - } - break; - - case '--testdox-text': { - $testdoxTextFile = $option[1]; - } - break; - - case '--loader': { - if (!class_exists($option[1])) { - PHPUnit2_Util_Fileloader::checkAndLoad( - str_replace('_', '/', $option[1]) . '.php' - ); - } - - if (class_exists($option[1])) { - $class = new ReflectionClass($option[1]); - - if ($class->implementsInterface('PHPUnit2_Runner_TestSuiteLoader') && - $class->isInstantiable()) { - $this->loader = $class->newInstance(); - } - } - - if ($this->loader === NULL) { - $this->showError( - sprintf( - 'Could not use "%s" as loader.', - - $option[1] - ) - ); - } - } - break; - - case '--log-xml': { - $xmlLogfile = $option[1]; - } - break; - - case '--skeleton': { - if ($test !== FALSE) { - self::printVersionString(); - - try { - require_once 'PHPUnit2/Util/Skeleton.php'; - - $skeleton = new PHPUnit2_Util_Skeleton($test, $testFile); - $skeleton->write(); - } - - catch (Exception $e) { - print $e->getMessage() . "\n"; - - printf( - "Could not write test class skeleton for %s to %s.\n", - $test, - $test . 'Test.php' - ); - - exit(self::FAILURE_EXIT); - } - - printf( - "Wrote test class skeleton for %s to %s.\n", - $test, - $test . 'Test.php' - ); - - exit(self::SUCCESS_EXIT); - } - } - break; - - case '--version': { - self::printVersionString(); - exit(self::SUCCESS_EXIT); - } - break; - - case '--wait': { - $wait = TRUE; - } - break; - } - } - - if ($test === FALSE) { - $this->showHelp(); - - exit(self::SUCCESS_EXIT); - } - - try { - return $this->doRun( - $this->getTest($test, $testFile), - $coverageDataFile, - $coverageHTMLFile, - $coverageTextFile, - $testdoxHTMLFile, - $testdoxTextFile, - $xmlLogfile, - $wait - ); - } - - catch (Exception $e) { - throw new Exception( - 'Could not create and run test suite: ' . $e->getMessage() - ); - } - } - - /** - * @param mixed $test - * @param mixed $coverageDataFile - * @param mixed $testdoxHTMLFile - * @param mixed $testdoxTextFile - * @param mixed $xmlLogfile - * @param boolean $wait - * @access public - * @static - */ - public static function run($test, $coverageDataFile = FALSE, $coverageHTMLFile = FALSE, $coverageTextFile = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { - if ($test instanceof ReflectionClass) { - $test = new PHPUnit2_Framework_TestSuite($test); - } - - if ($test instanceof PHPUnit2_Framework_Test) { - $aTestRunner = new PHPUnit2_TextUI_TestRunner; - - return $aTestRunner->doRun( - $test, - $coverageDataFile, - $coverageHTMLFile, - $coverageTextFile, - $testdoxHTMLFile, - $testdoxTextFile, - $xmlLogfile, - $wait - ); - } - } - - /** - * Runs a single test and waits until the user types RETURN. - * - * @param PHPUnit2_Framework_Test $suite - * @access public - * @static - */ - public static function runAndWait(PHPUnit2_Framework_Test $suite) { - $aTestRunner = new PHPUnit2_TextUI_TestRunner; - - $aTestRunner->doRun( - $suite, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - FALSE, - TRUE - ); - } - - /** - * @return PHPUnit2_Framework_TestResult - * @access protected - */ - protected function createTestResult() { - return new PHPUnit2_Framework_TestResult; - } - - /** - * @param PHPUnit2_Framework_Test $suite - * @param mixed $coverageDataFile - * @param mixed $coverageHTMLFile - * @param mixed $coverageTextFile - * @param mixed $testdoxHTMLFile - * @param mixed $testdoxTextFile - * @param mixed $xmlLogfile - * @param boolean $wait - * @return PHPUnit2_Framework_TestResult - * @access public - */ - public function doRun(PHPUnit2_Framework_Test $suite, $coverageDataFile = FALSE, $coverageHTMLFile = FALSE, $coverageTextFile = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { - $result = $this->createTestResult(); - $timer = new Benchmark_Timer; - - if ($this->printer === NULL) { - $this->printer = new PHPUnit2_TextUI_ResultPrinter; - } - - $this->printer->write( - PHPUnit2_Runner_Version::getVersionString() . "\n\n" - ); - - $result->addListener($this->printer); - - if ($testdoxHTMLFile !== FALSE || $testdoxTextFile !== FALSE) { - require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; - - if ($testdoxHTMLFile !== FALSE) { - $result->addListener( - PHPUnit2_Util_TestDox_ResultPrinter::factory( - 'HTML', - $testdoxHTMLFile - ) - ); - } - - if ($testdoxTextFile !== FALSE) { - $result->addListener( - PHPUnit2_Util_TestDox_ResultPrinter::factory( - 'Text', - $testdoxTextFile - ) - ); - } - } - - if ($xmlLogfile !== FALSE) { - require_once 'PHPUnit2/Util/Log/XML.php'; - - $result->addListener( - new PHPUnit2_Util_Log_XML($xmlLogfile) - ); - } - - if ($coverageDataFile !== FALSE || - $coverageHTMLFile !== FALSE || - $coverageTextFile !== FALSE) { - $result->collectCodeCoverageInformation(TRUE); - } - - $timer->start(); - $suite->run($result); - $timer->stop(); - $timeElapsed = $timer->timeElapsed(); - - $this->pause($wait); - - $this->printer->printResult($result, $timeElapsed); - - $this->handleCodeCoverageInformation( - $result, - $coverageDataFile, - $coverageHTMLFile, - $coverageTextFile - ); - - return $result; - } - - /** - * Returns the loader to be used. - * - * @return PHPUnit2_Runner_TestSuiteLoader - * @access public - * @since Method available since Release 2.2.0 - */ - public function getLoader() { - if ($this->loader === NULL) { - $this->loader = new PHPUnit2_Runner_StandardTestSuiteLoader; - } - - return $this->loader; - } - - /** - * @param PHPUnit2_Framework_TestResult $result - * @param mixed $coverageDataFile - * @param mixed $coverageHTMLFile - * @param mixed $coverageTextFile - * @access protected - * @since Method available since Release 2.1.0 - */ - protected function handleCodeCoverageInformation(PHPUnit2_Framework_TestResult $result, $coverageDataFile, $coverageHTMLFile, $coverageTextFile) { - if ($coverageDataFile !== FALSE && - $fp = fopen($coverageDataFile, 'w')) { - fputs($fp, serialize($result->getCodeCoverageInformation())); - fclose($fp); - } - - if ($coverageHTMLFile !== FALSE || $coverageTextFile !== FALSE) { - require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; - - if ($coverageHTMLFile !== FALSE) { - $renderer = PHPUnit2_Util_CodeCoverage_Renderer::factory( - 'HTML', - $result->getCodeCoverageInformation() - ); - - $renderer->renderToFile($coverageHTMLFile); - } - - if ($coverageTextFile !== FALSE) { - $renderer = PHPUnit2_Util_CodeCoverage_Renderer::factory( - 'Text', - $result->getCodeCoverageInformation() - ); - - $renderer->renderToFile($coverageTextFile); - } - } - } - - /** - * @access public - */ - public function showError($message) { - self::printVersionString(); - print $message . "\n"; - - exit(self::FAILURE_EXIT); - } - - /** - * @access public - */ - public function showHelp() { - self::printVersionString(); - print "Usage: phpunit [switches] UnitTest [UnitTest.php]\n"; - - if (extension_loaded('xdebug')) { - print " --coverage-data Write Code Coverage data in raw format to file.\n" . - " --coverage-html Write Code Coverage data in HTML format to file.\n" . - " --coverage-text Write Code Coverage data in text format to file.\n\n"; - } - - print " --testdox-html Write agile documentation in HTML format to file.\n" . - " --testdox-text Write agile documentation in Text format to file.\n" . - " --log-xml Log test progress in XML format to file.\n\n"; - - print " --loader TestSuiteLoader implementation to use.\n\n" . - " --skeleton Generate skeleton UnitTest class for Unit in Unit.php.\n\n" . - " --wait Waits for a keystroke after each test.\n\n" . - " --help Prints this usage information.\n" . - " --version Prints the version and exits.\n"; - } - - /** - * @param boolean $wait - * @access protected - */ - protected function pause($wait) { - if (!$wait) { - return; - } - - $this->printer->printWaitPrompt(); - - fgets(STDIN); - } - - /** - * @param PHPUnit2_TextUI_ResultPrinter $resultPrinter - * @access public - */ - public function setPrinter(PHPUnit2_TextUI_ResultPrinter $resultPrinter) { - $this->printer = $resultPrinter; - } - - /** - * A test started. - * - * @param string $testName - * @access public - */ - public function testStarted($testName) { - } - - /** - * A test ended. - * - * @param string $testName - * @access public - */ - public function testEnded($testName) { - } - - /** - * A test failed. - * - * @param integer $status - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - } - - /** - * Override to define how to handle a failed loading of - * a test suite. - * - * @param string $message - * @access protected - */ - protected function runFailed($message) { - self::printVersionString(); - print $message; - exit(self::FAILURE_EXIT); - } - - /** - * @access private - * @since Method available since Release 2.2.0 - */ - private static function printVersionString() { - if (!self::$versionStringPrinted) { - print PHPUnit2_Runner_Version::getVersionString() . "\n\n"; - self::$versionStringPrinted = TRUE; - } - } -} - -if (PHPUnit2_MAIN_METHOD == 'PHPUnit2_TextUI_TestRunner::main') { - PHPUnit2_TextUI_TestRunner::main(); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: TestRunner.php,v 1.64.2.5 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +if (!defined('PHPUnit2_MAIN_METHOD')) { + define('PHPUnit2_MAIN_METHOD', 'PHPUnit2_TextUI_TestRunner::main'); +} + +require_once 'PHPUnit2/Framework/TestSuite.php'; +require_once 'PHPUnit2/Runner/Version.php'; +require_once 'PHPUnit2/Runner/BaseTestRunner.php'; +require_once 'PHPUnit2/TextUI/ResultPrinter.php'; +require_once 'PHPUnit2/Util/Fileloader.php'; + +require_once 'Console/Getopt.php'; +require_once 'Benchmark/Timer.php'; + +/** + * A TestRunner for the Command Line Interface (CLI) + * PHP SAPI Module. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_TextUI_TestRunner extends PHPUnit2_Runner_BaseTestRunner { + const SUCCESS_EXIT = 0; + const FAILURE_EXIT = 1; + const EXCEPTION_EXIT = 2; + + /** + * @var PHPUnit2_Runner_TestSuiteLoader + * @access private + */ + private $loader = NULL; + + /** + * @var PHPUnit2_TextUI_ResultPrinter + * @access private + */ + private $printer = NULL; + + /** + * @var boolean + * @access private + * @static + */ + private static $versionStringPrinted = FALSE; + + /** + * @access public + * @static + */ + public static function main() { + $aTestRunner = new PHPUnit2_TextUI_TestRunner; + + try { + $result = $aTestRunner->start($_SERVER['argv']); + + if (!$result->wasSuccessful()) { + exit(self::FAILURE_EXIT); + } + + exit(self::SUCCESS_EXIT); + } + + catch (Exception $e) { + self::printVersionString(); + print $e->getMessage(); + exit(self::EXCEPTION_EXIT); + } + } + + /** + * @param array $arguments + * @throws Exception + * @access protected + */ + protected function start($arguments) { + $coverageDataFile = FALSE; + $coverageHTMLFile = FALSE; + $coverageTextFile = FALSE; + $testdoxHTMLFile = FALSE; + $testdoxTextFile = FALSE; + $xmlLogfile = FALSE; + $wait = FALSE; + + $possibleOptions = array( + 'help', + 'loader=', + 'log-xml=', + 'skeleton', + 'testdox-html=', + 'testdox-text=', + 'version', + 'wait' + ); + + if (extension_loaded('xdebug')) { + $possibleOptions[] = 'coverage-data='; + $possibleOptions[] = 'coverage-html='; + $possibleOptions[] = 'coverage-text='; + } + + $options = Console_Getopt::getopt( + $arguments, + '', + $possibleOptions + ); + + if (PEAR::isError($options)) { + $this->showError($options->getMessage()); + } + + $test = isset($options[1][0]) ? $options[1][0] : FALSE; + $testFile = isset($options[1][1]) ? $options[1][1] : $test . '.php'; + + foreach ($options[0] as $option) { + switch ($option[0]) { + case '--coverage-data': { + $coverageDataFile = $option[1]; + } + break; + + case '--coverage-html': { + $coverageHTMLFile = $option[1]; + } + break; + + case '--coverage-text': { + $coverageTextFile = $option[1]; + } + break; + + case '--help': { + $this->showHelp(); + exit(self::SUCCESS_EXIT); + } + break; + + case '--testdox-html': { + $testdoxHTMLFile = $option[1]; + } + break; + + case '--testdox-text': { + $testdoxTextFile = $option[1]; + } + break; + + case '--loader': { + if (!class_exists($option[1])) { + PHPUnit2_Util_Fileloader::checkAndLoad( + str_replace('_', '/', $option[1]) . '.php' + ); + } + + if (class_exists($option[1])) { + $class = new ReflectionClass($option[1]); + + if ($class->implementsInterface('PHPUnit2_Runner_TestSuiteLoader') && + $class->isInstantiable()) { + $this->loader = $class->newInstance(); + } + } + + if ($this->loader === NULL) { + $this->showError( + sprintf( + 'Could not use "%s" as loader.', + + $option[1] + ) + ); + } + } + break; + + case '--log-xml': { + $xmlLogfile = $option[1]; + } + break; + + case '--skeleton': { + if ($test !== FALSE) { + self::printVersionString(); + + try { + require_once 'PHPUnit2/Util/Skeleton.php'; + + $skeleton = new PHPUnit2_Util_Skeleton($test, $testFile); + $skeleton->write(); + } + + catch (Exception $e) { + print $e->getMessage() . "\n"; + + printf( + "Could not write test class skeleton for %s to %s.\n", + $test, + $test . 'Test.php' + ); + + exit(self::FAILURE_EXIT); + } + + printf( + "Wrote test class skeleton for %s to %s.\n", + $test, + $test . 'Test.php' + ); + + exit(self::SUCCESS_EXIT); + } + } + break; + + case '--version': { + self::printVersionString(); + exit(self::SUCCESS_EXIT); + } + break; + + case '--wait': { + $wait = TRUE; + } + break; + } + } + + if ($test === FALSE) { + $this->showHelp(); + + exit(self::SUCCESS_EXIT); + } + + try { + return $this->doRun( + $this->getTest($test, $testFile), + $coverageDataFile, + $coverageHTMLFile, + $coverageTextFile, + $testdoxHTMLFile, + $testdoxTextFile, + $xmlLogfile, + $wait + ); + } + + catch (Exception $e) { + throw new Exception( + 'Could not create and run test suite: ' . $e->getMessage() + ); + } + } + + /** + * @param mixed $test + * @param mixed $coverageDataFile + * @param mixed $testdoxHTMLFile + * @param mixed $testdoxTextFile + * @param mixed $xmlLogfile + * @param boolean $wait + * @access public + * @static + */ + public static function run($test, $coverageDataFile = FALSE, $coverageHTMLFile = FALSE, $coverageTextFile = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { + if ($test instanceof ReflectionClass) { + $test = new PHPUnit2_Framework_TestSuite($test); + } + + if ($test instanceof PHPUnit2_Framework_Test) { + $aTestRunner = new PHPUnit2_TextUI_TestRunner; + + return $aTestRunner->doRun( + $test, + $coverageDataFile, + $coverageHTMLFile, + $coverageTextFile, + $testdoxHTMLFile, + $testdoxTextFile, + $xmlLogfile, + $wait + ); + } + } + + /** + * Runs a single test and waits until the user types RETURN. + * + * @param PHPUnit2_Framework_Test $suite + * @access public + * @static + */ + public static function runAndWait(PHPUnit2_Framework_Test $suite) { + $aTestRunner = new PHPUnit2_TextUI_TestRunner; + + $aTestRunner->doRun( + $suite, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + FALSE, + TRUE + ); + } + + /** + * @return PHPUnit2_Framework_TestResult + * @access protected + */ + protected function createTestResult() { + return new PHPUnit2_Framework_TestResult; + } + + /** + * @param PHPUnit2_Framework_Test $suite + * @param mixed $coverageDataFile + * @param mixed $coverageHTMLFile + * @param mixed $coverageTextFile + * @param mixed $testdoxHTMLFile + * @param mixed $testdoxTextFile + * @param mixed $xmlLogfile + * @param boolean $wait + * @return PHPUnit2_Framework_TestResult + * @access public + */ + public function doRun(PHPUnit2_Framework_Test $suite, $coverageDataFile = FALSE, $coverageHTMLFile = FALSE, $coverageTextFile = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { + $result = $this->createTestResult(); + $timer = new Benchmark_Timer; + + if ($this->printer === NULL) { + $this->printer = new PHPUnit2_TextUI_ResultPrinter; + } + + $this->printer->write( + PHPUnit2_Runner_Version::getVersionString() . "\n\n" + ); + + $result->addListener($this->printer); + + if ($testdoxHTMLFile !== FALSE || $testdoxTextFile !== FALSE) { + require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; + + if ($testdoxHTMLFile !== FALSE) { + $result->addListener( + PHPUnit2_Util_TestDox_ResultPrinter::factory( + 'HTML', + $testdoxHTMLFile + ) + ); + } + + if ($testdoxTextFile !== FALSE) { + $result->addListener( + PHPUnit2_Util_TestDox_ResultPrinter::factory( + 'Text', + $testdoxTextFile + ) + ); + } + } + + if ($xmlLogfile !== FALSE) { + require_once 'PHPUnit2/Util/Log/XML.php'; + + $result->addListener( + new PHPUnit2_Util_Log_XML($xmlLogfile) + ); + } + + if ($coverageDataFile !== FALSE || + $coverageHTMLFile !== FALSE || + $coverageTextFile !== FALSE) { + $result->collectCodeCoverageInformation(TRUE); + } + + $timer->start(); + $suite->run($result); + $timer->stop(); + $timeElapsed = $timer->timeElapsed(); + + $this->pause($wait); + + $this->printer->printResult($result, $timeElapsed); + + $this->handleCodeCoverageInformation( + $result, + $coverageDataFile, + $coverageHTMLFile, + $coverageTextFile + ); + + return $result; + } + + /** + * Returns the loader to be used. + * + * @return PHPUnit2_Runner_TestSuiteLoader + * @access public + * @since Method available since Release 2.2.0 + */ + public function getLoader() { + if ($this->loader === NULL) { + $this->loader = new PHPUnit2_Runner_StandardTestSuiteLoader; + } + + return $this->loader; + } + + /** + * @param PHPUnit2_Framework_TestResult $result + * @param mixed $coverageDataFile + * @param mixed $coverageHTMLFile + * @param mixed $coverageTextFile + * @access protected + * @since Method available since Release 2.1.0 + */ + protected function handleCodeCoverageInformation(PHPUnit2_Framework_TestResult $result, $coverageDataFile, $coverageHTMLFile, $coverageTextFile) { + if ($coverageDataFile !== FALSE && + $fp = fopen($coverageDataFile, 'w')) { + fputs($fp, serialize($result->getCodeCoverageInformation())); + fclose($fp); + } + + if ($coverageHTMLFile !== FALSE || $coverageTextFile !== FALSE) { + require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; + + if ($coverageHTMLFile !== FALSE) { + $renderer = PHPUnit2_Util_CodeCoverage_Renderer::factory( + 'HTML', + $result->getCodeCoverageInformation() + ); + + $renderer->renderToFile($coverageHTMLFile); + } + + if ($coverageTextFile !== FALSE) { + $renderer = PHPUnit2_Util_CodeCoverage_Renderer::factory( + 'Text', + $result->getCodeCoverageInformation() + ); + + $renderer->renderToFile($coverageTextFile); + } + } + } + + /** + * @access public + */ + public function showError($message) { + self::printVersionString(); + print $message . "\n"; + + exit(self::FAILURE_EXIT); + } + + /** + * @access public + */ + public function showHelp() { + self::printVersionString(); + print "Usage: phpunit [switches] UnitTest [UnitTest.php]\n"; + + if (extension_loaded('xdebug')) { + print " --coverage-data Write Code Coverage data in raw format to file.\n" . + " --coverage-html Write Code Coverage data in HTML format to file.\n" . + " --coverage-text Write Code Coverage data in text format to file.\n\n"; + } + + print " --testdox-html Write agile documentation in HTML format to file.\n" . + " --testdox-text Write agile documentation in Text format to file.\n" . + " --log-xml Log test progress in XML format to file.\n\n"; + + print " --loader TestSuiteLoader implementation to use.\n\n" . + " --skeleton Generate skeleton UnitTest class for Unit in Unit.php.\n\n" . + " --wait Waits for a keystroke after each test.\n\n" . + " --help Prints this usage information.\n" . + " --version Prints the version and exits.\n"; + } + + /** + * @param boolean $wait + * @access protected + */ + protected function pause($wait) { + if (!$wait) { + return; + } + + $this->printer->printWaitPrompt(); + + fgets(STDIN); + } + + /** + * @param PHPUnit2_TextUI_ResultPrinter $resultPrinter + * @access public + */ + public function setPrinter(PHPUnit2_TextUI_ResultPrinter $resultPrinter) { + $this->printer = $resultPrinter; + } + + /** + * A test started. + * + * @param string $testName + * @access public + */ + public function testStarted($testName) { + } + + /** + * A test ended. + * + * @param string $testName + * @access public + */ + public function testEnded($testName) { + } + + /** + * A test failed. + * + * @param integer $status + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + } + + /** + * Override to define how to handle a failed loading of + * a test suite. + * + * @param string $message + * @access protected + */ + protected function runFailed($message) { + self::printVersionString(); + print $message; + exit(self::FAILURE_EXIT); + } + + /** + * @access private + * @since Method available since Release 2.2.0 + */ + private static function printVersionString() { + if (!self::$versionStringPrinted) { + print PHPUnit2_Runner_Version::getVersionString() . "\n\n"; + self::$versionStringPrinted = TRUE; + } + } +} + +if (PHPUnit2_MAIN_METHOD == 'PHPUnit2_TextUI_TestRunner::main') { + PHPUnit2_TextUI_TestRunner::main(); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer.php b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer.php index cbcdda51..408b6850 100644 --- a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer.php +++ b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer.php @@ -1,225 +1,225 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Renderer.php,v 1.8.2.7 2006/02/25 17:02:23 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -/** - * Abstract base class for Code Coverage renderers. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - * @abstract - */ -abstract class PHPUnit2_Util_CodeCoverage_Renderer { - /** - * @var array - * @access protected - */ - protected $codeCoverageInformation; - - /** - * Constructor. - * - * @param array $codeCoverageInformation - * @access protected - */ - protected function __construct($codeCoverageInformation) { - $this->codeCoverageInformation = $codeCoverageInformation; - } - - /** - * Abstract Factory. - * - * @param string $rendererName - * @param array $codeCoverageInformation - * @throws Exception - * @access public - */ - public function factory($rendererName, $codeCoverageInformation) { - require_once 'PHPUnit2/Util/CodeCoverage/Renderer/' . $rendererName . '.php'; - - $class = 'PHPUnit2_Util_CodeCoverage_Renderer_' . $rendererName; - return new $class($codeCoverageInformation); - } - - /** - * Visualizes the result array of - * PHPUnit2_Framework_TestResult::getCodeCoverageInformation(). - * - * @return string - * @access public - * @final - */ - public final function render() { - $buffer = $this->header(); - - foreach ($this->getSummary() as $sourceFile => $executedLines) { - if (file_exists($sourceFile)) { - $buffer .= $this->startSourceFile($sourceFile); - $buffer .= $this->renderSourceFile(file($sourceFile), $executedLines); - $buffer .= $this->endSourceFile($sourceFile); - } - } - - return $buffer . $this->footer(); - } - - /** - * Visualizes the result array of - * PHPUnit2_Framework_TestResult::getCodeCoverageInformation() - * and writes it to a file. - * - * @param string $filename - * @access public - * @since Method available since Release 2.2.0 - */ - public function renderToFile($filename) { - if ($fp = fopen($filename, 'w')) { - fputs( - $fp, - $this->render() - ); - - fclose($fp); - } - } - - /** - * Returns summarized Code Coverage data. - * - * Format of the result array: - * - * - * array( - * "/tested/code.php" => array( - * linenumber => flag - * ) - * ) - * - * - * flag > 0: line was executed. - * flag < 0: line is executable but was not executed. - * - * @return array - * @access protected - * @since Method available since Release 2.2.0 - */ - protected function getSummary() { - $summary = array(); - - foreach ($this->codeCoverageInformation as $testCaseName => $sourceFiles) { - foreach ($sourceFiles as $sourceFile => $executedLines) { - foreach ($executedLines as $lineNumber => $flag) { - if (!isset($summary[$sourceFile][$lineNumber])) { - $summary[$sourceFile][$lineNumber] = $flag; - } - - else if ($flag > 0) { - $summary[$sourceFile][$lineNumber] = $flag; - } - } - } - } - - return $summary; - } - - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function header() { - } - - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function footer() { - } - - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function startSourceFile($sourceFile) { - } - - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function endSourceFile($sourceFile) { - } - - /** - * @param array $codeLines - * @param array $executedLines - * @return string - * @access protected - * @abstract - */ - abstract protected function renderSourceFile($codeLines, $executedLines); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Renderer.php,v 1.8.2.7 2006/02/25 17:02:23 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +/** + * Abstract base class for Code Coverage renderers. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + * @abstract + */ +abstract class PHPUnit2_Util_CodeCoverage_Renderer { + /** + * @var array + * @access protected + */ + protected $codeCoverageInformation; + + /** + * Constructor. + * + * @param array $codeCoverageInformation + * @access protected + */ + protected function __construct($codeCoverageInformation) { + $this->codeCoverageInformation = $codeCoverageInformation; + } + + /** + * Abstract Factory. + * + * @param string $rendererName + * @param array $codeCoverageInformation + * @throws Exception + * @access public + */ + public function factory($rendererName, $codeCoverageInformation) { + require_once 'PHPUnit2/Util/CodeCoverage/Renderer/' . $rendererName . '.php'; + + $class = 'PHPUnit2_Util_CodeCoverage_Renderer_' . $rendererName; + return new $class($codeCoverageInformation); + } + + /** + * Visualizes the result array of + * PHPUnit2_Framework_TestResult::getCodeCoverageInformation(). + * + * @return string + * @access public + * @final + */ + public final function render() { + $buffer = $this->header(); + + foreach ($this->getSummary() as $sourceFile => $executedLines) { + if (file_exists($sourceFile)) { + $buffer .= $this->startSourceFile($sourceFile); + $buffer .= $this->renderSourceFile(file($sourceFile), $executedLines); + $buffer .= $this->endSourceFile($sourceFile); + } + } + + return $buffer . $this->footer(); + } + + /** + * Visualizes the result array of + * PHPUnit2_Framework_TestResult::getCodeCoverageInformation() + * and writes it to a file. + * + * @param string $filename + * @access public + * @since Method available since Release 2.2.0 + */ + public function renderToFile($filename) { + if ($fp = fopen($filename, 'w')) { + fputs( + $fp, + $this->render() + ); + + fclose($fp); + } + } + + /** + * Returns summarized Code Coverage data. + * + * Format of the result array: + * + * + * array( + * "/tested/code.php" => array( + * linenumber => flag + * ) + * ) + * + * + * flag > 0: line was executed. + * flag < 0: line is executable but was not executed. + * + * @return array + * @access protected + * @since Method available since Release 2.2.0 + */ + protected function getSummary() { + $summary = array(); + + foreach ($this->codeCoverageInformation as $testCaseName => $sourceFiles) { + foreach ($sourceFiles as $sourceFile => $executedLines) { + foreach ($executedLines as $lineNumber => $flag) { + if (!isset($summary[$sourceFile][$lineNumber])) { + $summary[$sourceFile][$lineNumber] = $flag; + } + + else if ($flag > 0) { + $summary[$sourceFile][$lineNumber] = $flag; + } + } + } + } + + return $summary; + } + + /** + * @return string + * @access protected + * @since Method available since Release 2.1.1 + */ + protected function header() { + } + + /** + * @return string + * @access protected + * @since Method available since Release 2.1.1 + */ + protected function footer() { + } + + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function startSourceFile($sourceFile) { + } + + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function endSourceFile($sourceFile) { + } + + /** + * @param array $codeLines + * @param array $executedLines + * @return string + * @access protected + * @abstract + */ + abstract protected function renderSourceFile($codeLines, $executedLines); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php index 66fc4d13..128204dc 100644 --- a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php +++ b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/HTML.php @@ -1,191 +1,191 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: HTML.php,v 1.7.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; - -/** - * Renders Code Coverage information in HTML format. - * - * Formatting of the generated HTML can be achieved through - * CSS (codecoverage.css). - * - * Example - * - * - * td.ccLineNumber, td.ccCoveredLine, td.ccUncoveredLine, td.ccNotExecutableLine { - * font-family: monospace; - * white-space: pre; - * } - * - * td.ccLineNumber, td.ccCoveredLine { - * background-color: #aaaaaa; - * } - * - * td.ccNotExecutableLine { - * color: #aaaaaa; - * } - * - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_CodeCoverage_Renderer_HTML extends PHPUnit2_Util_CodeCoverage_Renderer { - const pageHeader = -' - - - - - - -'; - - const pageFooter = -' - -'; - - const sourceFileHeader = -' -'; - - const sourceFileFooter = -'
-'; - - const codeLine = -' %s%s -'; - - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function header() { - return self::pageHeader; - } - - /** - * @return string - * @access protected - * @since Method available since Release 2.1.1 - */ - protected function footer() { - return self::pageFooter; - } - - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function startSourceFile($sourceFile) { - return self::sourceFileHeader; - } - - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function endSourceFile($sourceFile) { - return self::sourceFileFooter; - } - - /** - * @param array $codeLines - * @param array $executedLines - * @return string - * @access protected - */ - protected function renderSourceFile($codeLines, $executedLines) { - $buffer = ''; - $line = 1; - - foreach ($codeLines as $codeLine) { - $lineStyle = 'ccNotExecutableLine'; - - if (isset($executedLines[$line])) { - if ($executedLines[$line] > 0) { - $lineStyle = 'ccCoveredLine'; - } else { - $lineStyle = 'ccUncoveredLine'; - } - } - - $buffer .= sprintf( - self::codeLine, - - $line, - $lineStyle, - htmlspecialchars(rtrim($codeLine)) - ); - - $line++; - } - - return $buffer; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: HTML.php,v 1.7.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; + +/** + * Renders Code Coverage information in HTML format. + * + * Formatting of the generated HTML can be achieved through + * CSS (codecoverage.css). + * + * Example + * + * + * td.ccLineNumber, td.ccCoveredLine, td.ccUncoveredLine, td.ccNotExecutableLine { + * font-family: monospace; + * white-space: pre; + * } + * + * td.ccLineNumber, td.ccCoveredLine { + * background-color: #aaaaaa; + * } + * + * td.ccNotExecutableLine { + * color: #aaaaaa; + * } + * + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_CodeCoverage_Renderer_HTML extends PHPUnit2_Util_CodeCoverage_Renderer { + const pageHeader = +' + + + + + + +'; + + const pageFooter = +' + +'; + + const sourceFileHeader = +' +'; + + const sourceFileFooter = +'
+'; + + const codeLine = +' %s%s +'; + + /** + * @return string + * @access protected + * @since Method available since Release 2.1.1 + */ + protected function header() { + return self::pageHeader; + } + + /** + * @return string + * @access protected + * @since Method available since Release 2.1.1 + */ + protected function footer() { + return self::pageFooter; + } + + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function startSourceFile($sourceFile) { + return self::sourceFileHeader; + } + + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function endSourceFile($sourceFile) { + return self::sourceFileFooter; + } + + /** + * @param array $codeLines + * @param array $executedLines + * @return string + * @access protected + */ + protected function renderSourceFile($codeLines, $executedLines) { + $buffer = ''; + $line = 1; + + foreach ($codeLines as $codeLine) { + $lineStyle = 'ccNotExecutableLine'; + + if (isset($executedLines[$line])) { + if ($executedLines[$line] > 0) { + $lineStyle = 'ccCoveredLine'; + } else { + $lineStyle = 'ccUncoveredLine'; + } + } + + $buffer .= sprintf( + self::codeLine, + + $line, + $lineStyle, + htmlspecialchars(rtrim($codeLine)) + ); + + $line++; + } + + return $buffer; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/Text.php b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/Text.php index 6b083692..92f3282e 100644 --- a/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/Text.php +++ b/buildscripts/PHPUnit2/Util/CodeCoverage/Renderer/Text.php @@ -1,125 +1,125 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Text.php,v 1.6.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; - -/** - * Renders Code Coverage information in text format. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_CodeCoverage_Renderer_Text extends PHPUnit2_Util_CodeCoverage_Renderer { - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function startSourceFile($sourceFile) { - return ' ' . $sourceFile . "\n\n"; - } - - /** - * @param string $sourceFile - * @return string - * @access protected - */ - protected function endSourceFile($sourceFile) { - return "\n"; - } - - /** - * @param array $codeLines - * @param array $executedLines - * @return string - * @access protected - */ - protected function renderSourceFile($codeLines, $executedLines) { - $buffer = ''; - $line = 1; - - foreach ($codeLines as $codeLine) { - $flag = '-'; - - if (isset($executedLines[$line])) { - if ($executedLines[$line] > 0) { - $flag = '+'; - } else { - $flag = '#'; - } - } - - $buffer .= sprintf( - ' %4u|%s| %s', - - $line, - $flag, - $codeLine - ); - - $line++; - } - - return $buffer; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Text.php,v 1.6.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Util/CodeCoverage/Renderer.php'; + +/** + * Renders Code Coverage information in text format. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_CodeCoverage_Renderer_Text extends PHPUnit2_Util_CodeCoverage_Renderer { + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function startSourceFile($sourceFile) { + return ' ' . $sourceFile . "\n\n"; + } + + /** + * @param string $sourceFile + * @return string + * @access protected + */ + protected function endSourceFile($sourceFile) { + return "\n"; + } + + /** + * @param array $codeLines + * @param array $executedLines + * @return string + * @access protected + */ + protected function renderSourceFile($codeLines, $executedLines) { + $buffer = ''; + $line = 1; + + foreach ($codeLines as $codeLine) { + $flag = '-'; + + if (isset($executedLines[$line])) { + if ($executedLines[$line] > 0) { + $flag = '+'; + } else { + $flag = '#'; + } + } + + $buffer .= sprintf( + ' %4u|%s| %s', + + $line, + $flag, + $codeLine + ); + + $line++; + } + + return $buffer; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/ErrorHandler.php b/buildscripts/PHPUnit2/Util/ErrorHandler.php index ee724ffe..450b2dd2 100644 --- a/buildscripts/PHPUnit2/Util/ErrorHandler.php +++ b/buildscripts/PHPUnit2/Util/ErrorHandler.php @@ -1,77 +1,77 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ErrorHandler.php,v 1.1.2.2 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -/** - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - * @throws PHPUnit2_Framework_Error - * @since Function available since Release 2.3.0 - */ -function PHPUnit2_Util_ErrorHandler($errno, $errstr, $errfile, $errline) { - $trace = debug_backtrace(); - array_shift($trace); - - throw new PHPUnit2_Framework_Error( - $errstr, - $errno, - $errfile, - $errline, - $trace - ); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: ErrorHandler.php,v 1.1.2.2 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +/** + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + * @throws PHPUnit2_Framework_Error + * @since Function available since Release 2.3.0 + */ +function PHPUnit2_Util_ErrorHandler($errno, $errstr, $errfile, $errline) { + $trace = debug_backtrace(); + array_shift($trace); + + throw new PHPUnit2_Framework_Error( + $errstr, + $errno, + $errfile, + $errline, + $trace + ); +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Fileloader.php b/buildscripts/PHPUnit2/Util/Fileloader.php index bdcd49ed..0eb45f82 100644 --- a/buildscripts/PHPUnit2/Util/Fileloader.php +++ b/buildscripts/PHPUnit2/Util/Fileloader.php @@ -1,109 +1,109 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Fileloader.php,v 1.1.2.6 2005/12/19 05:43:56 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -/** - * - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.3.0 - */ -class PHPUnit2_Util_Fileloader { - /** - * Checks if a PHP sourcefile is readable and contains no syntax errors. - * If that is the case, the sourcefile is loaded through include_once(). - * - * @param string $filename - * @throws Exception - * @access public - * @static - */ - public static function checkAndLoad($filename) { - if (!is_readable($filename)) { - $filename = './' . $filename; - } - - if (!is_readable($filename)) { - throw new Exception( - sprintf( - '%s could not be found or is not readable.', - - str_replace('./', '', $filename) - ) - ); - } - - $output = shell_exec('php -l ' . escapeshellarg($filename)); - - if (strpos($output, 'No syntax errors detected in') === FALSE) { - throw new Exception( - sprintf( - 'Syntax error in %s.', - - str_replace('./', '', $filename) - ) - ); - } - - include_once $filename; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Fileloader.php,v 1.1.2.6 2005/12/19 05:43:56 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +/** + * + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.3.0 + */ +class PHPUnit2_Util_Fileloader { + /** + * Checks if a PHP sourcefile is readable and contains no syntax errors. + * If that is the case, the sourcefile is loaded through include_once(). + * + * @param string $filename + * @throws Exception + * @access public + * @static + */ + public static function checkAndLoad($filename) { + if (!is_readable($filename)) { + $filename = './' . $filename; + } + + if (!is_readable($filename)) { + throw new Exception( + sprintf( + '%s could not be found or is not readable.', + + str_replace('./', '', $filename) + ) + ); + } + + $output = shell_exec('php -l ' . escapeshellarg($filename)); + + if (strpos($output, 'No syntax errors detected in') === FALSE) { + throw new Exception( + sprintf( + 'Syntax error in %s.', + + str_replace('./', '', $filename) + ) + ); + } + + include_once $filename; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Filter.php b/buildscripts/PHPUnit2/Util/Filter.php index 70d055fd..c3138889 100644 --- a/buildscripts/PHPUnit2/Util/Filter.php +++ b/buildscripts/PHPUnit2/Util/Filter.php @@ -1,263 +1,263 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Filter.php,v 1.32.2.5 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * Utility class for code filtering. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - */ -class PHPUnit2_Util_Filter { - /** - * Source files that are to be filtered. - * - * @var array - * @access protected - * @static - */ - protected static $filteredFiles = array( - 'PHPUnit2/Extensions/ExceptionTestCase.php', - 'PHPUnit2/Extensions/PerformanceTestCase.php', - 'PHPUnit2/Extensions/RepeatedTest.php', - 'PHPUnit2/Extensions/TestDecorator.php', - 'PHPUnit2/Extensions/TestSetup.php', - 'PHPUnit2/Framework/Assert.php', - 'PHPUnit2/Framework/AssertionFailedError.php', - 'PHPUnit2/Framework/ComparisonFailure.php', - 'PHPUnit2/Framework/Error.php', - 'PHPUnit2/Framework/IncompleteTest.php', - 'PHPUnit2/Framework/IncompleteTestError.php', - 'PHPUnit2/Framework/Test.php', - 'PHPUnit2/Framework/TestCase.php', - 'PHPUnit2/Framework/TestFailure.php', - 'PHPUnit2/Framework/TestListener.php', - 'PHPUnit2/Framework/TestResult.php', - 'PHPUnit2/Framework/TestSuite.php', - 'PHPUnit2/Framework/Warning.php', - 'PHPUnit2/Runner/BaseTestRunner.php', - 'PHPUnit2/Runner/IncludePathTestCollector.php', - 'PHPUnit2/Runner/StandardTestSuiteLoader.php', - 'PHPUnit2/Runner/TestCollector.php', - 'PHPUnit2/Runner/TestSuiteLoader.php', - 'PHPUnit2/Runner/Version.php', - 'PHPUnit2/TextUI/ResultPrinter.php', - 'PHPUnit2/TextUI/TestRunner.php', - 'PHPUnit2/Util/CodeCoverage/Renderer/HTML.php', - 'PHPUnit2/Util/CodeCoverage/Renderer/Text.php', - 'PHPUnit2/Util/CodeCoverage/Renderer.php', - 'PHPUnit2/Util/Log/PEAR.php', - 'PHPUnit2/Util/Log/XML.php', - 'PHPUnit2/Util/TestDox/ResultPrinter/HTML.php', - 'PHPUnit2/Util/TestDox/ResultPrinter/Text.php', - 'PHPUnit2/Util/TestDox/NamePrettifier.php', - 'PHPUnit2/Util/TestDox/ResultPrinter.php', - 'PHPUnit2/Util/ErrorHandler.php', - 'PHPUnit2/Util/Fileloader.php', - 'PHPUnit2/Util/Filter.php', - 'PHPUnit2/Util/Printer.php', - 'PHPUnit2/Util/Skeleton.php', - 'Benchmark/Timer.php', - 'Console/Getopt.php', - 'Log/composite.php', - 'Log/console.php', - 'Log/display.php', - 'Log/error.php', - 'Log/file.php', - 'Log/mail.php', - 'Log/mcal.php', - 'Log/null.php', - 'Log/observer.php', - 'Log/sql.php', - 'Log/sqlite.php', - 'Log/syslog.php', - 'Log/win.php', - 'Log.php', - 'PEAR/Config.php', - 'PEAR.php' - ); - - /** - * Adds a new file to be filtered. - * - * @param string - * @access public - * @static - * @since Method available since Release 2.1.0 - */ - public static function addFileToFilter($filename) { - $filename = self::getCanonicalFilename($filename); - - if (!self::isFiltered($filename)) { - self::$filteredFiles[] = $filename; - } - } - - /** - * Removes a file from the filter. - * - * @param string - * @access public - * @static - * @since Method available since Release 2.1.0 - */ - public static function removeFileFromFilter($filename) { - $filename = self::getCanonicalFilename($filename); - $keys = array_keys(self::$filteredFiles); - - for ($i = 0; $i < sizeof($keys); $i++) { - if (self::$filteredFiles[$keys[$i]] == $filename) { - unset(self::$filteredFiles[$keys[$i]]); - break; - } - } - } - - /** - * Filters source lines from PHPUnit classes. - * - * @param array - * @return array - * @access public - * @static - */ - public static function getFilteredCodeCoverage($codeCoverageInformation) { - $files = array_keys($codeCoverageInformation); - - foreach ($files as $file) { - if (self::isFiltered($file)) { - unset($codeCoverageInformation[$file]); - } - } - - return $codeCoverageInformation; - } - - /** - * Filters stack frames from PHPUnit classes. - * - * @param Exception $e - * @return string - * @access public - * @static - */ - public static function getFilteredStacktrace(Exception $e) { - $filteredStacktrace = ''; - $stacktrace = $e->getTrace(); - - foreach ($stacktrace as $frame) { - $filtered = FALSE; - - if (isset($frame['file']) && !self::isFiltered($frame['file'])) { - $filteredStacktrace .= sprintf( - "%s:%s\n", - - $frame['file'], - isset($frame['line']) ? $frame['line'] : '?' - ); - } - } - - return $filteredStacktrace; - } - - /** - * Canonicalizes a source file name. - * - * @param string $filename - * @return string - * @access protected - * @static - */ - protected static function getCanonicalFilename($filename) { - foreach (array('PHPUnit2', 'Benchmark', 'Console', 'PEAR') as $package) { - $pos = strpos($filename, $package); - - if ($pos !== FALSE) { - $filename = substr($filename, $pos); - break; - } - } - - return str_replace( - '\\', - '/', - $filename - ); - } - - /** - * @param string $filename - * @return boolean - * @access protected - * @static - * @since Method available since Release 2.1.3 - */ - protected static function isFiltered($filename) { - if (substr($filename, -7) == 'phpunit' || - in_array(self::getCanonicalFilename($filename), self::$filteredFiles)) { - return TRUE; - } - - return FALSE; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Filter.php,v 1.32.2.5 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * Utility class for code filtering. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + */ +class PHPUnit2_Util_Filter { + /** + * Source files that are to be filtered. + * + * @var array + * @access protected + * @static + */ + protected static $filteredFiles = array( + 'PHPUnit2/Extensions/ExceptionTestCase.php', + 'PHPUnit2/Extensions/PerformanceTestCase.php', + 'PHPUnit2/Extensions/RepeatedTest.php', + 'PHPUnit2/Extensions/TestDecorator.php', + 'PHPUnit2/Extensions/TestSetup.php', + 'PHPUnit2/Framework/Assert.php', + 'PHPUnit2/Framework/AssertionFailedError.php', + 'PHPUnit2/Framework/ComparisonFailure.php', + 'PHPUnit2/Framework/Error.php', + 'PHPUnit2/Framework/IncompleteTest.php', + 'PHPUnit2/Framework/IncompleteTestError.php', + 'PHPUnit2/Framework/Test.php', + 'PHPUnit2/Framework/TestCase.php', + 'PHPUnit2/Framework/TestFailure.php', + 'PHPUnit2/Framework/TestListener.php', + 'PHPUnit2/Framework/TestResult.php', + 'PHPUnit2/Framework/TestSuite.php', + 'PHPUnit2/Framework/Warning.php', + 'PHPUnit2/Runner/BaseTestRunner.php', + 'PHPUnit2/Runner/IncludePathTestCollector.php', + 'PHPUnit2/Runner/StandardTestSuiteLoader.php', + 'PHPUnit2/Runner/TestCollector.php', + 'PHPUnit2/Runner/TestSuiteLoader.php', + 'PHPUnit2/Runner/Version.php', + 'PHPUnit2/TextUI/ResultPrinter.php', + 'PHPUnit2/TextUI/TestRunner.php', + 'PHPUnit2/Util/CodeCoverage/Renderer/HTML.php', + 'PHPUnit2/Util/CodeCoverage/Renderer/Text.php', + 'PHPUnit2/Util/CodeCoverage/Renderer.php', + 'PHPUnit2/Util/Log/PEAR.php', + 'PHPUnit2/Util/Log/XML.php', + 'PHPUnit2/Util/TestDox/ResultPrinter/HTML.php', + 'PHPUnit2/Util/TestDox/ResultPrinter/Text.php', + 'PHPUnit2/Util/TestDox/NamePrettifier.php', + 'PHPUnit2/Util/TestDox/ResultPrinter.php', + 'PHPUnit2/Util/ErrorHandler.php', + 'PHPUnit2/Util/Fileloader.php', + 'PHPUnit2/Util/Filter.php', + 'PHPUnit2/Util/Printer.php', + 'PHPUnit2/Util/Skeleton.php', + 'Benchmark/Timer.php', + 'Console/Getopt.php', + 'Log/composite.php', + 'Log/console.php', + 'Log/display.php', + 'Log/error.php', + 'Log/file.php', + 'Log/mail.php', + 'Log/mcal.php', + 'Log/null.php', + 'Log/observer.php', + 'Log/sql.php', + 'Log/sqlite.php', + 'Log/syslog.php', + 'Log/win.php', + 'Log.php', + 'PEAR/Config.php', + 'PEAR.php' + ); + + /** + * Adds a new file to be filtered. + * + * @param string + * @access public + * @static + * @since Method available since Release 2.1.0 + */ + public static function addFileToFilter($filename) { + $filename = self::getCanonicalFilename($filename); + + if (!self::isFiltered($filename)) { + self::$filteredFiles[] = $filename; + } + } + + /** + * Removes a file from the filter. + * + * @param string + * @access public + * @static + * @since Method available since Release 2.1.0 + */ + public static function removeFileFromFilter($filename) { + $filename = self::getCanonicalFilename($filename); + $keys = array_keys(self::$filteredFiles); + + for ($i = 0; $i < sizeof($keys); $i++) { + if (self::$filteredFiles[$keys[$i]] == $filename) { + unset(self::$filteredFiles[$keys[$i]]); + break; + } + } + } + + /** + * Filters source lines from PHPUnit classes. + * + * @param array + * @return array + * @access public + * @static + */ + public static function getFilteredCodeCoverage($codeCoverageInformation) { + $files = array_keys($codeCoverageInformation); + + foreach ($files as $file) { + if (self::isFiltered($file)) { + unset($codeCoverageInformation[$file]); + } + } + + return $codeCoverageInformation; + } + + /** + * Filters stack frames from PHPUnit classes. + * + * @param Exception $e + * @return string + * @access public + * @static + */ + public static function getFilteredStacktrace(Exception $e) { + $filteredStacktrace = ''; + $stacktrace = $e->getTrace(); + + foreach ($stacktrace as $frame) { + $filtered = FALSE; + + if (isset($frame['file']) && !self::isFiltered($frame['file'])) { + $filteredStacktrace .= sprintf( + "%s:%s\n", + + $frame['file'], + isset($frame['line']) ? $frame['line'] : '?' + ); + } + } + + return $filteredStacktrace; + } + + /** + * Canonicalizes a source file name. + * + * @param string $filename + * @return string + * @access protected + * @static + */ + protected static function getCanonicalFilename($filename) { + foreach (array('PHPUnit2', 'Benchmark', 'Console', 'PEAR') as $package) { + $pos = strpos($filename, $package); + + if ($pos !== FALSE) { + $filename = substr($filename, $pos); + break; + } + } + + return str_replace( + '\\', + '/', + $filename + ); + } + + /** + * @param string $filename + * @return boolean + * @access protected + * @static + * @since Method available since Release 2.1.3 + */ + protected static function isFiltered($filename) { + if (substr($filename, -7) == 'phpunit' || + in_array(self::getCanonicalFilename($filename), self::$filteredFiles)) { + return TRUE; + } + + return FALSE; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Log/PEAR.php b/buildscripts/PHPUnit2/Util/Log/PEAR.php index 368c4f54..822b34c4 100644 --- a/buildscripts/PHPUnit2/Util/Log/PEAR.php +++ b/buildscripts/PHPUnit2/Util/Log/PEAR.php @@ -1,220 +1,220 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: PEAR.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Framework/TestListener.php'; - -@include_once 'Log.php'; - -/** - * A TestListener that logs to a PEAR_Log sink. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_Log_PEAR implements PHPUnit2_Framework_TestListener { - /** - * Log. - * - * @var Log - * @access private - */ - private $log; - - /** - * @param string $type The type of concrete Log subclass to use. - * Currently, valid values are 'console', - * 'syslog', 'sql', 'file', and 'mcal'. - * @param string $name The name of the actually log file, table, or - * other specific store to use. Defaults to an - * empty string, with which the subclass will - * attempt to do something intelligent. - * @param string $ident The identity reported to the log system. - * @param array $conf A hash containing any additional configuration - * information that a subclass might need. - * @param int $maxLevel Maximum priority level at which to log. - * @access public - */ - public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG) { - $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel); - } - - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->log->crit( - sprintf( - 'Test "%s" failed: %s', - - $test->getName(), - $e->getMessage() - ) - ); - } - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->log->err( - sprintf( - 'Test "%s" failed: %s', - - $test->getName(), - $e->getMessage() - ) - ); - } - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { - $this->log->info( - sprintf( - 'Test "%s" incomplete: %s', - - $test->getName(), - $e->getMessage() - ) - ); - } - - /** - * A test suite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - $this->log->info( - sprintf( - 'TestSuite "%s" started.', - - $suite->getName() - ) - ); - } - - /** - * A test suite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - $this->log->info( - sprintf( - 'TestSuite "%s" ended.', - - $suite->getName() - ) - ); - } - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - $this->log->info( - sprintf( - 'Test "%s" started.', - - $test->getName() - ) - ); - } - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - $this->log->info( - sprintf( - 'Test "%s" ended.', - - $test->getName() - ) - ); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: PEAR.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Framework/TestListener.php'; + +@include_once 'Log.php'; + +/** + * A TestListener that logs to a PEAR_Log sink. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_Log_PEAR implements PHPUnit2_Framework_TestListener { + /** + * Log. + * + * @var Log + * @access private + */ + private $log; + + /** + * @param string $type The type of concrete Log subclass to use. + * Currently, valid values are 'console', + * 'syslog', 'sql', 'file', and 'mcal'. + * @param string $name The name of the actually log file, table, or + * other specific store to use. Defaults to an + * empty string, with which the subclass will + * attempt to do something intelligent. + * @param string $ident The identity reported to the log system. + * @param array $conf A hash containing any additional configuration + * information that a subclass might need. + * @param int $maxLevel Maximum priority level at which to log. + * @access public + */ + public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG) { + $this->log = Log::factory($type, $name, $ident, $conf, $maxLevel); + } + + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + $this->log->crit( + sprintf( + 'Test "%s" failed: %s', + + $test->getName(), + $e->getMessage() + ) + ); + } + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + $this->log->err( + sprintf( + 'Test "%s" failed: %s', + + $test->getName(), + $e->getMessage() + ) + ); + } + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->log->info( + sprintf( + 'Test "%s" incomplete: %s', + + $test->getName(), + $e->getMessage() + ) + ); + } + + /** + * A test suite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + $this->log->info( + sprintf( + 'TestSuite "%s" started.', + + $suite->getName() + ) + ); + } + + /** + * A test suite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + $this->log->info( + sprintf( + 'TestSuite "%s" ended.', + + $suite->getName() + ) + ); + } + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + $this->log->info( + sprintf( + 'Test "%s" started.', + + $test->getName() + ) + ); + } + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + $this->log->info( + sprintf( + 'Test "%s" ended.', + + $test->getName() + ) + ); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Log/XML.php b/buildscripts/PHPUnit2/Util/Log/XML.php index ce528753..dba4c929 100644 --- a/buildscripts/PHPUnit2/Util/Log/XML.php +++ b/buildscripts/PHPUnit2/Util/Log/XML.php @@ -1,356 +1,356 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: XML.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Framework/TestListener.php'; -require_once 'PHPUnit2/Util/Filter.php'; -require_once 'PHPUnit2/Util/Printer.php'; - -require_once 'Benchmark/Timer.php'; - -/** - * A TestListener that generates an XML-based logfile - * of the test execution. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_Log_XML extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { - /** - * @var DOMDocument - * @access private - */ - private $document; - - /** - * @var DOMElement - * @access private - */ - private $root; - - /** - * @var boolean - * @access private - */ - private $writeDocument = TRUE; - - /** - * @var DOMElement[] - * @access private - */ - private $testSuites = array(); - - /** - * @var integer[] - * @access private - */ - private $testSuiteTests = array(0); - - /** - * @var integer[] - * @access private - */ - private $testSuiteErrors = array(0); - - /** - * @var integer[] - * @access private - */ - private $testSuiteFailures = array(0); - - /** - * @var integer[] - * @access private - */ - private $testSuiteTimes = array(0); - - /** - * @var integer - * @access private - */ - private $testSuiteLevel = 0; - - /** - * @var DOMElement - * @access private - */ - private $currentTestCase = NULL; - - /** - * @var Benchmark_Timer - * @access private - */ - private $timer; - - /** - * Constructor. - * - * @param mixed $out - * @access public - */ - public function __construct($out = NULL) { - $this->document = new DOMDocument('1.0', 'UTF-8'); - $this->document->formatOutput = TRUE; - - $this->root = $this->document->createElement('testsuites'); - $this->document->appendChild($this->root); - - $this->timer = new Benchmark_Timer; - - parent::__construct($out); - } - - /** - * Destructor. - * - * @access public - */ - public function __destruct() { - if ($this->writeDocument === TRUE) { - $this->write($this->getXML()); - } - - parent::__destruct(); - } - - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $error = $this->document->createElement('error', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); - $error->setAttribute('message', $e->getMessage()); - $error->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($error); - - $this->testSuiteErrors[$this->testSuiteLevel]++; - } - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $failure = $this->document->createElement('failure', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); - $failure->setAttribute('message', $e->getMessage()); - $failure->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($failure); - - $this->testSuiteFailures[$this->testSuiteLevel]++; - } - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { - $error = $this->document->createElement('error', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); - $error->setAttribute('message', 'Incomplete Test'); - $error->setAttribute('type', get_class($e)); - - $this->currentTestCase->appendChild($error); - - $this->testSuiteErrors[$this->testSuiteLevel]++; - } - - /** - * A testsuite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - $testSuite = $this->document->createElement('testsuite'); - $testSuite->setAttribute('name', $suite->getName()); - - try { - $class = new ReflectionClass($suite->getName()); - $docComment = $class->getDocComment(); - - if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) { - $testSuite->setAttribute('category', $matches[1]); - } - - if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) { - $testSuite->setAttribute('package', $matches[1]); - } - - if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) { - $testSuite->setAttribute('subpackage', $matches[1]); - } - } - - catch (ReflectionException $e) { - } - - if ($this->testSuiteLevel > 0) { - $this->testSuites[$this->testSuiteLevel]->appendChild($testSuite); - } else { - $this->root->appendChild($testSuite); - } - - $this->testSuiteLevel++; - $this->testSuites[$this->testSuiteLevel] = $testSuite; - $this->testSuiteTests[$this->testSuiteLevel] = 0; - $this->testSuiteErrors[$this->testSuiteLevel] = 0; - $this->testSuiteFailures[$this->testSuiteLevel] = 0; - $this->testSuiteTimes[$this->testSuiteLevel] = 0; - } - - /** - * A testsuite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - $this->testSuites[$this->testSuiteLevel]->setAttribute('tests', $this->testSuiteTests[$this->testSuiteLevel]); - $this->testSuites[$this->testSuiteLevel]->setAttribute('failures', $this->testSuiteFailures[$this->testSuiteLevel]); - $this->testSuites[$this->testSuiteLevel]->setAttribute('errors', $this->testSuiteErrors[$this->testSuiteLevel]); - $this->testSuites[$this->testSuiteLevel]->setAttribute('time', $this->testSuiteTimes[$this->testSuiteLevel]); - - if ($this->testSuiteLevel > 1) { - $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; - $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; - $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; - $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; - } - - $this->testSuiteLevel--; - } - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - $testCase = $this->document->createElement('testcase'); - $testCase->setAttribute('name', $test->getName()); - $testCase->setAttribute('class', get_class($test)); - - $this->testSuites[$this->testSuiteLevel]->appendChild($testCase); - $this->currentTestCase = $testCase; - - $this->testSuiteTests[$this->testSuiteLevel]++; - - $this->timer->start(); - } - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - $this->timer->stop(); - $time = $this->timer->timeElapsed(); - - $this->currentTestCase->setAttribute('time', $time); - $this->testSuiteTimes[$this->testSuiteLevel] += $time; - - $this->currentTestCase = NULL; - } - - /** - * Returns the XML as a string. - * - * @return string - * @access public - * @since Method available since Release 2.2.0 - */ - public function getXML() { - return $this->document->saveXML(); - } - - /** - * Enables or disables the writing of the document - * in __destruct(). - * - * This is a "hack" needed for the integration of - * PHPUnit with Phing. - * - * @return string - * @access public - * @since Method available since Release 2.2.0 - */ - public function setWriteDocument($flag) { - if (is_bool($flag)) { - $this->writeDocument = $flag; - } - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: XML.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Framework/TestListener.php'; +require_once 'PHPUnit2/Util/Filter.php'; +require_once 'PHPUnit2/Util/Printer.php'; + +require_once 'Benchmark/Timer.php'; + +/** + * A TestListener that generates an XML-based logfile + * of the test execution. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_Log_XML extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { + /** + * @var DOMDocument + * @access private + */ + private $document; + + /** + * @var DOMElement + * @access private + */ + private $root; + + /** + * @var boolean + * @access private + */ + private $writeDocument = TRUE; + + /** + * @var DOMElement[] + * @access private + */ + private $testSuites = array(); + + /** + * @var integer[] + * @access private + */ + private $testSuiteTests = array(0); + + /** + * @var integer[] + * @access private + */ + private $testSuiteErrors = array(0); + + /** + * @var integer[] + * @access private + */ + private $testSuiteFailures = array(0); + + /** + * @var integer[] + * @access private + */ + private $testSuiteTimes = array(0); + + /** + * @var integer + * @access private + */ + private $testSuiteLevel = 0; + + /** + * @var DOMElement + * @access private + */ + private $currentTestCase = NULL; + + /** + * @var Benchmark_Timer + * @access private + */ + private $timer; + + /** + * Constructor. + * + * @param mixed $out + * @access public + */ + public function __construct($out = NULL) { + $this->document = new DOMDocument('1.0', 'UTF-8'); + $this->document->formatOutput = TRUE; + + $this->root = $this->document->createElement('testsuites'); + $this->document->appendChild($this->root); + + $this->timer = new Benchmark_Timer; + + parent::__construct($out); + } + + /** + * Destructor. + * + * @access public + */ + public function __destruct() { + if ($this->writeDocument === TRUE) { + $this->write($this->getXML()); + } + + parent::__destruct(); + } + + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + $error = $this->document->createElement('error', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); + $error->setAttribute('message', $e->getMessage()); + $error->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($error); + + $this->testSuiteErrors[$this->testSuiteLevel]++; + } + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + $failure = $this->document->createElement('failure', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); + $failure->setAttribute('message', $e->getMessage()); + $failure->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($failure); + + $this->testSuiteFailures[$this->testSuiteLevel]++; + } + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $error = $this->document->createElement('error', PHPUnit2_Util_Filter::getFilteredStacktrace($e)); + $error->setAttribute('message', 'Incomplete Test'); + $error->setAttribute('type', get_class($e)); + + $this->currentTestCase->appendChild($error); + + $this->testSuiteErrors[$this->testSuiteLevel]++; + } + + /** + * A testsuite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + $testSuite = $this->document->createElement('testsuite'); + $testSuite->setAttribute('name', $suite->getName()); + + try { + $class = new ReflectionClass($suite->getName()); + $docComment = $class->getDocComment(); + + if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) { + $testSuite->setAttribute('category', $matches[1]); + } + + if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) { + $testSuite->setAttribute('package', $matches[1]); + } + + if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) { + $testSuite->setAttribute('subpackage', $matches[1]); + } + } + + catch (ReflectionException $e) { + } + + if ($this->testSuiteLevel > 0) { + $this->testSuites[$this->testSuiteLevel]->appendChild($testSuite); + } else { + $this->root->appendChild($testSuite); + } + + $this->testSuiteLevel++; + $this->testSuites[$this->testSuiteLevel] = $testSuite; + $this->testSuiteTests[$this->testSuiteLevel] = 0; + $this->testSuiteErrors[$this->testSuiteLevel] = 0; + $this->testSuiteFailures[$this->testSuiteLevel] = 0; + $this->testSuiteTimes[$this->testSuiteLevel] = 0; + } + + /** + * A testsuite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + $this->testSuites[$this->testSuiteLevel]->setAttribute('tests', $this->testSuiteTests[$this->testSuiteLevel]); + $this->testSuites[$this->testSuiteLevel]->setAttribute('failures', $this->testSuiteFailures[$this->testSuiteLevel]); + $this->testSuites[$this->testSuiteLevel]->setAttribute('errors', $this->testSuiteErrors[$this->testSuiteLevel]); + $this->testSuites[$this->testSuiteLevel]->setAttribute('time', $this->testSuiteTimes[$this->testSuiteLevel]); + + if ($this->testSuiteLevel > 1) { + $this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel]; + $this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel]; + $this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel]; + $this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel]; + } + + $this->testSuiteLevel--; + } + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + $testCase = $this->document->createElement('testcase'); + $testCase->setAttribute('name', $test->getName()); + $testCase->setAttribute('class', get_class($test)); + + $this->testSuites[$this->testSuiteLevel]->appendChild($testCase); + $this->currentTestCase = $testCase; + + $this->testSuiteTests[$this->testSuiteLevel]++; + + $this->timer->start(); + } + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + $this->timer->stop(); + $time = $this->timer->timeElapsed(); + + $this->currentTestCase->setAttribute('time', $time); + $this->testSuiteTimes[$this->testSuiteLevel] += $time; + + $this->currentTestCase = NULL; + } + + /** + * Returns the XML as a string. + * + * @return string + * @access public + * @since Method available since Release 2.2.0 + */ + public function getXML() { + return $this->document->saveXML(); + } + + /** + * Enables or disables the writing of the document + * in __destruct(). + * + * This is a "hack" needed for the integration of + * PHPUnit with Phing. + * + * @return string + * @access public + * @since Method available since Release 2.2.0 + */ + public function setWriteDocument($flag) { + if (is_bool($flag)) { + $this->writeDocument = $flag; + } + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Printer.php b/buildscripts/PHPUnit2/Util/Printer.php index 13dc46a9..2134f9b8 100644 --- a/buildscripts/PHPUnit2/Util/Printer.php +++ b/buildscripts/PHPUnit2/Util/Printer.php @@ -1,116 +1,116 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Printer.php,v 1.10.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.0.0 - */ - -/** - * Utility class that can print to STDOUT or write to a file. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.0.0 - * @abstract - */ -abstract class PHPUnit2_Util_Printer { - /** - * @var resource - * @access private - */ - private $out = NULL; - - /** - * Constructor. - * - * @param mixed $out - * @access public - */ - public function __construct($out = NULL) { - if ($out !== NULL) { - if (is_string($out)) { - $this->out = fopen($out, 'w'); - } else { - $this->out = $out; - } - } - } - - /** - * Destructor. - * - * @access public - */ - public function __destruct() { - if ($this->out !== NULL) { - fclose($this->out); - } - } - - /** - * @param string $buffer - * @access public - */ - public function write($buffer) { - if ($this->out !== NULL) { - fputs($this->out, $buffer); - } else { - print $buffer; - } - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Printer.php,v 1.10.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.0.0 + */ + +/** + * Utility class that can print to STDOUT or write to a file. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.0.0 + * @abstract + */ +abstract class PHPUnit2_Util_Printer { + /** + * @var resource + * @access private + */ + private $out = NULL; + + /** + * Constructor. + * + * @param mixed $out + * @access public + */ + public function __construct($out = NULL) { + if ($out !== NULL) { + if (is_string($out)) { + $this->out = fopen($out, 'w'); + } else { + $this->out = $out; + } + } + } + + /** + * Destructor. + * + * @access public + */ + public function __destruct() { + if ($this->out !== NULL) { + fclose($this->out); + } + } + + /** + * @param string $buffer + * @access public + */ + public function write($buffer) { + if ($this->out !== NULL) { + fputs($this->out, $buffer); + } else { + print $buffer; + } + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/Skeleton.php b/buildscripts/PHPUnit2/Util/Skeleton.php index 39717557..4f2d0770 100644 --- a/buildscripts/PHPUnit2/Util/Skeleton.php +++ b/buildscripts/PHPUnit2/Util/Skeleton.php @@ -1,340 +1,340 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Skeleton.php,v 1.24.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.1.0 - */ - -/** - * Class for creating a PHPUnit2_Framework_TestCase skeleton file. - * - * This class will take a classname as a parameter on construction and will - * create a PHP file that contains the skeleton of a PHPUnit2_Framework_TestCase - * subclass. - * - * - * write(); - * ?> - * - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_Skeleton { - protected $templateClassHeader = -' -'; - - protected $templateMethod = -' - /** - * @todo Implement test{methodName}(). - */ - public function test{methodName}() { - // Remove the following line when you implement this test. - throw new PHPUnit2_Framework_IncompleteTestError; - } -'; - - /** - * @var string - * @access protected - */ - protected $className; - - /** - * @var string - * @access protected - */ - protected $classSourceFile; - - /** - * Constructor. - * - * @param string $className - * @param string $classSourceFile - * @throws Exception - * @access public - */ - public function __construct($className, $classSourceFile = '') { - if ($classSourceFile == '') { - $classSourceFile = $className . '.php'; - } - - if (file_exists($classSourceFile)) { - $this->classSourceFile = $classSourceFile; - } else { - throw new Exception( - sprintf( - 'Could not open %s.', - - $classSourceFile - ) - ); - } - - @include_once $this->classSourceFile; - - if (class_exists($className)) { - $this->className = $className; - } else { - throw new Exception( - sprintf( - 'Could not find class "%s" in %s.', - - $className, - $classSourceFile - ) - ); - } - } - - /** - * Generates the test class' source. - * - * @return string - * @access public - */ - public function generate() { - $testClassSource = $this->testClassHeader($this->className, $this->classSourceFile); - - $class = new ReflectionClass($this->className); - - foreach ($class->getMethods() as $method) { - if (!$method->isConstructor() && - !$method->isAbstract() && - $method->isUserDefined() && - $method->isPublic() && - $method->getDeclaringClass()->getName() == $this->className) { - $testClassSource .= $this->testMethod($method->getName()); - } - } - - $testClassSource .= $this->testClassFooter($this->className); - - return $testClassSource; - } - - /** - * Generates the test class and writes it to a source file. - * - * @param string $file - * @access public - */ - public function write($file = '') { - if ($file == '') { - $file = $this->className . 'Test.php'; - } - - if ($fp = @fopen($file, 'w')) { - @fputs($fp, $this->generate()); - @fclose($fp); - } - } - - /** - * Sets the templates for class header, class footer, and method. - * - * @param string $classHeader - * @param string $classFooter - * @param string $method - * @access public - * @since Method available since Release 2.2.0 - */ - public function setTemplates($classHeader, $classFooter, $method) { - if (is_file($classHeader)) { - $this->templateClassHeader = file_get_contents($classHeader); - } else { - $this->templateClassHeader = $classHeader; - } - - if (is_file($classFooter)) { - $this->templateClassFooter = file_get_contents($classFooter); - } else { - $this->templateClassFooter = $classFooter; - } - - if (is_file($method)) { - $this->templateMethod = file_get_contents($method); - } else { - $this->templateMethod = $method; - } - } - - /** - * @param string $className - * @param string $classSourceFile - * @access protected - */ - protected function testClassHeader($className, $classSourceFile) { - return str_replace( - array( - '{className}', - '{classFile}', - '{date}', - '{time}' - ), - array( - $className, - $classSourceFile, - date('Y-m-d'), - date('H:i:s') - ), - $this->templateClassHeader - ); - } - - /** - * @param string $className - * @access protected - */ - protected function testClassFooter($className) { - return str_replace( - array( - '{className}' - ), - array( - $className - ), - $this->templateClassFooter - ); - } - - /** - * @param string $methodName - * @access protected - */ - protected function testMethod($methodName) { - return str_replace( - array( - '{methodName}' - ), - array( - ucfirst($methodName) - ), - $this->templateMethod - ); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Skeleton.php,v 1.24.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.1.0 + */ + +/** + * Class for creating a PHPUnit2_Framework_TestCase skeleton file. + * + * This class will take a classname as a parameter on construction and will + * create a PHP file that contains the skeleton of a PHPUnit2_Framework_TestCase + * subclass. + * + * + * write(); + * ?> + * + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_Skeleton { + protected $templateClassHeader = +' +'; + + protected $templateMethod = +' + /** + * @todo Implement test{methodName}(). + */ + public function test{methodName}() { + // Remove the following line when you implement this test. + throw new PHPUnit2_Framework_IncompleteTestError; + } +'; + + /** + * @var string + * @access protected + */ + protected $className; + + /** + * @var string + * @access protected + */ + protected $classSourceFile; + + /** + * Constructor. + * + * @param string $className + * @param string $classSourceFile + * @throws Exception + * @access public + */ + public function __construct($className, $classSourceFile = '') { + if ($classSourceFile == '') { + $classSourceFile = $className . '.php'; + } + + if (file_exists($classSourceFile)) { + $this->classSourceFile = $classSourceFile; + } else { + throw new Exception( + sprintf( + 'Could not open %s.', + + $classSourceFile + ) + ); + } + + @include_once $this->classSourceFile; + + if (class_exists($className)) { + $this->className = $className; + } else { + throw new Exception( + sprintf( + 'Could not find class "%s" in %s.', + + $className, + $classSourceFile + ) + ); + } + } + + /** + * Generates the test class' source. + * + * @return string + * @access public + */ + public function generate() { + $testClassSource = $this->testClassHeader($this->className, $this->classSourceFile); + + $class = new ReflectionClass($this->className); + + foreach ($class->getMethods() as $method) { + if (!$method->isConstructor() && + !$method->isAbstract() && + $method->isUserDefined() && + $method->isPublic() && + $method->getDeclaringClass()->getName() == $this->className) { + $testClassSource .= $this->testMethod($method->getName()); + } + } + + $testClassSource .= $this->testClassFooter($this->className); + + return $testClassSource; + } + + /** + * Generates the test class and writes it to a source file. + * + * @param string $file + * @access public + */ + public function write($file = '') { + if ($file == '') { + $file = $this->className . 'Test.php'; + } + + if ($fp = @fopen($file, 'w')) { + @fputs($fp, $this->generate()); + @fclose($fp); + } + } + + /** + * Sets the templates for class header, class footer, and method. + * + * @param string $classHeader + * @param string $classFooter + * @param string $method + * @access public + * @since Method available since Release 2.2.0 + */ + public function setTemplates($classHeader, $classFooter, $method) { + if (is_file($classHeader)) { + $this->templateClassHeader = file_get_contents($classHeader); + } else { + $this->templateClassHeader = $classHeader; + } + + if (is_file($classFooter)) { + $this->templateClassFooter = file_get_contents($classFooter); + } else { + $this->templateClassFooter = $classFooter; + } + + if (is_file($method)) { + $this->templateMethod = file_get_contents($method); + } else { + $this->templateMethod = $method; + } + } + + /** + * @param string $className + * @param string $classSourceFile + * @access protected + */ + protected function testClassHeader($className, $classSourceFile) { + return str_replace( + array( + '{className}', + '{classFile}', + '{date}', + '{time}' + ), + array( + $className, + $classSourceFile, + date('Y-m-d'), + date('H:i:s') + ), + $this->templateClassHeader + ); + } + + /** + * @param string $className + * @access protected + */ + protected function testClassFooter($className) { + return str_replace( + array( + '{className}' + ), + array( + $className + ), + $this->templateClassFooter + ); + } + + /** + * @param string $methodName + * @access protected + */ + protected function testMethod($methodName) { + return str_replace( + array( + '{methodName}' + ), + array( + ucfirst($methodName) + ), + $this->templateMethod + ); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/TestDox/NamePrettifier.php b/buildscripts/PHPUnit2/Util/TestDox/NamePrettifier.php index 1d686dc8..b4787a7f 100644 --- a/buildscripts/PHPUnit2/Util/TestDox/NamePrettifier.php +++ b/buildscripts/PHPUnit2/Util/TestDox/NamePrettifier.php @@ -1,165 +1,165 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: NamePrettifier.php,v 1.2.2.2 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -/** - * Prettifies class and method names for use in TestDox documentation. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_TestDox_NamePrettifier { - /** - * @var string - * @access protected - */ - protected $prefix = 'Test'; - - /** - * @var string - * @access protected - */ - protected $suffix = 'Test'; - - /** - * Tests if a method is a test method. - * - * @param string $testMethodName - * @return boolean - * @access public - */ - public function isATestMethod($testMethodName) { - if (substr($testMethodName, 0, 4) == 'test') { - return TRUE; - } - - return FALSE; - } - - /** - * Prettifies the name of a test class. - * - * @param string $testClassName - * @return string - * @access public - */ - public function prettifyTestClass($testClassName) { - $title = $testClassName; - - if ($this->suffix !== NULL && - $this->suffix == substr($testClassName, -1 * strlen($this->suffix))) { - $title = substr($title, 0, strripos($title, $this->suffix)); - } - - if ($this->prefix !== NULL && - $this->prefix == substr($testClassName, 0, strlen($this->prefix))) { - $title = substr($title, strlen($this->prefix)); - } - - return $title; - } - - /** - * Prettifies the name of a test method. - * - * @param string $testMethodName - * @return string - * @access public - */ - public function prettifyTestMethod($testMethodName) { - $buffer = ''; - - $testMethodName = preg_replace('#\d+$#', '', $testMethodName); - - for ($i = 4; $i < strlen($testMethodName); $i++) { - if ($i > 4 && - ord($testMethodName[$i]) >= 65 && - ord($testMethodName[$i]) <= 90) { - $buffer .= ' ' . strtolower($testMethodName[$i]); - } else { - $buffer .= $testMethodName[$i]; - } - } - - return $buffer; - } - - /** - * Sets the prefix of test names. - * - * @param string $prefix - * @access public - */ - public function setPrefix($prefix) { - $this->prefix = $prefix; - } - - /** - * Sets the suffix of test names. - * - * @param string $prefix - * @access public - */ - public function setSuffix($suffix) { - $this->suffix = $suffix; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: NamePrettifier.php,v 1.2.2.2 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +/** + * Prettifies class and method names for use in TestDox documentation. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_TestDox_NamePrettifier { + /** + * @var string + * @access protected + */ + protected $prefix = 'Test'; + + /** + * @var string + * @access protected + */ + protected $suffix = 'Test'; + + /** + * Tests if a method is a test method. + * + * @param string $testMethodName + * @return boolean + * @access public + */ + public function isATestMethod($testMethodName) { + if (substr($testMethodName, 0, 4) == 'test') { + return TRUE; + } + + return FALSE; + } + + /** + * Prettifies the name of a test class. + * + * @param string $testClassName + * @return string + * @access public + */ + public function prettifyTestClass($testClassName) { + $title = $testClassName; + + if ($this->suffix !== NULL && + $this->suffix == substr($testClassName, -1 * strlen($this->suffix))) { + $title = substr($title, 0, strripos($title, $this->suffix)); + } + + if ($this->prefix !== NULL && + $this->prefix == substr($testClassName, 0, strlen($this->prefix))) { + $title = substr($title, strlen($this->prefix)); + } + + return $title; + } + + /** + * Prettifies the name of a test method. + * + * @param string $testMethodName + * @return string + * @access public + */ + public function prettifyTestMethod($testMethodName) { + $buffer = ''; + + $testMethodName = preg_replace('#\d+$#', '', $testMethodName); + + for ($i = 4; $i < strlen($testMethodName); $i++) { + if ($i > 4 && + ord($testMethodName[$i]) >= 65 && + ord($testMethodName[$i]) <= 90) { + $buffer .= ' ' . strtolower($testMethodName[$i]); + } else { + $buffer .= $testMethodName[$i]; + } + } + + return $buffer; + } + + /** + * Sets the prefix of test names. + * + * @param string $prefix + * @access public + */ + public function setPrefix($prefix) { + $this->prefix = $prefix; + } + + /** + * Sets the suffix of test names. + * + * @param string $prefix + * @access public + */ + public function setSuffix($suffix) { + $this->suffix = $suffix; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter.php b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter.php index 274c7309..5b47ef42 100644 --- a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter.php +++ b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter.php @@ -1,299 +1,299 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ResultPrinter.php,v 1.2.2.6 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Framework/TestListener.php'; -require_once 'PHPUnit2/Util/TestDox/NamePrettifier.php'; -require_once 'PHPUnit2/Util/Printer.php'; - -/** - * Base class for printers of TestDox documentation. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - * @abstract - */ -abstract class PHPUnit2_Util_TestDox_ResultPrinter extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { - /** - * @var PHPUnit2_Util_TestDox_NamePrettifier - * @access protected - */ - protected $prettifier; - - /** - * @var string - * @access protected - */ - protected $testClass = ''; - - /** - * @var boolean - * @access protected - */ - protected $testFailed = FALSE; - - /** - * @var array - * @access protected - */ - protected $tests = array(); - - /** - * Constructor. - * - * @param resource $out - * @access public - */ - public function __construct($out = NULL) { - parent::__construct($out); - - $this->prettifier = new PHPUnit2_Util_TestDox_NamePrettifier; - $this->startRun(); - } - - /** - * Destructor. - * - * @access public - */ - public function __destruct() { - $this->doEndClass(); - $this->endRun(); - - parent::__destruct(); - } - - /** - * Abstract Factory. - * - * @param string $type - * @param resource $out - * @throws Exception - * @access public - * @static - */ - public static function factory($type, $out = NULL) { - require_once 'PHPUnit2/Util/TestDox/ResultPrinter/' . $type . '.php'; - - $class = 'PHPUnit2_Util_TestDox_ResultPrinter_' . $type; - return new $class($out); - } - - /** - * An error occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->testFailed = TRUE; - } - - /** - * A failure occurred. - * - * @param PHPUnit2_Framework_Test $test - * @param PHPUnit2_Framework_AssertionFailedError $e - * @access public - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->testFailed = TRUE; - } - - /** - * Incomplete test. - * - * @param PHPUnit2_Framework_Test $test - * @param Exception $e - * @access public - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { - $this->testFailed = TRUE; - } - - /** - * A testsuite started. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A testsuite ended. - * - * @param PHPUnit2_Framework_TestSuite $suite - * @access public - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { - } - - /** - * A test started. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function startTest(PHPUnit2_Framework_Test $test) { - $class = get_class($test); - - if ($this->testClass != $class) { - if ($this->testClass != '') { - $this->doEndClass(); - } - - $this->startClass($this->prettifier->prettifyTestClass($class)); - - $this->testClass = $class; - $this->tests = array(); - } - - $this->testFailed = FALSE; - } - - /** - * A test ended. - * - * @param PHPUnit2_Framework_Test $test - * @access public - */ - public function endTest(PHPUnit2_Framework_Test $test) { - $prettifiedName = $this->prettifier->prettifyTestMethod($test->getName()); - - if (!isset($this->tests[$prettifiedName])) { - if (!$this->testFailed) { - $this->tests[$prettifiedName]['success'] = 1; - $this->tests[$prettifiedName]['failure'] = 0; - } else { - $this->tests[$prettifiedName]['success'] = 0; - $this->tests[$prettifiedName]['failure'] = 1; - } - } else { - if (!$this->testFailed) { - $this->tests[$prettifiedName]['success']++; - } else { - $this->tests[$prettifiedName]['failure']++; - } - } - } - - /** - * @access private - * @since Method available since Release 2.3.0 - */ - private function doEndClass() { - foreach ($this->tests as $name => $data) { - if ($data['failure'] == 0) { - $this->onTest($name); - } - } - - $this->endClass($this->prettifier->prettifyTestClass($this->testClass)); - } - - /** - * Handler for 'start run' event. - * - * @access protected - */ - protected function startRun() { - } - - /** - * Handler for 'start class' event. - * - * @param string $name - * @access protected - * @abstract - */ - abstract protected function startClass($name); - - /** - * Handler for 'on test' event. - * - * @param string $name - * @access protected - * @abstract - */ - abstract protected function onTest($name); - - /** - * Handler for 'end class' event. - * - * @param string $name - * @access protected - * @abstract - */ - abstract protected function endClass($name); - - /** - * Handler for 'end run' event. - * - * @access protected - */ - protected function endRun() { - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: ResultPrinter.php,v 1.2.2.6 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Framework/TestListener.php'; +require_once 'PHPUnit2/Util/TestDox/NamePrettifier.php'; +require_once 'PHPUnit2/Util/Printer.php'; + +/** + * Base class for printers of TestDox documentation. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + * @abstract + */ +abstract class PHPUnit2_Util_TestDox_ResultPrinter extends PHPUnit2_Util_Printer implements PHPUnit2_Framework_TestListener { + /** + * @var PHPUnit2_Util_TestDox_NamePrettifier + * @access protected + */ + protected $prettifier; + + /** + * @var string + * @access protected + */ + protected $testClass = ''; + + /** + * @var boolean + * @access protected + */ + protected $testFailed = FALSE; + + /** + * @var array + * @access protected + */ + protected $tests = array(); + + /** + * Constructor. + * + * @param resource $out + * @access public + */ + public function __construct($out = NULL) { + parent::__construct($out); + + $this->prettifier = new PHPUnit2_Util_TestDox_NamePrettifier; + $this->startRun(); + } + + /** + * Destructor. + * + * @access public + */ + public function __destruct() { + $this->doEndClass(); + $this->endRun(); + + parent::__destruct(); + } + + /** + * Abstract Factory. + * + * @param string $type + * @param resource $out + * @throws Exception + * @access public + * @static + */ + public static function factory($type, $out = NULL) { + require_once 'PHPUnit2/Util/TestDox/ResultPrinter/' . $type . '.php'; + + $class = 'PHPUnit2_Util_TestDox_ResultPrinter_' . $type; + return new $class($out); + } + + /** + * An error occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addError(PHPUnit2_Framework_Test $test, Exception $e) { + $this->testFailed = TRUE; + } + + /** + * A failure occurred. + * + * @param PHPUnit2_Framework_Test $test + * @param PHPUnit2_Framework_AssertionFailedError $e + * @access public + */ + public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { + $this->testFailed = TRUE; + } + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->testFailed = TRUE; + } + + /** + * A testsuite started. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A testsuite ended. + * + * @param PHPUnit2_Framework_TestSuite $suite + * @access public + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) { + } + + /** + * A test started. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function startTest(PHPUnit2_Framework_Test $test) { + $class = get_class($test); + + if ($this->testClass != $class) { + if ($this->testClass != '') { + $this->doEndClass(); + } + + $this->startClass($this->prettifier->prettifyTestClass($class)); + + $this->testClass = $class; + $this->tests = array(); + } + + $this->testFailed = FALSE; + } + + /** + * A test ended. + * + * @param PHPUnit2_Framework_Test $test + * @access public + */ + public function endTest(PHPUnit2_Framework_Test $test) { + $prettifiedName = $this->prettifier->prettifyTestMethod($test->getName()); + + if (!isset($this->tests[$prettifiedName])) { + if (!$this->testFailed) { + $this->tests[$prettifiedName]['success'] = 1; + $this->tests[$prettifiedName]['failure'] = 0; + } else { + $this->tests[$prettifiedName]['success'] = 0; + $this->tests[$prettifiedName]['failure'] = 1; + } + } else { + if (!$this->testFailed) { + $this->tests[$prettifiedName]['success']++; + } else { + $this->tests[$prettifiedName]['failure']++; + } + } + } + + /** + * @access private + * @since Method available since Release 2.3.0 + */ + private function doEndClass() { + foreach ($this->tests as $name => $data) { + if ($data['failure'] == 0) { + $this->onTest($name); + } + } + + $this->endClass($this->prettifier->prettifyTestClass($this->testClass)); + } + + /** + * Handler for 'start run' event. + * + * @access protected + */ + protected function startRun() { + } + + /** + * Handler for 'start class' event. + * + * @param string $name + * @access protected + * @abstract + */ + abstract protected function startClass($name); + + /** + * Handler for 'on test' event. + * + * @param string $name + * @access protected + * @abstract + */ + abstract protected function onTest($name); + + /** + * Handler for 'end class' event. + * + * @param string $name + * @access protected + * @abstract + */ + abstract protected function endClass($name); + + /** + * Handler for 'end run' event. + * + * @access protected + */ + protected function endRun() { + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/HTML.php b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/HTML.php index 505ec60d..2eda325a 100644 --- a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/HTML.php +++ b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/HTML.php @@ -1,120 +1,120 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: HTML.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; - -/** - * Prints TestDox documentation in HTML format. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_TestDox_ResultPrinter_HTML extends PHPUnit2_Util_TestDox_ResultPrinter { - /** - * Handler for 'start run' event. - * - * @access protected - */ - protected function startRun() { - $this->write(''); - } - - /** - * Handler for 'start class' event. - * - * @param string $name - * @access protected - */ - protected function startClass($name) { - $this->write('

' . $name . '

    '); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @access protected - */ - protected function onTest($name) { - $this->write('
  • ' . $name . '
  • '); - } - - /** - * Handler for 'end class' event. - * - * @param string $name - * @access protected - */ - protected function endClass($name) { - $this->write('
'); - } - - /** - * Handler for 'end run' event. - * - * @access protected - */ - protected function endRun() { - $this->write(''); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: HTML.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; + +/** + * Prints TestDox documentation in HTML format. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_TestDox_ResultPrinter_HTML extends PHPUnit2_Util_TestDox_ResultPrinter { + /** + * Handler for 'start run' event. + * + * @access protected + */ + protected function startRun() { + $this->write(''); + } + + /** + * Handler for 'start class' event. + * + * @param string $name + * @access protected + */ + protected function startClass($name) { + $this->write('

' . $name . '

    '); + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @access protected + */ + protected function onTest($name) { + $this->write('
  • ' . $name . '
  • '); + } + + /** + * Handler for 'end class' event. + * + * @param string $name + * @access protected + */ + protected function endClass($name) { + $this->write('
'); + } + + /** + * Handler for 'end run' event. + * + * @access protected + */ + protected function endRun() { + $this->write(''); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/Text.php b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/Text.php index cd12e525..388dab50 100644 --- a/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/Text.php +++ b/buildscripts/PHPUnit2/Util/TestDox/ResultPrinter/Text.php @@ -1,102 +1,102 @@ -. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Sebastian Bergmann nor the names of his - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Text.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ - * @link http://pear.php.net/package/PHPUnit2 - * @since File available since Release 2.3.0 - */ - -require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; - -/** - * Prints TestDox documentation in text format. - * - * @category Testing - * @package PHPUnit2 - * @author Sebastian Bergmann - * @copyright 2002-2006 Sebastian Bergmann - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PHPUnit2 - * @since Class available since Release 2.1.0 - */ -class PHPUnit2_Util_TestDox_ResultPrinter_Text extends PHPUnit2_Util_TestDox_ResultPrinter { - /** - * Handler for 'start class' event. - * - * @param string $name - * @access protected - */ - protected function startClass($name) { - $this->write($name . "\n"); - } - - /** - * Handler for 'on test' event. - * - * @param string $name - * @access protected - */ - protected function onTest($name) { - $this->write(' - ' . $name . "\n"); - } - - /** - * Handler for 'end class' event. - * - * @param string $name - * @access protected - */ - protected function endClass($name) { - $this->write("\n"); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ -?> +. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Sebastian Bergmann nor the names of his + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Text.php,v 1.2.2.3 2005/12/17 16:04:58 sebastian Exp $ + * @link http://pear.php.net/package/PHPUnit2 + * @since File available since Release 2.3.0 + */ + +require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php'; + +/** + * Prints TestDox documentation in text format. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann + * @copyright 2002-2006 Sebastian Bergmann + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHPUnit2 + * @since Class available since Release 2.1.0 + */ +class PHPUnit2_Util_TestDox_ResultPrinter_Text extends PHPUnit2_Util_TestDox_ResultPrinter { + /** + * Handler for 'start class' event. + * + * @param string $name + * @access protected + */ + protected function startClass($name) { + $this->write($name . "\n"); + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @access protected + */ + protected function onTest($name) { + $this->write(' - ' . $name . "\n"); + } + + /** + * Handler for 'end class' event. + * + * @param string $name + * @access protected + */ + protected function endClass($name) { + $this->write("\n"); + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ +?> diff --git a/buildscripts/chmbuilder/ChmQuickstartBuilder.php b/buildscripts/chmbuilder/ChmQuickstartBuilder.php index 43b55d12..2e517d68 100644 --- a/buildscripts/chmbuilder/ChmQuickstartBuilder.php +++ b/buildscripts/chmbuilder/ChmQuickstartBuilder.php @@ -1,439 +1,439 @@ -base = $base; - $this->output_dir = $output; - - if(!is_dir($this->output_dir) || !is_dir($this->output_dir.'/assets')) - { - @mkdir($this->output_dir); - @mkdir($this->output_dir.'/assets/'); - copy(dirname(__FILE__).'/chm_style.css', $this->output_dir.'/assets/chm_style.css'); - } - - Prado::setPathOfAlias('Output', realpath($this->output_dir)); - } - - public function buildDoc($pages) - { - foreach($pages as $section) - { - foreach($section as $page) - { - $this->parsePage($page); - } - } - } - - protected function initApp() - { - $this->app = new TApplication($this->base); - $response = new THttpResponse(); - $response->setBufferOutput(false); - $this->app->setResponse($response); - $assets = new TAssetManager(); - $assets->setBasePath('Output.assets.*'); - $this->app->setAssetManager($assets); - } - - public function parsePage($page) - { - $_GET['page'] = str_replace(array('/','.page'),array('.',''),$page); - $_GET['notheme'] = 'true'; - - $html = $this->parseHtmlContent($this->getApplicationContent()); - $file = str_replace(array('/','.page'), array('_','.html'),$page); -// echo 'writing file '.$file."\n"; - file_put_contents($this->output_dir.'/'.$file, $html); - } - - public function getApplicationContent() - { - ob_start(); - $this->initApp(); - $this->app->run(); - $content = ob_get_contents(); - ob_end_clean(); - return $content; - } - - public function parseHtmlContent($content) - { - $html = preg_replace('/]+\/>/m', '', $content); -$html = str_replace('', '', $html); -$html = preg_replace('/