diff options
Diffstat (limited to 'buildscripts')
84 files changed, 14127 insertions, 14127 deletions
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 @@ -<?php
-//
-// +------------------------------------------------------------------------+
-// | PEAR :: Benchmark |
-// +------------------------------------------------------------------------+
-// | Copyright (c) 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
-// +------------------------------------------------------------------------+
-// | 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
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Iterate.php';
- *
- * $benchmark = new Benchmark_Iterate;
- *
- * function foo($string) {
- * print $string . '<br>';
- * }
- *
- * $benchmark->run(100, 'foo', 'test');
- * $result = $benchmark->get();
- * ?>
- * </code>
- *
- * Example 2
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Iterate.php';
- *
- * $benchmark = new Benchmark_Iterate;
- *
- * class MyClass {
- * function foo($string) {
- * print $string . '<br>';
- * }
- * }
- *
- * $benchmark->run(100, 'myclass::foo', 'test');
- * $result = $benchmark->get();
- * ?>
- * </code>
- *
- * Example 3
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Iterate.php';
- *
- * $benchmark = new Benchmark_Iterate;
- *
- * class MyClass {
- * function foo($string) {
- * print $string . '<br>';
- * }
- * }
- *
- * $o = new MyClass();
- *
- * $benchmark->run(100, 'o->foo', 'test');
- * $result = $benchmark->get();
- * ?>
- * </code>
- *
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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;
- }
-}
+<?php +// +// +------------------------------------------------------------------------+ +// | PEAR :: Benchmark | +// +------------------------------------------------------------------------+ +// | Copyright (c) 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>. | +// +------------------------------------------------------------------------+ +// | 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 + * + * <code> + * <?php + * require_once 'Benchmark/Iterate.php'; + * + * $benchmark = new Benchmark_Iterate; + * + * function foo($string) { + * print $string . '<br>'; + * } + * + * $benchmark->run(100, 'foo', 'test'); + * $result = $benchmark->get(); + * ?> + * </code> + * + * Example 2 + * + * <code> + * <?php + * require_once 'Benchmark/Iterate.php'; + * + * $benchmark = new Benchmark_Iterate; + * + * class MyClass { + * function foo($string) { + * print $string . '<br>'; + * } + * } + * + * $benchmark->run(100, 'myclass::foo', 'test'); + * $result = $benchmark->get(); + * ?> + * </code> + * + * Example 3 + * + * <code> + * <?php + * require_once 'Benchmark/Iterate.php'; + * + * $benchmark = new Benchmark_Iterate; + * + * class MyClass { + * function foo($string) { + * print $string . '<br>'; + * } + * } + * + * $o = new MyClass(); + * + * $benchmark->run(100, 'o->foo', 'test'); + * $result = $benchmark->get(); + * ?> + * </code> + * + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-//
-// +----------------------------------------------------------------------+
-// | PEAR :: Benchmark |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 2002-2006 Matthias Englert <Matthias.Englert@gmx.de>. |
-// +----------------------------------------------------------------------+
-// | 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.
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Profiler.php';
- *
- * $profiler = new Benchmark_Profiler(TRUE);
- *
- * function myFunction() {
- * global $profiler;
- * $profiler->enterSection('myFunction');
- * //do something
- * $profiler->leaveSection('myFunction');
- * return;
- * }
- *
- * //do something
- * myFunction();
- * //do more
- * ?>
- * </code>
- *
- * Example 2: Manual profiling start, stop, and output.
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Profiler.php';
- *
- * $profiler = new Benchmark_Profiler();
- *
- * function myFunction() {
- * global $profiler;
- * $profiler->enterSection('myFunction');
- * //do something
- * $profiler->leaveSection('myFunction');
- * return;
- * }
- *
- * $profiler->start();
- * //do something
- * myFunction();
- * //do more
- * $profiler->stop();
- * $profiler->display();
- * ?>
- * </code>
- *
- * @author Matthias Englert <Matthias.Englert@gmx.de>
- * @copyright Copyright © 2002-2005 Matthias Englert <Matthias.Englert@gmx.de>
- * @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 = '<table style="border: 1px solid #000000; ">'."\n";
- $out .=
- '<tr><td> </td><td align="center"><b>total ex. time</b></td>'.
- '<td align="center"><b>netto ex. time</b></td>'.
- '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'.
- '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'.
- "\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 .= "<tr><td><b>$name</b></td><td>{$values['time']}</td><td>{$values['netto_time']}</td><td>{$values['num_calls']}</td>";
- if (is_numeric($values['percentage'])) {
- $out .= "<td align=\"right\">{$values['percentage']}%</td>\n";
- } else {
- $out .= "<td align=\"right\">{$values['percentage']}</td>\n";
- }
- $out .= "<td>$calls_str</td><td>$callers_str</td></tr>";
- } 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 . '</table>';
- } 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);
- }
-}
+<?php +// +// +----------------------------------------------------------------------+ +// | PEAR :: Benchmark | +// +----------------------------------------------------------------------+ +// | Copyright (c) 2002-2006 Matthias Englert <Matthias.Englert@gmx.de>. | +// +----------------------------------------------------------------------+ +// | 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. + * + * <code> + * <?php + * require_once 'Benchmark/Profiler.php'; + * + * $profiler = new Benchmark_Profiler(TRUE); + * + * function myFunction() { + * global $profiler; + * $profiler->enterSection('myFunction'); + * //do something + * $profiler->leaveSection('myFunction'); + * return; + * } + * + * //do something + * myFunction(); + * //do more + * ?> + * </code> + * + * Example 2: Manual profiling start, stop, and output. + * + * <code> + * <?php + * require_once 'Benchmark/Profiler.php'; + * + * $profiler = new Benchmark_Profiler(); + * + * function myFunction() { + * global $profiler; + * $profiler->enterSection('myFunction'); + * //do something + * $profiler->leaveSection('myFunction'); + * return; + * } + * + * $profiler->start(); + * //do something + * myFunction(); + * //do more + * $profiler->stop(); + * $profiler->display(); + * ?> + * </code> + * + * @author Matthias Englert <Matthias.Englert@gmx.de> + * @copyright Copyright © 2002-2005 Matthias Englert <Matthias.Englert@gmx.de> + * @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 = '<table style="border: 1px solid #000000; ">'."\n"; + $out .= + '<tr><td> </td><td align="center"><b>total ex. time</b></td>'. + '<td align="center"><b>netto ex. time</b></td>'. + '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'. + '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'. + "\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 .= "<tr><td><b>$name</b></td><td>{$values['time']}</td><td>{$values['netto_time']}</td><td>{$values['num_calls']}</td>"; + if (is_numeric($values['percentage'])) { + $out .= "<td align=\"right\">{$values['percentage']}%</td>\n"; + } else { + $out .= "<td align=\"right\">{$values['percentage']}</td>\n"; + } + $out .= "<td>$calls_str</td><td>$callers_str</td></tr>"; + } 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 . '</table>'; + } 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 @@ -<?php
-//
-// +------------------------------------------------------------------------+
-// | PEAR :: Benchmark |
-// +------------------------------------------------------------------------+
-// | Copyright (c) 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
-// +------------------------------------------------------------------------+
-// | 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.
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Timer.php';
- *
- * $timer = new Benchmark_Timer(TRUE);
- * $timer->setMarker('Marker 1');
- * ?>
- * </code>
- *
- * Example 2: Manual profiling start, stop, and output.
- *
- * <code>
- * <?php
- * require_once 'Benchmark/Timer.php';
- *
- * $timer = new Benchmark_Timer();
- * $timer->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
- * ?>
- * </code>
- *
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @author Ludovico Magnocavallo <ludo@sumatrasolutions.com>
- * @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 = '<table border="1">'."\n";
- $out .= '<tr><td> </td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'.
- ($showTotal ?
- '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>'
- : '')."</tr>\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 .= "<tr><td><b>" . $v['name'] .
- "</b></td><td>" . $v['time'] .
- "</td><td>" . $v['diff'] .
- "</td><td align=\"right\">" . number_format($perc, 2, '.', '') .
- "%</td>".
- ($showTotal ?
- "<td>" . $v['total'] .
- "</td><td align=\"right\">" .
- number_format($tperc, 2, '.', '') .
- "%</td>" : '').
- "</tr>\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 .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n";
- $out .= "</table>\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);
- }
-}
+<?php +// +// +------------------------------------------------------------------------+ +// | PEAR :: Benchmark | +// +------------------------------------------------------------------------+ +// | Copyright (c) 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>. | +// +------------------------------------------------------------------------+ +// | 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. + * + * <code> + * <?php + * require_once 'Benchmark/Timer.php'; + * + * $timer = new Benchmark_Timer(TRUE); + * $timer->setMarker('Marker 1'); + * ?> + * </code> + * + * Example 2: Manual profiling start, stop, and output. + * + * <code> + * <?php + * require_once 'Benchmark/Timer.php'; + * + * $timer = new Benchmark_Timer(); + * $timer->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 + * ?> + * </code> + * + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @author Ludovico Magnocavallo <ludo@sumatrasolutions.com> + * @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 = '<table border="1">'."\n"; + $out .= '<tr><td> </td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'. + ($showTotal ? + '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>' + : '')."</tr>\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 .= "<tr><td><b>" . $v['name'] . + "</b></td><td>" . $v['time'] . + "</td><td>" . $v['diff'] . + "</td><td align=\"right\">" . number_format($perc, 2, '.', '') . + "%</td>". + ($showTotal ? + "<td>" . $v['total'] . + "</td><td align=\"right\">" . + number_format($tperc, 2, '.', '') . + "%</td>" : ''). + "</tr>\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 .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n"; + $out .= "</table>\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 @@ -<?php
-require '../Timer.php';
-
-function wait($amount) {
- for ($i=0; $i < $amount; $i++) {
- for ($i=0; $i < 100; $i++);
- }
-}
-// Pass the param "true" to constructor to automatically display the results
-$timer = new Benchmark_Timer();
-$timer->start();
-wait(10);
-$timer->setMarker('Mark1');
-echo "Elapsed time between Start and Mark1: " .
- $timer->timeElapsed('Start', 'Mark1') . "\n";
-wait(50);
-$timer->stop();
-$timer->display();
+<?php +require '../Timer.php'; + +function wait($amount) { + for ($i=0; $i < $amount; $i++) { + for ($i=0; $i < 100; $i++); + } +} +// Pass the param "true" to constructor to automatically display the results +$timer = new Benchmark_Timer(); +$timer->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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <adam@trachtenberg.com>
- */
- 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <adam@trachtenberg.com> + */ + 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- *
- * <code>
- * <?php
- * require_once 'PHPUnit2/Framework/TestCase.php';
- *
- * class MathTest extends PHPUnit2_Framework_TestCase {
- * public $value1;
- * public $value2;
- *
- * public function __construct($name) {
- * parent::__construct($name);
- * }
- *
- * public function setUp() {
- * $this->value1 = 2;
- * $this->value2 = 3;
- * }
- * }
- * ?>
- * </code>
- *
- * For each test implement a method which interacts with the fixture.
- * Verify the expected results with assertions specified by calling
- * assert with a boolean.
- *
- * <code>
- * <?php
- * public function testPass() {
- * $this->assertTrue($this->value1 + $this->value2 == 5);
- * }
- * ?>
- * </code>
- *
- * @category Testing
- * @package PHPUnit2
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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: + * + * <code> + * <?php + * require_once 'PHPUnit2/Framework/TestCase.php'; + * + * class MathTest extends PHPUnit2_Framework_TestCase { + * public $value1; + * public $value2; + * + * public function __construct($name) { + * parent::__construct($name); + * } + * + * public function setUp() { + * $this->value1 = 2; + * $this->value2 = 3; + * } + * } + * ?> + * </code> + * + * For each test implement a method which interacts with the fixture. + * Verify the expected results with assertions specified by calling + * assert with a boolean. + * + * <code> + * <?php + * public function testPass() { + * $this->assertTrue($this->value1 + $this->value2 == 5); + * } + * ?> + * </code> + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- *
- * <code>
- * array(
- * "testCase" => array(
- * "/tested/code.php" => array(
- * linenumber => flag
- * )
- * )
- * )
- * </code>
- *
- * 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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: + * + * <code> + * array( + * "testCase" => array( + * "/tested/code.php" => array( + * linenumber => flag + * ) + * ) + * ) + * </code> + * + * 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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.
- *
- * <code>
- * <?php
- * $suite = new PHPUnit2_Framework_TestSuite;
- * $suite->addTest(new MathTest('testPass'));
- * ?>
- * </code>
- *
- * 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.
- *
- * <code>
- * <?php
- * $suite = new PHPUnit2_Framework_TestSuite(
- * new ReflectionClass('MathTest')
- * );
- * ?>
- * </code>
- *
- * This constructor creates a suite with all the methods starting with
- * "test" that take no arguments.
- *
- * @category Testing
- * @package PHPUnit2
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <code>addTest()</code> and <code>addTestSuite</code>
- * 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 <code>PHPUnit2_Framework_Warning</code> 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 <stefano@rausch-e.net>
- */
- 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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. + * + * <code> + * <?php + * $suite = new PHPUnit2_Framework_TestSuite; + * $suite->addTest(new MathTest('testPass')); + * ?> + * </code> + * + * 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. + * + * <code> + * <?php + * $suite = new PHPUnit2_Framework_TestSuite( + * new ReflectionClass('MathTest') + * ); + * ?> + * </code> + * + * This constructor creates a suite with all the methods starting with + * "test" that take no arguments. + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <code>addTest()</code> and <code>addTestSuite</code> + * 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 <code>PHPUnit2_Framework_Warning</code> 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 <stefano@rausch-e.net> + */ + 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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<RETURN> 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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<RETURN> 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <file> Write Code Coverage data in raw format to file.\n" .
- " --coverage-html <file> Write Code Coverage data in HTML format to file.\n" .
- " --coverage-text <file> Write Code Coverage data in text format to file.\n\n";
- }
-
- print " --testdox-html <file> Write agile documentation in HTML format to file.\n" .
- " --testdox-text <file> Write agile documentation in Text format to file.\n" .
- " --log-xml <file> Log test progress in XML format to file.\n\n";
-
- print " --loader <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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <file> Write Code Coverage data in raw format to file.\n" . + " --coverage-html <file> Write Code Coverage data in HTML format to file.\n" . + " --coverage-text <file> Write Code Coverage data in text format to file.\n\n"; + } + + print " --testdox-html <file> Write agile documentation in HTML format to file.\n" . + " --testdox-text <file> Write agile documentation in Text format to file.\n" . + " --log-xml <file> Log test progress in XML format to file.\n\n"; + + print " --loader <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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- *
- * <code>
- * array(
- * "/tested/code.php" => array(
- * linenumber => flag
- * )
- * )
- * </code>
- *
- * 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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: + * + * <code> + * array( + * "/tested/code.php" => array( + * linenumber => flag + * ) + * ) + * </code> + * + * 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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
- *
- * <code>
- * 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;
- * }
- * </code>
- *
- * @category Testing
- * @package PHPUnit2
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 =
-'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link href="codecoverage.css" type="text/css" rel="stylesheet" />
- </head>
- <body>
-';
-
- const pageFooter =
-' </body>
-</html>
-';
-
- const sourceFileHeader =
-' <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%">
-';
-
- const sourceFileFooter =
-' </table>
-';
-
- const codeLine =
-' <tr><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr>
-';
-
- /**
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 + * + * <code> + * 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; + * } + * </code> + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 = +'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <link href="codecoverage.css" type="text/css" rel="stylesheet" /> + </head> + <body> +'; + + const pageFooter = +' </body> +</html> +'; + + const sourceFileHeader = +' <table style="border: 1px solid black" cellspacing="0" cellpadding="0" width="100%"> +'; + + const sourceFileFooter = +' </table> +'; + + const codeLine = +' <tr><td class="ccLineNumber">%s</td><td class="%s">%s</td></tr> +'; + + /** + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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.
- *
- * <code>
- * <?php
- * require_once 'PHPUnit2/Util/Skeleton.php';
- *
- * $skeleton = new PHPUnit2_Util_Skeleton(
- * 'PHPUnit2_Util_Skeleton',
- * 'PHPUnit2/Util/Skeleton.php'
- * );
- *
- * $skeleton->write();
- * ?>
- * </code>
- *
- * @category Testing
- * @package PHPUnit2
- * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 =
-'<?php
-// Call {className}Test::main() if this source file is executed directly.
-if (!defined("PHPUnit2_MAIN_METHOD")) {
- define("PHPUnit2_MAIN_METHOD", "{className}Test::main");
-}
-
-require_once "PHPUnit2/Framework/TestCase.php";
-require_once "PHPUnit2/Framework/TestSuite.php";
-
-// You may remove the following line when all tests have been implemented.
-require_once "PHPUnit2/Framework/IncompleteTestError.php";
-
-require_once "{classFile}";
-
-/**
- * Test class for {className}.
- * Generated by PHPUnit2_Util_Skeleton on {date} at {time}.
- */
-class {className}Test extends PHPUnit2_Framework_TestCase {
- /**
- * Runs the test methods of this class.
- *
- * @access public
- * @static
- */
- public static function main() {
- require_once "PHPUnit2/TextUI/TestRunner.php";
-
- $suite = new PHPUnit2_Framework_TestSuite("{className}Test");
- $result = PHPUnit2_TextUI_TestRunner::run($suite);
- }
-
- /**
- * 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() {
- }
-';
-
- protected $templateClassFooter =
-'}
-
-// Call {className}Test::main() if this source file is executed directly.
-if (PHPUnit2_MAIN_METHOD == "{className}Test::main") {
- {className}Test::main();
-}
-?>
-';
-
- 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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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. + * + * <code> + * <?php + * require_once 'PHPUnit2/Util/Skeleton.php'; + * + * $skeleton = new PHPUnit2_Util_Skeleton( + * 'PHPUnit2_Util_Skeleton', + * 'PHPUnit2/Util/Skeleton.php' + * ); + * + * $skeleton->write(); + * ?> + * </code> + * + * @category Testing + * @package PHPUnit2 + * @author Sebastian Bergmann <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 = +'<?php +// Call {className}Test::main() if this source file is executed directly. +if (!defined("PHPUnit2_MAIN_METHOD")) { + define("PHPUnit2_MAIN_METHOD", "{className}Test::main"); +} + +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "PHPUnit2/Framework/TestSuite.php"; + +// You may remove the following line when all tests have been implemented. +require_once "PHPUnit2/Framework/IncompleteTestError.php"; + +require_once "{classFile}"; + +/** + * Test class for {className}. + * Generated by PHPUnit2_Util_Skeleton on {date} at {time}. + */ +class {className}Test extends PHPUnit2_Framework_TestCase { + /** + * Runs the test methods of this class. + * + * @access public + * @static + */ + public static function main() { + require_once "PHPUnit2/TextUI/TestRunner.php"; + + $suite = new PHPUnit2_Framework_TestSuite("{className}Test"); + $result = PHPUnit2_TextUI_TestRunner::run($suite); + } + + /** + * 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() { + } +'; + + protected $templateClassFooter = +'} + +// Call {className}Test::main() if this source file is executed directly. +if (PHPUnit2_MAIN_METHOD == "{className}Test::main") { + {className}Test::main(); +} +?> +'; + + 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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('<html><body>');
- }
-
- /**
- * Handler for 'start class' event.
- *
- * @param string $name
- * @access protected
- */
- protected function startClass($name) {
- $this->write('<h2>' . $name . '</h2><ul>');
- }
-
- /**
- * Handler for 'on test' event.
- *
- * @param string $name
- * @access protected
- */
- protected function onTest($name) {
- $this->write('<li>' . $name . '</li>');
- }
-
- /**
- * Handler for 'end class' event.
- *
- * @param string $name
- * @access protected
- */
- protected function endClass($name) {
- $this->write('</ul>');
- }
-
- /**
- * Handler for 'end run' event.
- *
- * @access protected
- */
- protected function endRun() {
- $this->write('</body></html>');
- }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * c-hanging-comment-ender-p: nil
- * End:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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('<html><body>'); + } + + /** + * Handler for 'start class' event. + * + * @param string $name + * @access protected + */ + protected function startClass($name) { + $this->write('<h2>' . $name . '</h2><ul>'); + } + + /** + * Handler for 'on test' event. + * + * @param string $name + * @access protected + */ + protected function onTest($name) { + $this->write('<li>' . $name . '</li>'); + } + + /** + * Handler for 'end class' event. + * + * @param string $name + * @access protected + */ + protected function endClass($name) { + $this->write('</ul>'); + } + + /** + * Handler for 'end run' event. + * + * @access protected + */ + protected function endRun() { + $this->write('</body></html>'); + } +} + +/* + * 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 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * PHP Version 5
- *
- * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>.
- * 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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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 <sb@sebastian-bergmann.de>
- * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>
- * @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:
- */
-?>
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ + +/** + * PHP Version 5 + * + * Copyright (c) 2002-2006, Sebastian Bergmann <sb@sebastian-bergmann.de>. + * 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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 <sb@sebastian-bergmann.de> + * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> + * @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 @@ -<?php
-
-class ChmQuickstartBuilder
-{
- private $base;
- const DEMO_URL = 'http://www.pradosoft.com/demos/quickstart/';
- const CSS_URL = 'assets/chm_style.css';
- private $output_dir;
- private $app;
-
- private $_viewed=array();
-
- public function __construct($base,$output)
- {
- $this->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('/<input.*name="PRADO_PAGESTATE" [^>]+\/>/m', '', $content);
-$html = str_replace('<div id="header">
-<div class="title">Prado QuickStart Tutorial</div>
-<div class="image"></div>
-</div>', '', $html);
-$html = preg_replace('/<div id="footer">.*?<\/div>/ms', '<div id="footer">
-Copyright © 2005-2007 <a href="http://www.pradosoft.com">PradoSoft</a>.</div>', $html);
-
-
- $html = str_replace('</head>', '<link rel="stylesheet" type="text/css" href="'.self::CSS_URL.'" /></head>', $html);
-
- $html = preg_replace_callback('/(?<!RunButton" )href=".*\?page=([a-zA-Z0-9\.#]+)"/',
- array($this, 'update_page_url'), $html);
- $html = preg_replace_callback('/(?<=RunButton" )href=".*\?page=([a-zA-Z0-9\.#]+)"/',
- array($this, 'update_run_url'), $html);
-
- $html = preg_replace('/(src|href)=("?)\//', '$1=$2assets/',$html);
- $html = str_replace('http://www.pradosoft.com/docs/manual', '../manual/CHMdefaultConverter', $html);
- $html = str_replace('target="_blank">View Source', '>View Source', $html);
- $html = preg_replace('/action="[^"]+"/', '', $html);
- $html = preg_replace('/<script[^>]+><\/script>/', '', $html); //remove js
- $html = preg_replace('/href="C:[^"]+"/', 'href="#"', $html);
-
- $html = preg_replace_callback('/href="\?page=ViewSource&(amp;){0,1}path=([a-zA-z0-9\.\/]+)"/',
- array($this, 'update_source_url'), $html);
-
- return $html;
- }
-
- protected function update_source_url($matches)
- {
- $page = $matches[2];
- $file = str_replace('/', '_',$page).'.html';
-
- if(!isset($this->_viewed[$page]))
- {
- $this->_viewed[$page]=true;
- $this->view_source_page($page);
- }
- return 'href="'.$file.'"';
- }
-
- protected function view_source_page($page)
- {
- $_GET['page'] = 'ViewSource';
- $_GET['path'] = $page;
- $_GET['lines'] = 'false';
-
- $html = $this->parseHtmlContent($this->getApplicationContent());
- $file = str_replace('/', '_',$page).'.html';
-// echo 'writing file '.$file."\n";
- file_put_contents($this->output_dir.'/'.$file, $html);
- }
-
- protected function update_page_url($matches)
- {
- $bits = explode('#',str_replace('.','_',$matches[1]));
- $anchor = isset($bits[1]) ? '#'.$bits[1] : '';
- return 'href="'.$bits[0].'.html'.$anchor.'"';
- }
-
- protected function update_run_url($matches)
- {
- return 'href="'.self::DEMO_URL.'?page='.$matches[1].'"';
- }
-}
-
-class HTMLHelpTOCBuilder
-{
-
- public function buildToc($file,$output,$classes)
- {
- $contents = file_get_contents($file);
- $content = $this->prepareContent($contents);
- $ul = $this->parseUl($content);
- $toc = $this->header();
- $toc .= $this->to_string($ul);
- $toc .= $this->footer();
- $toc = $this->appendApiToc($output,$toc);
- $toc = $this->appendClassesToc($classes,$toc);
- file_put_contents($output.'/toc.hhc', $toc);
- file_put_contents($output.'/prado3_manual.hhp', $this->getHHP());
- file_put_contents($output.'/manual.html', $this->getIndexPage());
- $index = $output.'/manual/CHMdefaultConverter/index.hhk';
- file_put_contents($index, $this->updateIndex($index));
- }
-
- protected function updateIndex($file)
- {
- $content = file_get_contents($file);
- return preg_replace('/"Local" value="/', '"Local" value="manual\\CHMdefaultConverter\\', $content);
- }
-
- protected function appendClassesToc($classes, $toc)
- {
- $version = Prado::getVersion();
- $ul['classes']['params'][] = array('Name' => "Prado {$version} Class Index");
- foreach($classes as $class)
- {
- $ul['classes']['ul'][0]['params'][] =
- array('Name'=>$class, 'Local'=>'classdoc/'.$class.'.html');
- }
- $ul['wiki']['params'][] = array('Name' => "Prado Wiki", 'Local'=>'wiki\\index.html');
- $content = $this->to_string($ul);
- $toc = preg_replace('!(</BODY></HTML>)!', $content.'$1', $toc);
- return $toc;
- }
-
- protected function appendApiToc($output,$toc)
- {
- $content = file_get_contents($output.'/manual/CHMdefaultConverter/contents.hhc');
- $content = preg_replace('/"Local" value="/', '"Local" value="manual\\CHMdefaultConverter\\', $content);
- $toc = preg_replace('!(API Manual">\s*</OBJECT>)\s*(</UL>\s*</BODY></HTML>)!', '$1'."\n".$content.'$2', $toc);
- return preg_replace("/\r/","\n",$toc);
- }
-
- protected function getIndexPage()
- {
- $version = Prado::getVersion();
- $date = date('d M Y', time());
- $year = date('Y',time());
-$content = <<<EOD
-<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Prado Manual</title>
- <style type="text/css">
- /*<![CDATA[*/
- body
- {
- font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
- font-weight:normal;
- }
- h1
- {
- color: #600;
- }
- /*]]>*/
- </style>
-</head>
-
-<body style="text-align:center">
-
-<h1>Prado {$version} Manual</h1>
-
-<div>Created On: {$date}</div>
-
-<div style="margin-top:3em;margin-bottom:0.75em"><strong>Written By:</strong> Qiang Xue, Wei Zhuo</div>
-<div style="margin-bottom:3em;"><strong>Edited By:</strong> Wei Zhuo</div>
-
-<div id="footer">
-Copyright © 2005-{$year} <a href="http://www.pradosoft.com">PradoSoft</a>.</div>
-
-</body>
-</html>
-EOD;
- return $content;
- }
-
- protected function getHHP()
- {
- $version = Prado::getVersion();
-$content = <<<EOD
-[OPTIONS]
-Binary TOC=Yes
-Compatibility=1.1 or later
-Compiled File=prado3_manual.chm
-Contents File=toc.hhc
-Default Window=main
-Default Topic=manual.html
-Display compile progress=Yes
-Error log file=_errorlog.txt
-Full-text search=Yes
-Language=0x409 English (United States)
-Title=Prado {$version} Manual
-Binary Index=Yes
-Index file=manual\CHMdefaultConverter\index.hhk
-Default Font=
-Auto Index=Yes
-Create CHI file=No
-Full text search stop list file=
-Display compile notes=Yes
-
-[WINDOWS]
-main="Prado {$version} Manual","toc.hhc","manual\CHMdefaultConverter\index.hhk","manual.html","manual.html",,,,,0x63520,250,0x104e,[10,10,900,700],0xb0000,,,,,,0
-
-EOD;
- return $content;
- }
-
- protected function parseUl($content)
- {
- $ul = array();
- $current = null;
- $ul['index']['params'][] = array('Name'=>'Prado Manual', 'Local'=>'manual.html');
-
- foreach(explode("\n", $content) as $line)
- {
- $line = trim($line);
- if(strlen($line) > 0)
- {
- if(strpos($line,'^')===false)
- {
- $current = $line;
- $ul[$current]['params'][]['Name'] = $current;
- }
- else
- {
- list($page,$title) = explode('^', $line);
- $ul[$current]['ul'][0]['params'][] = array('Name'=>$title, 'Local'=>$this->getFileName($page));
- }
- }
- }
- $version = Prado::getVersion();
- $ul['api']['params'][] = array('Name' => "Prado {$version} API Manual");
-
- return $ul;
- }
-
- protected function getFileName($page)
- {
- return 'quickstart\\'.str_replace('.', '_',$page).'.html';
- }
-
- protected function prepareContent($content)
- {
- $content = preg_replace('/<\/?div[^>]*>/','', $content);
- $content = preg_replace('/<\/?ul>|<\/?li>|<\/a>/ms', '', $content);
- $content = str_replace('<a href="?page=', '', $content);
- $content = str_replace('">', '^', $content);
- return $content;
- }
-
- public function to_string($ul)
- {
- $contents = "<UL>\n";
- foreach($ul as $li)
- {
- if(isset($li['params']))
- {
- $contents .= $this->li_to_string($li);
- }
- if(isset($li['ul']))
- {
- $contents .= $this->to_string($li['ul']);
- }
- }
- $contents .= "</UL>\n";
- return $contents;
- }
-
- protected function li_to_string($li)
- {
- $contents = '';
- foreach($li['params'] as $param)
- {
- $contents .= "\t<LI>";
- $contents .= "<OBJECT type=\"text/sitemap\">\n";
- foreach($param as $name => $value)
- $contents .= "\t\t\t<param name=\"$name\" value=\"$value\">\n";
- $contents .= "\t\t</OBJECT>\n";
- }
- return $contents;
- }
-
- public function header()
- {
- $content = <<<EOD
-<HTML>
-<HEAD>
-</HEAD>
-<BODY>
- <OBJECT type="text/site properties">
- <param name="Window Styles" value="0x800025">
- <param name="FrameName" value="right">
- <param name="ImageType" value="Folder">
- <param name="comment" value="title:Online Help">
- <param name="comment" value="base:index.htm">
- </OBJECT>
-
-EOD;
- return $content;
- }
-
- public function footer()
- {
- return '</BODY></HTML>';
- }
-}
-
-class ClassDocBuilder
-{
- private $output;
- private $base;
-
- function __construct($base, $output)
- {
- $this->base = $base;
- $this->output = $output.'/classdoc';
- if(!is_dir($this->output))
- {
- mkdir($this->output);
- mkdir($this->output.'/assets/');
- }
- Prado::setPathOfAlias('Output', $this->output);
- }
-
- 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 buildDoc($class)
- {
- $this->parsePage($class);
- }
-
- public function parseBasePage()
- {
- $_GET['page'] = 'Classes';
-
- $html = $this->parseHtmlContent($this->getApplicationContent());
- $file = 'Classes.html';
-// echo 'writing file '.$file."\n";
- file_put_contents($this->output.'/'.$file, $html);
- }
-
- public function parsePage($class)
- {
- $_GET['page'] = 'ClassDoc';
- $_GET['class'] = $class;
-
- $html = $this->parseHtmlContent($this->getApplicationContent());
- $file = $class.'.html';
-// echo 'writing file '.$file."\n";
- file_put_contents($this->output.'/'.$file, $html);
- }
-
- protected function getApplicationContent()
- {
- ob_start();
- $this->initApp();
- $this->app->run();
- $content = ob_get_contents();
- ob_end_clean();
- $this->app->completeRequest();
- $this->app=null;
- return $content;
- }
-
- protected function parseHtmlContent($content)
- {
- $html = preg_replace('/<input.*name="PRADO_PAGESTATE" [^>]+\/>/m', '', $content);
- $html = preg_replace('!href="/(\w+)/style.css"!', 'href="assets/$1/style.css"', $html);
- return $html;
- }
-}
-
-
+<?php + +class ChmQuickstartBuilder +{ + private $base; + const DEMO_URL = 'http://www.pradosoft.com/demos/quickstart/'; + const CSS_URL = 'assets/chm_style.css'; + private $output_dir; + private $app; + + private $_viewed=array(); + + public function __construct($base,$output) + { + $this->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('/<input.*name="PRADO_PAGESTATE" [^>]+\/>/m', '', $content); +$html = str_replace('<div id="header"> +<div class="title">Prado QuickStart Tutorial</div> +<div class="image"></div> +</div>', '', $html); +$html = preg_replace('/<div id="footer">.*?<\/div>/ms', '<div id="footer"> +Copyright © 2005-2007 <a href="http://www.pradosoft.com">PradoSoft</a>.</div>', $html); + + + $html = str_replace('</head>', '<link rel="stylesheet" type="text/css" href="'.self::CSS_URL.'" /></head>', $html); + + $html = preg_replace_callback('/(?<!RunButton" )href=".*\?page=([a-zA-Z0-9\.#]+)"/', + array($this, 'update_page_url'), $html); + $html = preg_replace_callback('/(?<=RunButton" )href=".*\?page=([a-zA-Z0-9\.#]+)"/', + array($this, 'update_run_url'), $html); + + $html = preg_replace('/(src|href)=("?)\//', '$1=$2assets/',$html); + $html = str_replace('http://www.pradosoft.com/docs/manual', '../manual/CHMdefaultConverter', $html); + $html = str_replace('target="_blank">View Source', '>View Source', $html); + $html = preg_replace('/action="[^"]+"/', '', $html); + $html = preg_replace('/<script[^>]+><\/script>/', '', $html); //remove js + $html = preg_replace('/href="C:[^"]+"/', 'href="#"', $html); + + $html = preg_replace_callback('/href="\?page=ViewSource&(amp;){0,1}path=([a-zA-z0-9\.\/]+)"/', + array($this, 'update_source_url'), $html); + + return $html; + } + + protected function update_source_url($matches) + { + $page = $matches[2]; + $file = str_replace('/', '_',$page).'.html'; + + if(!isset($this->_viewed[$page])) + { + $this->_viewed[$page]=true; + $this->view_source_page($page); + } + return 'href="'.$file.'"'; + } + + protected function view_source_page($page) + { + $_GET['page'] = 'ViewSource'; + $_GET['path'] = $page; + $_GET['lines'] = 'false'; + + $html = $this->parseHtmlContent($this->getApplicationContent()); + $file = str_replace('/', '_',$page).'.html'; +// echo 'writing file '.$file."\n"; + file_put_contents($this->output_dir.'/'.$file, $html); + } + + protected function update_page_url($matches) + { + $bits = explode('#',str_replace('.','_',$matches[1])); + $anchor = isset($bits[1]) ? '#'.$bits[1] : ''; + return 'href="'.$bits[0].'.html'.$anchor.'"'; + } + + protected function update_run_url($matches) + { + return 'href="'.self::DEMO_URL.'?page='.$matches[1].'"'; + } +} + +class HTMLHelpTOCBuilder +{ + + public function buildToc($file,$output,$classes) + { + $contents = file_get_contents($file); + $content = $this->prepareContent($contents); + $ul = $this->parseUl($content); + $toc = $this->header(); + $toc .= $this->to_string($ul); + $toc .= $this->footer(); + $toc = $this->appendApiToc($output,$toc); + $toc = $this->appendClassesToc($classes,$toc); + file_put_contents($output.'/toc.hhc', $toc); + file_put_contents($output.'/prado3_manual.hhp', $this->getHHP()); + file_put_contents($output.'/manual.html', $this->getIndexPage()); + $index = $output.'/manual/CHMdefaultConverter/index.hhk'; + file_put_contents($index, $this->updateIndex($index)); + } + + protected function updateIndex($file) + { + $content = file_get_contents($file); + return preg_replace('/"Local" value="/', '"Local" value="manual\\CHMdefaultConverter\\', $content); + } + + protected function appendClassesToc($classes, $toc) + { + $version = Prado::getVersion(); + $ul['classes']['params'][] = array('Name' => "Prado {$version} Class Index"); + foreach($classes as $class) + { + $ul['classes']['ul'][0]['params'][] = + array('Name'=>$class, 'Local'=>'classdoc/'.$class.'.html'); + } + $ul['wiki']['params'][] = array('Name' => "Prado Wiki", 'Local'=>'wiki\\index.html'); + $content = $this->to_string($ul); + $toc = preg_replace('!(</BODY></HTML>)!', $content.'$1', $toc); + return $toc; + } + + protected function appendApiToc($output,$toc) + { + $content = file_get_contents($output.'/manual/CHMdefaultConverter/contents.hhc'); + $content = preg_replace('/"Local" value="/', '"Local" value="manual\\CHMdefaultConverter\\', $content); + $toc = preg_replace('!(API Manual">\s*</OBJECT>)\s*(</UL>\s*</BODY></HTML>)!', '$1'."\n".$content.'$2', $toc); + return preg_replace("/\r/","\n",$toc); + } + + protected function getIndexPage() + { + $version = Prado::getVersion(); + $date = date('d M Y', time()); + $year = date('Y',time()); +$content = <<<EOD +<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Prado Manual</title> + <style type="text/css"> + /*<![CDATA[*/ + body + { + font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif; + font-weight:normal; + } + h1 + { + color: #600; + } + /*]]>*/ + </style> +</head> + +<body style="text-align:center"> + +<h1>Prado {$version} Manual</h1> + +<div>Created On: {$date}</div> + +<div style="margin-top:3em;margin-bottom:0.75em"><strong>Written By:</strong> Qiang Xue, Wei Zhuo</div> +<div style="margin-bottom:3em;"><strong>Edited By:</strong> Wei Zhuo</div> + +<div id="footer"> +Copyright © 2005-{$year} <a href="http://www.pradosoft.com">PradoSoft</a>.</div> + +</body> +</html> +EOD; + return $content; + } + + protected function getHHP() + { + $version = Prado::getVersion(); +$content = <<<EOD +[OPTIONS] +Binary TOC=Yes +Compatibility=1.1 or later +Compiled File=prado3_manual.chm +Contents File=toc.hhc +Default Window=main +Default Topic=manual.html +Display compile progress=Yes +Error log file=_errorlog.txt +Full-text search=Yes +Language=0x409 English (United States) +Title=Prado {$version} Manual +Binary Index=Yes +Index file=manual\CHMdefaultConverter\index.hhk +Default Font= +Auto Index=Yes +Create CHI file=No +Full text search stop list file= +Display compile notes=Yes + +[WINDOWS] +main="Prado {$version} Manual","toc.hhc","manual\CHMdefaultConverter\index.hhk","manual.html","manual.html",,,,,0x63520,250,0x104e,[10,10,900,700],0xb0000,,,,,,0 + +EOD; + return $content; + } + + protected function parseUl($content) + { + $ul = array(); + $current = null; + $ul['index']['params'][] = array('Name'=>'Prado Manual', 'Local'=>'manual.html'); + + foreach(explode("\n", $content) as $line) + { + $line = trim($line); + if(strlen($line) > 0) + { + if(strpos($line,'^')===false) + { + $current = $line; + $ul[$current]['params'][]['Name'] = $current; + } + else + { + list($page,$title) = explode('^', $line); + $ul[$current]['ul'][0]['params'][] = array('Name'=>$title, 'Local'=>$this->getFileName($page)); + } + } + } + $version = Prado::getVersion(); + $ul['api']['params'][] = array('Name' => "Prado {$version} API Manual"); + + return $ul; + } + + protected function getFileName($page) + { + return 'quickstart\\'.str_replace('.', '_',$page).'.html'; + } + + protected function prepareContent($content) + { + $content = preg_replace('/<\/?div[^>]*>/','', $content); + $content = preg_replace('/<\/?ul>|<\/?li>|<\/a>/ms', '', $content); + $content = str_replace('<a href="?page=', '', $content); + $content = str_replace('">', '^', $content); + return $content; + } + + public function to_string($ul) + { + $contents = "<UL>\n"; + foreach($ul as $li) + { + if(isset($li['params'])) + { + $contents .= $this->li_to_string($li); + } + if(isset($li['ul'])) + { + $contents .= $this->to_string($li['ul']); + } + } + $contents .= "</UL>\n"; + return $contents; + } + + protected function li_to_string($li) + { + $contents = ''; + foreach($li['params'] as $param) + { + $contents .= "\t<LI>"; + $contents .= "<OBJECT type=\"text/sitemap\">\n"; + foreach($param as $name => $value) + $contents .= "\t\t\t<param name=\"$name\" value=\"$value\">\n"; + $contents .= "\t\t</OBJECT>\n"; + } + return $contents; + } + + public function header() + { + $content = <<<EOD +<HTML> +<HEAD> +</HEAD> +<BODY> + <OBJECT type="text/site properties"> + <param name="Window Styles" value="0x800025"> + <param name="FrameName" value="right"> + <param name="ImageType" value="Folder"> + <param name="comment" value="title:Online Help"> + <param name="comment" value="base:index.htm"> + </OBJECT> + +EOD; + return $content; + } + + public function footer() + { + return '</BODY></HTML>'; + } +} + +class ClassDocBuilder +{ + private $output; + private $base; + + function __construct($base, $output) + { + $this->base = $base; + $this->output = $output.'/classdoc'; + if(!is_dir($this->output)) + { + mkdir($this->output); + mkdir($this->output.'/assets/'); + } + Prado::setPathOfAlias('Output', $this->output); + } + + 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 buildDoc($class) + { + $this->parsePage($class); + } + + public function parseBasePage() + { + $_GET['page'] = 'Classes'; + + $html = $this->parseHtmlContent($this->getApplicationContent()); + $file = 'Classes.html'; +// echo 'writing file '.$file."\n"; + file_put_contents($this->output.'/'.$file, $html); + } + + public function parsePage($class) + { + $_GET['page'] = 'ClassDoc'; + $_GET['class'] = $class; + + $html = $this->parseHtmlContent($this->getApplicationContent()); + $file = $class.'.html'; +// echo 'writing file '.$file."\n"; + file_put_contents($this->output.'/'.$file, $html); + } + + protected function getApplicationContent() + { + ob_start(); + $this->initApp(); + $this->app->run(); + $content = ob_get_contents(); + ob_end_clean(); + $this->app->completeRequest(); + $this->app=null; + return $content; + } + + protected function parseHtmlContent($content) + { + $html = preg_replace('/<input.*name="PRADO_PAGESTATE" [^>]+\/>/m', '', $content); + $html = preg_replace('!href="/(\w+)/style.css"!', 'href="assets/$1/style.css"', $html); + return $html; + } +} + + ?>
\ No newline at end of file diff --git a/buildscripts/chmbuilder/build.php b/buildscripts/chmbuilder/build.php index aeef4ad5..b6ea6c7b 100644 --- a/buildscripts/chmbuilder/build.php +++ b/buildscripts/chmbuilder/build.php @@ -1,80 +1,80 @@ -<?php
-
-$ROOT = dirname(__FILE__);
-
-//page root location
-$base = realpath($ROOT.'/../../demos/quickstart/protected/');
-$output_dir = realpath($ROOT.'/../../build/docs');
-$classData = realpath($ROOT.'/../classtree/classes.data');
-$classDocBase = realpath($ROOT.'/classes/');
-
-//-------------- END CONFIG ------------------
-
-if(!isset($isChild))
- $isChild = false;
-
-$toc_file = $base.'/controls/TopicList.tpl';
-
-$pages = include($ROOT.'/../texbuilder/quickstart/pages.php');
-
-include($ROOT.'/ChmQuickstartBuilder.php');
-include($ROOT.'/../../framework/PradoBase.php');
-class Prado extends PradoBase
-{
- protected static $app;
-
- public static function setApplication($application)
- {
- self::$app=$application;
- }
-
- public static function getApplication()
- {
- return self::$app;
- }
-
- public static function setPathOfAlias($alias,$path)
- {
- $aliases = self::getPathAliases();
- if(!isset($aliases[$alias]))
- parent::setPathOfAlias($alias,$path);
- }
-}
-
-include($ROOT.'/../../framework/prado.php');
-
-if($isChild)
-{
- $classBuilder = new ClassDocBuilder($classDocBase,$output_dir);
- $classBuilder->buildDoc($argv[1]);
-}
-else
-{
- $pages['Control Reference : Standard Controls'][] = 'Controls/Standard.page';
-
-
- $quickstart= new ChmQuickstartBuilder($base,$output_dir.'/quickstart');
- $quickstart->buildDoc($pages);
-
- //move class data to protected data directory for prado app.
- $classFile = $ROOT.'/classes/Data/classes.data';
- if(is_file($classData) && !is_file($classFile))
- copy($classData, $classFile);
- $classes = unserialize(file_get_contents($classFile));
-
- $classBuilder = new ClassDocBuilder($classDocBase,$output_dir);
-
- //use child process to build doc, otherwise it consumes too much memory
- $child_builder = realpath($ROOT.'/build_child.php');
- foreach($classes as $class =>$data)
- {
- passthru('php '.$child_builder.' '.$class);
- }
-
-// $classBuilder->parseBasePage();
-
- $toc = new HTMLHelpTOCBuilder();
- $toc->buildToc($toc_file,$output_dir,array_keys($classes));
-}
-
+<?php + +$ROOT = dirname(__FILE__); + +//page root location +$base = realpath($ROOT.'/../../demos/quickstart/protected/'); +$output_dir = realpath($ROOT.'/../../build/docs'); +$classData = realpath($ROOT.'/../classtree/classes.data'); +$classDocBase = realpath($ROOT.'/classes/'); + +//-------------- END CONFIG ------------------ + +if(!isset($isChild)) + $isChild = false; + +$toc_file = $base.'/controls/TopicList.tpl'; + +$pages = include($ROOT.'/../texbuilder/quickstart/pages.php'); + +include($ROOT.'/ChmQuickstartBuilder.php'); +include($ROOT.'/../../framework/PradoBase.php'); +class Prado extends PradoBase +{ + protected static $app; + + public static function setApplication($application) + { + self::$app=$application; + } + + public static function getApplication() + { + return self::$app; + } + + public static function setPathOfAlias($alias,$path) + { + $aliases = self::getPathAliases(); + if(!isset($aliases[$alias])) + parent::setPathOfAlias($alias,$path); + } +} + +include($ROOT.'/../../framework/prado.php'); + +if($isChild) +{ + $classBuilder = new ClassDocBuilder($classDocBase,$output_dir); + $classBuilder->buildDoc($argv[1]); +} +else +{ + $pages['Control Reference : Standard Controls'][] = 'Controls/Standard.page'; + + + $quickstart= new ChmQuickstartBuilder($base,$output_dir.'/quickstart'); + $quickstart->buildDoc($pages); + + //move class data to protected data directory for prado app. + $classFile = $ROOT.'/classes/Data/classes.data'; + if(is_file($classData) && !is_file($classFile)) + copy($classData, $classFile); + $classes = unserialize(file_get_contents($classFile)); + + $classBuilder = new ClassDocBuilder($classDocBase,$output_dir); + + //use child process to build doc, otherwise it consumes too much memory + $child_builder = realpath($ROOT.'/build_child.php'); + foreach($classes as $class =>$data) + { + passthru('php '.$child_builder.' '.$class); + } + +// $classBuilder->parseBasePage(); + + $toc = new HTMLHelpTOCBuilder(); + $toc->buildToc($toc_file,$output_dir,array_keys($classes)); +} + ?>
\ No newline at end of file diff --git a/buildscripts/chmbuilder/build_child.php b/buildscripts/chmbuilder/build_child.php index 91662373..a466d03a 100644 --- a/buildscripts/chmbuilder/build_child.php +++ b/buildscripts/chmbuilder/build_child.php @@ -1,7 +1,7 @@ -<?php
-
-$isChild = true;
-
-include(dirname(__FILE__).'/build.php');
-
+<?php + +$isChild = true; + +include(dirname(__FILE__).'/build.php'); + ?>
\ No newline at end of file diff --git a/buildscripts/chmbuilder/classes/pages/ClassDoc.php b/buildscripts/chmbuilder/classes/pages/ClassDoc.php index 733cfc5b..fc239890 100644 --- a/buildscripts/chmbuilder/classes/pages/ClassDoc.php +++ b/buildscripts/chmbuilder/classes/pages/ClassDoc.php @@ -1,228 +1,228 @@ -<?php
-
-class ClassDoc extends TPage
-{
- public $Class;
- private $_classes;
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $dataFile=Prado::getPathOfNamespace('Application.Data.classes','.data');
- $this->_classes=unserialize(file_get_contents($dataFile));
-
- if(($className=$this->Request['class'])!==null && isset($this->_classes[$className]))
- {
- $this->Class=$this->_classes[$className];
- $this->Class['Name']=$className;
- $this->Title='PRADO - Documentation of '.$className;
- }
- else
- $this->Response->redirect('/docs/classdoc/');
- }
-
- public function getAncestors()
- {
- $ancestors=array();
- $thisClass=$this->Class;
- while(true)
- {
- $parentClass=$thisClass['ParentClass'];
- if(isset($this->_classes[$parentClass]))
- {
- $ancestors[]=$parentClass;
- $thisClass=$this->_classes[$parentClass];
- }
- else
- break;
- }
- $ancestors=array_reverse($ancestors);
- $s='';
- foreach($ancestors as $ancestor)
- $s.="<a href=\"$ancestor.html\">$ancestor</a> »\n";
- if($s!=='')
- $s="<div class=\"doc-ancestors\">\nInheritance: $s</div>\n";
- return $s;
- }
-
- public function getProperties()
- {
- $class=$this->Class;
- $className=$this->Class['Name'];
- $s='';
- foreach($class['Properties'] as $name=>$property)
- {
- $inherited=strcasecmp($property['class'],$className)!==0;
- $rowclass=$inherited?'doc-inherited':'doc-native';
- $s.="<tr class=\"$rowclass\">\n";
- $access='';
- if($property['readonly'])
- $access.='R';
- if($property['protected'])
- $access.='P';
- if($access==='')
- $access=' ';
- $s.="<td width=\"1\" nowrap=\"nowrap\" align=\"center\">$access</td>\n";
-
- if($inherited)
- {
- $parentClass=$property['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#methodget{$name}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
- else
- $s.="<td>$name</td>\n";
- }
- else
- {
- $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#methodget{$name}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
-
- $type=$property['type'];
- if(isset($this->_classes[$type]))
- {
- $url="$type.html";
- $s.="<td><a href=\"$url\">$type</a></td>\n";
- }
- else
- $s.="<td>$type</td>\n";
-
- $comments=rtrim($property['comments'],'.').'.';
- if($inherited)
- {
- $parentClass=$property['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="$parentClass.html";
- $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)";
- }
- else
- $comments.=" (inherited from {$parentClass})";
- }
- $s.="<td>$comments</td>\n";
- $s.="</tr>\n";
- }
-
- $header="<tr>\n<th> </th><th>Name</th><th>Type</th><th>Description</th>\n</tr>\n";
- return $s===''?'':"<div class=\"doc-properties\">\n<table>\n$header$s</table>\n</div>\n";
- }
-
- public function getEvents()
- {
- $class=$this->Class;
- $className=$this->Class['Name'];
- $s='';
- foreach($class['Events'] as $name=>$event)
- {
- $inherited=strcasecmp($event['class'],$className)!==0;
- $rowclass=$inherited?'doc-inherited':'doc-native';
- $s.="<tr class=\"$rowclass\">\n";
-
- $methodName=$name;
- $methodName[0]='o';
- if($inherited)
- {
- $parentClass=$event['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#method{$methodName}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
- else
- $s.="<td>$name</td>\n";
- }
- else
- {
- $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#method{$methodName}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
-
- $comments=rtrim($event['comments'],'.').'.';
- if($inherited)
- {
- $parentClass=$event['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="$parentClass.html";
- $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)";
- }
- else
- $comments.=" (inherited from {$parentClass})";
- }
- $s.="<td>$comments</td>\n";
- $s.="</tr>\n";
- }
- $header="<tr>\n<th>Name</th><th>Description</th>\n</tr>\n";
- return $s===''?'':"<div class=\"doc-events\">\n<table>\n$header$s</table>\n</div>\n";
- }
-
- public function getMethods()
- {
- $class=$this->Class;
- $className=$this->Class['Name'];
- $s='';
- foreach($class['Methods'] as $name=>$method)
- {
- $inherited=strcasecmp($method['class'],$className)!==0;
- $rowclass=$inherited?'doc-inherited':'doc-native';
- $s.="<tr class=\"$rowclass\">\n";
- $access='';
- if($method['static'])
- $access.='S';
- if($method['protected'])
- $access.='P';
- if($access==='')
- $access=' ';
- $s.="<td nowrap=\"nowrap\" width=\"1\" align=\"center\">$access</td>\n";
-
- if($inherited)
- {
- $parentClass=$method['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#method{$name}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
- else
- $s.="<td>$name</td>\n";
- }
- else
- {
- $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#method{$name}";
- $s.="<td><a href=\"$url\">$name</a></td>\n";
- }
-
- $comments=rtrim($method['comments'],'.').'.';
- if($inherited)
- {
- $parentClass=$method['class'];
- if(isset($this->_classes[$parentClass]))
- {
- $url="$parentClass.html";
- $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)";
- }
- else
- $comments.=" (inherited from {$parentClass})";
- }
- $s.="<td>$comments</td>\n";
- $s.="</tr>\n";
- }
- $header="<tr>\n<th> </th><th>Name</th><th>Description</th>\n</tr>\n";
- return $s===''?'':"<div class=\"doc-methods\">\n<table>\n$header$s</table>\n</div>\n";
- }
-
- public function getDerived()
- {
- $class=$this->Class;
- $s='';
- foreach($class['ChildClasses'] as $childName)
- $s.="<li><a href=\"$childName.html\">$childName</a></li>\n";
- return $s===''?'':"<div class=\"doc-derived\">\n<ul>\n$s</ul>\n</div>\n";
- }
-
-}
-
-?>
+<?php + +class ClassDoc extends TPage +{ + public $Class; + private $_classes; + + public function onLoad($param) + { + parent::onLoad($param); + $dataFile=Prado::getPathOfNamespace('Application.Data.classes','.data'); + $this->_classes=unserialize(file_get_contents($dataFile)); + + if(($className=$this->Request['class'])!==null && isset($this->_classes[$className])) + { + $this->Class=$this->_classes[$className]; + $this->Class['Name']=$className; + $this->Title='PRADO - Documentation of '.$className; + } + else + $this->Response->redirect('/docs/classdoc/'); + } + + public function getAncestors() + { + $ancestors=array(); + $thisClass=$this->Class; + while(true) + { + $parentClass=$thisClass['ParentClass']; + if(isset($this->_classes[$parentClass])) + { + $ancestors[]=$parentClass; + $thisClass=$this->_classes[$parentClass]; + } + else + break; + } + $ancestors=array_reverse($ancestors); + $s=''; + foreach($ancestors as $ancestor) + $s.="<a href=\"$ancestor.html\">$ancestor</a> »\n"; + if($s!=='') + $s="<div class=\"doc-ancestors\">\nInheritance: $s</div>\n"; + return $s; + } + + public function getProperties() + { + $class=$this->Class; + $className=$this->Class['Name']; + $s=''; + foreach($class['Properties'] as $name=>$property) + { + $inherited=strcasecmp($property['class'],$className)!==0; + $rowclass=$inherited?'doc-inherited':'doc-native'; + $s.="<tr class=\"$rowclass\">\n"; + $access=''; + if($property['readonly']) + $access.='R'; + if($property['protected']) + $access.='P'; + if($access==='') + $access=' '; + $s.="<td width=\"1\" nowrap=\"nowrap\" align=\"center\">$access</td>\n"; + + if($inherited) + { + $parentClass=$property['class']; + if(isset($this->_classes[$parentClass])) + { + $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#methodget{$name}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + else + $s.="<td>$name</td>\n"; + } + else + { + $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#methodget{$name}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + + $type=$property['type']; + if(isset($this->_classes[$type])) + { + $url="$type.html"; + $s.="<td><a href=\"$url\">$type</a></td>\n"; + } + else + $s.="<td>$type</td>\n"; + + $comments=rtrim($property['comments'],'.').'.'; + if($inherited) + { + $parentClass=$property['class']; + if(isset($this->_classes[$parentClass])) + { + $url="$parentClass.html"; + $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)"; + } + else + $comments.=" (inherited from {$parentClass})"; + } + $s.="<td>$comments</td>\n"; + $s.="</tr>\n"; + } + + $header="<tr>\n<th> </th><th>Name</th><th>Type</th><th>Description</th>\n</tr>\n"; + return $s===''?'':"<div class=\"doc-properties\">\n<table>\n$header$s</table>\n</div>\n"; + } + + public function getEvents() + { + $class=$this->Class; + $className=$this->Class['Name']; + $s=''; + foreach($class['Events'] as $name=>$event) + { + $inherited=strcasecmp($event['class'],$className)!==0; + $rowclass=$inherited?'doc-inherited':'doc-native'; + $s.="<tr class=\"$rowclass\">\n"; + + $methodName=$name; + $methodName[0]='o'; + if($inherited) + { + $parentClass=$event['class']; + if(isset($this->_classes[$parentClass])) + { + $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#method{$methodName}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + else + $s.="<td>$name</td>\n"; + } + else + { + $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#method{$methodName}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + + $comments=rtrim($event['comments'],'.').'.'; + if($inherited) + { + $parentClass=$event['class']; + if(isset($this->_classes[$parentClass])) + { + $url="$parentClass.html"; + $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)"; + } + else + $comments.=" (inherited from {$parentClass})"; + } + $s.="<td>$comments</td>\n"; + $s.="</tr>\n"; + } + $header="<tr>\n<th>Name</th><th>Description</th>\n</tr>\n"; + return $s===''?'':"<div class=\"doc-events\">\n<table>\n$header$s</table>\n</div>\n"; + } + + public function getMethods() + { + $class=$this->Class; + $className=$this->Class['Name']; + $s=''; + foreach($class['Methods'] as $name=>$method) + { + $inherited=strcasecmp($method['class'],$className)!==0; + $rowclass=$inherited?'doc-inherited':'doc-native'; + $s.="<tr class=\"$rowclass\">\n"; + $access=''; + if($method['static']) + $access.='S'; + if($method['protected']) + $access.='P'; + if($access==='') + $access=' '; + $s.="<td nowrap=\"nowrap\" width=\"1\" align=\"center\">$access</td>\n"; + + if($inherited) + { + $parentClass=$method['class']; + if(isset($this->_classes[$parentClass])) + { + $url="../manual/CHMdefaultConverter/{$this->_classes[$parentClass]['Package']}/{$parentClass}.html#method{$name}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + else + $s.="<td>$name</td>\n"; + } + else + { + $url="../manual/CHMdefaultConverter/{$class['Package']}/{$className}.html#method{$name}"; + $s.="<td><a href=\"$url\">$name</a></td>\n"; + } + + $comments=rtrim($method['comments'],'.').'.'; + if($inherited) + { + $parentClass=$method['class']; + if(isset($this->_classes[$parentClass])) + { + $url="$parentClass.html"; + $comments.=" (inherited from <a href=\"$url\">$parentClass</a>)"; + } + else + $comments.=" (inherited from {$parentClass})"; + } + $s.="<td>$comments</td>\n"; + $s.="</tr>\n"; + } + $header="<tr>\n<th> </th><th>Name</th><th>Description</th>\n</tr>\n"; + return $s===''?'':"<div class=\"doc-methods\">\n<table>\n$header$s</table>\n</div>\n"; + } + + public function getDerived() + { + $class=$this->Class; + $s=''; + foreach($class['ChildClasses'] as $childName) + $s.="<li><a href=\"$childName.html\">$childName</a></li>\n"; + return $s===''?'':"<div class=\"doc-derived\">\n<ul>\n$s</ul>\n</div>\n"; + } + +} + +?> diff --git a/buildscripts/chmbuilder/classes/pages/Classes.php b/buildscripts/chmbuilder/classes/pages/Classes.php index ee2672b4..aeaf0a0a 100644 --- a/buildscripts/chmbuilder/classes/pages/Classes.php +++ b/buildscripts/chmbuilder/classes/pages/Classes.php @@ -1,19 +1,19 @@ -<?php
-
-class Classes extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $dataFile=Prado::getPathOfNamespace('Application.Data.classes','.data');
- $classes=unserialize(file_get_contents($dataFile));
- $data=array();
- $baseUrl=$this->Request->ApplicationUrl;
- foreach(array_keys($classes) as $className)
- $data["$className.html"]=$className;
- $this->ClassList->DataSource=$data;
- $this->ClassList->dataBind();
- }
-}
-
-?>
+<?php + +class Classes extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $dataFile=Prado::getPathOfNamespace('Application.Data.classes','.data'); + $classes=unserialize(file_get_contents($dataFile)); + $data=array(); + $baseUrl=$this->Request->ApplicationUrl; + foreach(array_keys($classes) as $className) + $data["$className.html"]=$className; + $this->ClassList->DataSource=$data; + $this->ClassList->dataBind(); + } +} + +?> diff --git a/buildscripts/chmbuilder/classes/pages/MainLayout.php b/buildscripts/chmbuilder/classes/pages/MainLayout.php index e536e71d..163c1c9f 100644 --- a/buildscripts/chmbuilder/classes/pages/MainLayout.php +++ b/buildscripts/chmbuilder/classes/pages/MainLayout.php @@ -1,8 +1,8 @@ -<?php
-
-class MainLayout extends TTemplateControl
-{
-
-}
-
+<?php + +class MainLayout extends TTemplateControl +{ + +} + ?>
\ No newline at end of file diff --git a/buildscripts/chmbuilder/index.php b/buildscripts/chmbuilder/index.php index 4330e1a9..359a53e1 100644 --- a/buildscripts/chmbuilder/index.php +++ b/buildscripts/chmbuilder/index.php @@ -1,7 +1,7 @@ -<?php
-include('../../framework/prado.php');
- $app = new TApplication("classes");
- $app->run();
-
-
+<?php +include('../../framework/prado.php'); + $app = new TApplication("classes"); + $app->run(); + + ?>
\ No newline at end of file diff --git a/buildscripts/classtree/DWExtension.php b/buildscripts/classtree/DWExtension.php index f85f100d..8849efea 100644 --- a/buildscripts/classtree/DWExtension.php +++ b/buildscripts/classtree/DWExtension.php @@ -1,255 +1,255 @@ -<?php
-
-/**
- * PradoVTMDocument class
- *
- * @author Stanislav Yordanov <stanprog[at]stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoVTMDocument
-{
- private $_document;
- private $_attributes;
-
- public function __construct($controlName)
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument($controlName);
- }
-
- protected function prepareDocument($controlName)
- {
- $this->_document->formatOutput = true;
-
- //--- add <tag>
- $tag = $this->_document->createElement('tag');
- $tag->setAttribute('name',$controlName);
- $tag->setAttribute('casesensitive','yes');
- $this->_document->appendChild($tag);
-
- //--- add <tagformat>
- $tagFormat = $this->_document->createElement('tagformat');
- $tagFormat->setAttribute('nlbeforetag','1');
- $tagFormat->setAttribute('nlaftertag','1');
- $tagFormat->setAttribute('indentcontents','yes');
- $tag->appendChild($tagFormat);
-
- //--- add <tagdialog file="Control.htm" />
- //$tagDialog = $this->_document->createElement('tagdialog');
- //$tagDialog->setAttribute('file',$controlName.'.htm');
- //$tag->appendChild($tagDialog);
-
- $this->_attributes = $this->_document->createElement('attributes');
- $tag->appendChild($this->_attributes);
- }
-
- public function getDocument()
- {
- return $this->_document;
- }
-
- public function addAttribute($attribName, $attribType)
- {
- //--- add <attrib>
- $attrib = $this->_document->createElement('attrib');
- $attrib->setAttribute('name',$attribName);
- if (is_array($attribType))
- {
- $attrib->setAttribute('type','Enumerated');
- foreach ($attribType as $value)
- {
- $option = $this->_document->createElement('attriboption');
- $option->setAttribute('value',$value);
- $option->setAttribute('caption','');
- $attrib->appendChild($option);
- }
- }
- else if($attribType!=='')
- {
- $attrib->setAttribute('type',$attribType);
- }
- $attrib->setAttribute('casesensitive','yes');
- $this->_attributes->appendChild($attrib);
- }
-
- public function addEvent($eventName)
- {
- //--- add <attrib>
- $this->addAttribute($eventName,'');
- //--- add <event>
- $event = $this->_document->createElement('event');
- $event->setAttribute('name',$eventName);
- $this->_attributes->appendChild($event);
- }
-
- public function getXML()
- {
- return $this->_document->saveXML();
- }
-}
-
-/**
- * PradoMXIDocument class
- *
- * @author Stanislav Yordanov <stanprog@stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoMXIDocument
-{
- private $_tagLibraryElement;
- private $_filesElement;
- private $_document;
-
- public function __construct($version)
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument($version);
- }
-
- protected function prepareDocument($version)
- {
- $this->_document->formatOutput = true;
- //--- add root element
- $rootElement = $this->_document->createElement('macromedia-extension');
- $rootElement->setAttribute('name','PRADO Taglib');
- $rootElement->setAttribute('version',$version);
- $rootElement->setAttribute('type','Suite');
- $rootElement->setAttribute('requires-restart','true');
- $this->_document->appendChild($rootElement);
- //--- add <author>
- $element = $this->_document->createElement('author');
- $element->setAttribute('name','Stanislav Yordanov, Qiang Xue');
- $rootElement->appendChild($element);
- $time = date('F j, Y, h:i:s a',time());
- //--- add <description>
- $description = <<<EOD
-PRADO $version Tag Library
-Authors: Stanislav Yordanov <stanprog@stanprog.com> and Qiang Xue <qiang.xue@gmail.com>
-Time: $time
-Requirement: Macromedia Dreamweaver MX/MX 2004/8.0 or above
-Description: This suite adds PRADO tag library. The tag library contains PRADO component
-tags, properties and events that are commonly used on PRADO templates.
-EOD;
- $element = $this->_document->createElement('description');
- $element->appendChild($this->_document->createCDATASection($description));
- $rootElement->appendChild($element);
- //--- add <products>
- $productsElement = $this->_document->createElement('products');
- $rootElement->appendChild($productsElement);
- //--- add <product>
- $product = $this->_document->createElement('product');
- $product->setAttribute('name','Dreamweaver');
- $product->setAttribute('version','6');
- $product->setAttribute('primary','false');
- $productsElement->appendChild($product);
- //--- add <ui-access>
- $element = $this->_document->createElement('ui-access');
- $element->appendChild($this->_document->createCDATASection("PRADO"));
- $rootElement->appendChild($element);
- //--- add <files>
- $this->_filesElement = $this->_document->createElement('files');
- $rootElement->appendChild($this->_filesElement);
- //--- add <configuration-changes>
- $configChangeElement = $this->_document->createElement('configuration-changes');
- $rootElement->appendChild($configChangeElement);
- //--- add <taglibrary-changes>
- $tagLibChangeElement = $this->_document->createElement('taglibrary-changes');
- $configChangeElement->appendChild($tagLibChangeElement);
- //--- add <taglibrary-insert>
- $tagLibInsertElement = $this->_document->createElement('taglibrary-insert');
- $tagLibChangeElement->appendChild($tagLibInsertElement);
- //--- add <taglibrary>
- $this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary');
- $element->setAttribute('doctypes','HTML,DWTemplate');
- $element->setAttribute('id','DWTagLibrary_PRADO_tags');
- $element->setAttribute('name','PRADO tags');
- $element->setAttribute('prefix','<com:');
- $element->setAttribute('tagchooser','PRADO/TagChooser.xml');
- $tagLibInsertElement->appendChild($element);
-
- $element = $this->_document->createElement('file');
- $element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml');
- $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
- $this->_filesElement->appendChild($element);
- }
-
- public function addTag($tagName)
- {
- $element = $this->_document->createElement('file');
- $element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
- $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
- $this->_filesElement->appendChild($element);
-
- $element = $this->_document->createElement('tagref');
- $element->setAttribute('file','PRADO/'.$tagName.'.vtm');
- $element->setAttribute('name',$tagName);
- $this->_tagLibraryElement->appendChild($element);
- }
-
- public function getDocument()
- {
- return $this->_document;
- }
-
- public function getXML()
- {
- return $this->_document->saveXML();
- }
-}
-
-/**
- * PradoTagChooser class
- *
- * @author Stanislav Yordanov <stanprog[at]stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoTagChooser
-{
- private $_document;
- private $_tclibrary;
- private $_category;
-
- public function __construct()
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument();
- }
-
- protected function prepareDocument()
- {
- $this->_document->standalone = true;
- $this->_document->formatOutput = true;
- $tclibrary = $this->_document->createElement('tclibrary');
- $tclibrary->setAttribute('name','PRADO tags');
- $tclibrary->setAttribute('desc','A collection of all PRADO tags.');
- $tclibrary->setAttribute('reference','PRADO');
- $this->_document->appendChild($tclibrary);
-
- $this->_category = $this->_document->createElement('category');
- $this->_category->setAttribute('name','General');
- $this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif');
- $tclibrary->appendChild($this->_category);
- }
-
- public function addElement($elementName)
- {
- $element = $this->_document->createElement('element');
- $element->setAttribute('name','com:'.$elementName);
- $element->setAttribute('value','<com:'.$elementName.'>');
- $element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName));
- $this->_category->appendChild($element);
- }
-
- public function getXML()
- {
- $this->_document->normalize();
- /*
- $resultXML = $this->_document->saveXML();
- $resultXML = str_replace('>','>',$resultXML);
- $resultXML = str_replace('<','<',$resultXML);
- return $resultXML;
- */
- return $this->_document->saveXML();
- }
-}
+<?php + +/** + * PradoVTMDocument class + * + * @author Stanislav Yordanov <stanprog[at]stanprog.com> + * @author Qiang Xue <qiang.xue@gmail.com> + */ +class PradoVTMDocument +{ + private $_document; + private $_attributes; + + public function __construct($controlName) + { + $this->_document = new DOMDocument('1.0', 'utf-8'); + $this->prepareDocument($controlName); + } + + protected function prepareDocument($controlName) + { + $this->_document->formatOutput = true; + + //--- add <tag> + $tag = $this->_document->createElement('tag'); + $tag->setAttribute('name',$controlName); + $tag->setAttribute('casesensitive','yes'); + $this->_document->appendChild($tag); + + //--- add <tagformat> + $tagFormat = $this->_document->createElement('tagformat'); + $tagFormat->setAttribute('nlbeforetag','1'); + $tagFormat->setAttribute('nlaftertag','1'); + $tagFormat->setAttribute('indentcontents','yes'); + $tag->appendChild($tagFormat); + + //--- add <tagdialog file="Control.htm" /> + //$tagDialog = $this->_document->createElement('tagdialog'); + //$tagDialog->setAttribute('file',$controlName.'.htm'); + //$tag->appendChild($tagDialog); + + $this->_attributes = $this->_document->createElement('attributes'); + $tag->appendChild($this->_attributes); + } + + public function getDocument() + { + return $this->_document; + } + + public function addAttribute($attribName, $attribType) + { + //--- add <attrib> + $attrib = $this->_document->createElement('attrib'); + $attrib->setAttribute('name',$attribName); + if (is_array($attribType)) + { + $attrib->setAttribute('type','Enumerated'); + foreach ($attribType as $value) + { + $option = $this->_document->createElement('attriboption'); + $option->setAttribute('value',$value); + $option->setAttribute('caption',''); + $attrib->appendChild($option); + } + } + else if($attribType!=='') + { + $attrib->setAttribute('type',$attribType); + } + $attrib->setAttribute('casesensitive','yes'); + $this->_attributes->appendChild($attrib); + } + + public function addEvent($eventName) + { + //--- add <attrib> + $this->addAttribute($eventName,''); + //--- add <event> + $event = $this->_document->createElement('event'); + $event->setAttribute('name',$eventName); + $this->_attributes->appendChild($event); + } + + public function getXML() + { + return $this->_document->saveXML(); + } +} + +/** + * PradoMXIDocument class + * + * @author Stanislav Yordanov <stanprog@stanprog.com> + * @author Qiang Xue <qiang.xue@gmail.com> + */ +class PradoMXIDocument +{ + private $_tagLibraryElement; + private $_filesElement; + private $_document; + + public function __construct($version) + { + $this->_document = new DOMDocument('1.0', 'utf-8'); + $this->prepareDocument($version); + } + + protected function prepareDocument($version) + { + $this->_document->formatOutput = true; + //--- add root element + $rootElement = $this->_document->createElement('macromedia-extension'); + $rootElement->setAttribute('name','PRADO Taglib'); + $rootElement->setAttribute('version',$version); + $rootElement->setAttribute('type','Suite'); + $rootElement->setAttribute('requires-restart','true'); + $this->_document->appendChild($rootElement); + //--- add <author> + $element = $this->_document->createElement('author'); + $element->setAttribute('name','Stanislav Yordanov, Qiang Xue'); + $rootElement->appendChild($element); + $time = date('F j, Y, h:i:s a',time()); + //--- add <description> + $description = <<<EOD +PRADO $version Tag Library +Authors: Stanislav Yordanov <stanprog@stanprog.com> and Qiang Xue <qiang.xue@gmail.com> +Time: $time +Requirement: Macromedia Dreamweaver MX/MX 2004/8.0 or above +Description: This suite adds PRADO tag library. The tag library contains PRADO component +tags, properties and events that are commonly used on PRADO templates. +EOD; + $element = $this->_document->createElement('description'); + $element->appendChild($this->_document->createCDATASection($description)); + $rootElement->appendChild($element); + //--- add <products> + $productsElement = $this->_document->createElement('products'); + $rootElement->appendChild($productsElement); + //--- add <product> + $product = $this->_document->createElement('product'); + $product->setAttribute('name','Dreamweaver'); + $product->setAttribute('version','6'); + $product->setAttribute('primary','false'); + $productsElement->appendChild($product); + //--- add <ui-access> + $element = $this->_document->createElement('ui-access'); + $element->appendChild($this->_document->createCDATASection("PRADO")); + $rootElement->appendChild($element); + //--- add <files> + $this->_filesElement = $this->_document->createElement('files'); + $rootElement->appendChild($this->_filesElement); + //--- add <configuration-changes> + $configChangeElement = $this->_document->createElement('configuration-changes'); + $rootElement->appendChild($configChangeElement); + //--- add <taglibrary-changes> + $tagLibChangeElement = $this->_document->createElement('taglibrary-changes'); + $configChangeElement->appendChild($tagLibChangeElement); + //--- add <taglibrary-insert> + $tagLibInsertElement = $this->_document->createElement('taglibrary-insert'); + $tagLibChangeElement->appendChild($tagLibInsertElement); + //--- add <taglibrary> + $this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary'); + $element->setAttribute('doctypes','HTML,DWTemplate'); + $element->setAttribute('id','DWTagLibrary_PRADO_tags'); + $element->setAttribute('name','PRADO tags'); + $element->setAttribute('prefix','<com:'); + $element->setAttribute('tagchooser','PRADO/TagChooser.xml'); + $tagLibInsertElement->appendChild($element); + + $element = $this->_document->createElement('file'); + $element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml'); + $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml'); + $this->_filesElement->appendChild($element); + } + + public function addTag($tagName) + { + $element = $this->_document->createElement('file'); + $element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm'); + $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm'); + $this->_filesElement->appendChild($element); + + $element = $this->_document->createElement('tagref'); + $element->setAttribute('file','PRADO/'.$tagName.'.vtm'); + $element->setAttribute('name',$tagName); + $this->_tagLibraryElement->appendChild($element); + } + + public function getDocument() + { + return $this->_document; + } + + public function getXML() + { + return $this->_document->saveXML(); + } +} + +/** + * PradoTagChooser class + * + * @author Stanislav Yordanov <stanprog[at]stanprog.com> + * @author Qiang Xue <qiang.xue@gmail.com> + */ +class PradoTagChooser +{ + private $_document; + private $_tclibrary; + private $_category; + + public function __construct() + { + $this->_document = new DOMDocument('1.0', 'utf-8'); + $this->prepareDocument(); + } + + protected function prepareDocument() + { + $this->_document->standalone = true; + $this->_document->formatOutput = true; + $tclibrary = $this->_document->createElement('tclibrary'); + $tclibrary->setAttribute('name','PRADO tags'); + $tclibrary->setAttribute('desc','A collection of all PRADO tags.'); + $tclibrary->setAttribute('reference','PRADO'); + $this->_document->appendChild($tclibrary); + + $this->_category = $this->_document->createElement('category'); + $this->_category->setAttribute('name','General'); + $this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif'); + $tclibrary->appendChild($this->_category); + } + + public function addElement($elementName) + { + $element = $this->_document->createElement('element'); + $element->setAttribute('name','com:'.$elementName); + $element->setAttribute('value','<com:'.$elementName.'>'); + $element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName)); + $this->_category->appendChild($element); + } + + public function getXML() + { + $this->_document->normalize(); + /* + $resultXML = $this->_document->saveXML(); + $resultXML = str_replace('>','>',$resultXML); + $resultXML = str_replace('<','<',$resultXML); + return $resultXML; + */ + return $this->_document->saveXML(); + } +} ?>
\ No newline at end of file diff --git a/buildscripts/classtree/build.php b/buildscripts/classtree/build.php index c3c3d2f0..fab1b12b 100644 --- a/buildscripts/classtree/build.php +++ b/buildscripts/classtree/build.php @@ -1,258 +1,258 @@ -<?php
-
-$basePath=dirname(__FILE__);
-$frameworkPath=realpath($basePath.'/../../framework');
-require_once($frameworkPath.'/prado.php');
-require_once($basePath.'/DWExtension.php');
-
-//the manager class sets up some dependency paths
-Prado::using('System.Data.SqlMap.TSqlMapManager');
-
-$exclusions=array(
- 'pradolite.php',
- 'prado-cli.php',
- 'JSMin.php',
- '.svn',
- '/I18N/core',
- '/3rdParty',
- '/Testing',
- '/Web/UI/WebControls/assets',
- );
-$a=new ClassTreeBuilder($frameworkPath,$exclusions);
-$a->buildTree();
-$a->saveToFile($basePath.'/classes.data');
-$a->saveAsDWExtension($basePath);
-
-class ClassTreeBuilder
-{
- const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
- private $_frameworkPath;
- private $_exclusions;
- private $_classes=array();
-
- public function __construct($frameworkPath,$exclusions)
- {
- $this->_frameworkPath=realpath($frameworkPath);
- $this->_exclusions=array();
- foreach($exclusions as $exclusion)
- {
- if($exclusion[0]==='/')
- $this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
- else
- $this->_exclusions[$exclusion]=true;
- }
- }
-
- public function buildTree()
- {
- $sourceFiles=$this->getSourceFiles($this->_frameworkPath);
- foreach($sourceFiles as $sourceFile)
- $this->parseFile($sourceFile);
- ksort($this->_classes);
- foreach(array_keys($this->_classes) as $className)
- {
- $parentClass=$this->_classes[$className]['ParentClass'];
- if(isset($this->_classes[$parentClass]))
- $this->_classes[$parentClass]['ChildClasses'][]=$className;
- }
- echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
- }
-
- public function saveToFile($fileName)
- {
- file_put_contents($fileName,serialize($this->_classes));
- }
-
- public function displayTree()
- {
- $this->displayTreeInternal(array_keys($this->_baseClasses),0);
- }
-
- public function displayTreeInternal($classNames,$level)
- {
- foreach($classNames as $className)
- {
- echo str_repeat(' ',$level*4);
- echo $className.':'.$this->_classes[$className]->Package."\n";
- $this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
- }
- }
-
- protected function parseFile($sourceFile)
- {
- include_once($sourceFile);
- $classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
- echo "Parsing $classFile...\n";
- $content=file_get_contents($sourceFile);
- if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
- $package=$matches[1];
- else
- $package='';
- $n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
- for($i=0;$i<$n;++$i)
- {
- $className=$matches[$i][2];
- if(isset($this->_classes[$className]))
- throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
- $c=new TComponentReflection($className);
- $properties=$c->getProperties();
- $this->parseMethodComments($properties);
- $events=$c->getEvents();
- $this->parseMethodComments($events);
- $methods=$c->getMethods();
- $this->parseMethodComments($methods);
- $this->_classes[$className]=array(
- 'ClassFile'=>$classFile,
- 'Package'=>$package,
- 'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
- 'ChildClasses'=>array(),
- 'Properties'=>$properties,
- 'Events'=>$events,
- 'Methods'=>$methods);
- }
- }
-
- protected function parseMethodComments(&$methods)
- {
- foreach(array_keys($methods) as $key)
- {
- $method=&$methods[$key];
- $comments=$method['comments'];
- $s='';
- foreach(explode("\n",$comments) as $line)
- {
- $line=trim($line);
- $line=trim($line,'/*');
- $s.=' '.$line;
- }
- $s=trim($s);
- $s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
- $pos1=strpos($s,'@');
- $pos2=strpos($s,'.');
- if($pos1===false)
- {
- if($pos2!==false)
- $method['comments']=substr($s,0,$pos2);
- else
- $method['comments']=$s;
- }
- else if($pos1>0)
- {
- if($pos2 && $pos2<$pos1) // use the first line as comment
- $method['comments']=substr($s,0,$pos2);
- else
- $method['comments']=substr($s,0,$pos1);
- }
- else
- {
- $matches=array();
- if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
- $method['comments']=$matches[1];
- else
- $method['comments']='';
- }
- }
- }
-
- protected function isValidPath($path)
- {
- if(is_dir($path))
- return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
- else
- return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
- }
-
- public function getSourceFiles($path)
- {
- $files=array();
- $folder=opendir($path);
- while($file=readdir($folder))
- {
- if($file==='.' || $file==='..')
- continue;
- $fullPath=realpath($path.'/'.$file);
- if($this->isValidPath($fullPath))
- {
- if(is_file($fullPath))
- $files[]=$fullPath;
- else
- $files=array_merge($files,$this->getSourceFiles($fullPath));
- }
- }
- closedir($folder);
- return $files;
- }
-
- public function saveAsDWExtension($basePath)
- {
- $tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
-
- // prepare the directory to save tag lib
- @mkdir($basePath.'/Configuration');
- @mkdir($basePath.'/Configuration/TagLibraries');
- @mkdir($basePath.'/Configuration/TagLibraries/PRADO');
-
- $docMXI = new PradoMXIDocument(Prado::getVersion());
- $tagChooser = new PradoTagChooser;
-
- $controlClass = new ReflectionClass('TControl');
-
- foreach($this->_classes as $className=>$classInfo)
- {
- $class = new ReflectionClass($className);
- if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
- {
- $docMXI->addTag($className);
- $tagChooser->addElement($className);
- $docVTM = new PradoVTMDocument($className);
- foreach($classInfo['Properties'] as $name=>$property)
- {
- $type=$property['type'];
- if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
- $this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
- if($property['readonly'] || $property['protected'])
- continue;
- if(($type=$this->checkType($className,$name,$property['type']))!=='')
- $docVTM->addAttribute($name,$type);
- }
- foreach($classInfo['Events'] as $name=>$event)
- {
- $docVTM->addEvent($name);
- }
- file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
- }
- }
-
- file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
- file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
-
- }
-
- private function processObjectType($objectType,$objectInfo,$prefix,$doc)
- {
- foreach($objectInfo['Properties'] as $name=>$property)
- {
- if($property['type']==='TFont')
- $this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
- if($property['readonly'] || $property['protected'])
- continue;
- if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
- $doc->addAttribute($prefix.'.'.$name,$type);
- }
- }
-
- private function checkType($className,$propertyName,$type)
- {
- if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
- return 'color';
- if($propertyName==='Style')
- return 'style';
- if($type==='boolean')
- return array('true','false');
- if($type==='string' || $type==='integer' || $type==='ITemplate')
- return 'text';
- return '';
- }
-}
-
-?>
+<?php + +$basePath=dirname(__FILE__); +$frameworkPath=realpath($basePath.'/../../framework'); +require_once($frameworkPath.'/prado.php'); +require_once($basePath.'/DWExtension.php'); + +//the manager class sets up some dependency paths +Prado::using('System.Data.SqlMap.TSqlMapManager'); + +$exclusions=array( + 'pradolite.php', + 'prado-cli.php', + 'JSMin.php', + '.svn', + '/I18N/core', + '/3rdParty', + '/Testing', + '/Web/UI/WebControls/assets', + ); +$a=new ClassTreeBuilder($frameworkPath,$exclusions); +$a->buildTree(); +$a->saveToFile($basePath.'/classes.data'); +$a->saveAsDWExtension($basePath); + +class ClassTreeBuilder +{ + const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS'; + private $_frameworkPath; + private $_exclusions; + private $_classes=array(); + + public function __construct($frameworkPath,$exclusions) + { + $this->_frameworkPath=realpath($frameworkPath); + $this->_exclusions=array(); + foreach($exclusions as $exclusion) + { + if($exclusion[0]==='/') + $this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true; + else + $this->_exclusions[$exclusion]=true; + } + } + + public function buildTree() + { + $sourceFiles=$this->getSourceFiles($this->_frameworkPath); + foreach($sourceFiles as $sourceFile) + $this->parseFile($sourceFile); + ksort($this->_classes); + foreach(array_keys($this->_classes) as $className) + { + $parentClass=$this->_classes[$className]['ParentClass']; + if(isset($this->_classes[$parentClass])) + $this->_classes[$parentClass]['ChildClasses'][]=$className; + } + echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n"; + } + + public function saveToFile($fileName) + { + file_put_contents($fileName,serialize($this->_classes)); + } + + public function displayTree() + { + $this->displayTreeInternal(array_keys($this->_baseClasses),0); + } + + public function displayTreeInternal($classNames,$level) + { + foreach($classNames as $className) + { + echo str_repeat(' ',$level*4); + echo $className.':'.$this->_classes[$className]->Package."\n"; + $this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1); + } + } + + protected function parseFile($sourceFile) + { + include_once($sourceFile); + $classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/'); + echo "Parsing $classFile...\n"; + $content=file_get_contents($sourceFile); + if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0) + $package=$matches[1]; + else + $package=''; + $n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER); + for($i=0;$i<$n;++$i) + { + $className=$matches[$i][2]; + if(isset($this->_classes[$className])) + throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile); + $c=new TComponentReflection($className); + $properties=$c->getProperties(); + $this->parseMethodComments($properties); + $events=$c->getEvents(); + $this->parseMethodComments($events); + $methods=$c->getMethods(); + $this->parseMethodComments($methods); + $this->_classes[$className]=array( + 'ClassFile'=>$classFile, + 'Package'=>$package, + 'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'', + 'ChildClasses'=>array(), + 'Properties'=>$properties, + 'Events'=>$events, + 'Methods'=>$methods); + } + } + + protected function parseMethodComments(&$methods) + { + foreach(array_keys($methods) as $key) + { + $method=&$methods[$key]; + $comments=$method['comments']; + $s=''; + foreach(explode("\n",$comments) as $line) + { + $line=trim($line); + $line=trim($line,'/*'); + $s.=' '.$line; + } + $s=trim($s); + $s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s); + $pos1=strpos($s,'@'); + $pos2=strpos($s,'.'); + if($pos1===false) + { + if($pos2!==false) + $method['comments']=substr($s,0,$pos2); + else + $method['comments']=$s; + } + else if($pos1>0) + { + if($pos2 && $pos2<$pos1) // use the first line as comment + $method['comments']=substr($s,0,$pos2); + else + $method['comments']=substr($s,0,$pos1); + } + else + { + $matches=array(); + if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0) + $method['comments']=$matches[1]; + else + $method['comments']=''; + } + } + } + + protected function isValidPath($path) + { + if(is_dir($path)) + return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]); + else + return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]); + } + + public function getSourceFiles($path) + { + $files=array(); + $folder=opendir($path); + while($file=readdir($folder)) + { + if($file==='.' || $file==='..') + continue; + $fullPath=realpath($path.'/'.$file); + if($this->isValidPath($fullPath)) + { + if(is_file($fullPath)) + $files[]=$fullPath; + else + $files=array_merge($files,$this->getSourceFiles($fullPath)); + } + } + closedir($folder); + return $files; + } + + public function saveAsDWExtension($basePath) + { + $tagPath=$basePath.'/Configuration/TagLibraries/PRADO'; + + // prepare the directory to save tag lib + @mkdir($basePath.'/Configuration'); + @mkdir($basePath.'/Configuration/TagLibraries'); + @mkdir($basePath.'/Configuration/TagLibraries/PRADO'); + + $docMXI = new PradoMXIDocument(Prado::getVersion()); + $tagChooser = new PradoTagChooser; + + $controlClass = new ReflectionClass('TControl'); + + foreach($this->_classes as $className=>$classInfo) + { + $class = new ReflectionClass($className); + if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass))) + { + $docMXI->addTag($className); + $tagChooser->addElement($className); + $docVTM = new PradoVTMDocument($className); + foreach($classInfo['Properties'] as $name=>$property) + { + $type=$property['type']; + if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle')) + $this->processObjectType($type,$this->_classes[$type],$name,$docVTM); + if($property['readonly'] || $property['protected']) + continue; + if(($type=$this->checkType($className,$name,$property['type']))!=='') + $docVTM->addAttribute($name,$type); + } + foreach($classInfo['Events'] as $name=>$event) + { + $docVTM->addEvent($name); + } + file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML()); + } + } + + file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML()); + file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML()); + + } + + private function processObjectType($objectType,$objectInfo,$prefix,$doc) + { + foreach($objectInfo['Properties'] as $name=>$property) + { + if($property['type']==='TFont') + $this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc); + if($property['readonly'] || $property['protected']) + continue; + if(($type=$this->checkType($objectType,$name,$property['type']))!=='') + $doc->addAttribute($prefix.'.'.$name,$type); + } + } + + private function checkType($className,$propertyName,$type) + { + if(strrpos($propertyName,'Color')===strlen($propertyName)-5) + return 'color'; + if($propertyName==='Style') + return 'style'; + if($type==='boolean') + return array('true','false'); + if($type==='string' || $type==='integer' || $type==='ITemplate') + return 'text'; + return ''; + } +} + +?> diff --git a/buildscripts/index/api_index.php b/buildscripts/index/api_index.php index c85fa267..339cb042 100644 --- a/buildscripts/index/api_index.php +++ b/buildscripts/index/api_index.php @@ -1,121 +1,121 @@ -<?php
-/*
- * Created on 10/05/2006
- */
-
-class api_index
-{
- const API_URL = '';
-
- private $_index;
- private $_api;
-
- public function __construct($index_file, $api)
- {
- $this->_api = $api;
- $this->_index = new Zend_Search_Lucene($index_file, true);
-
-
- }
-
- function create_index()
- {
- echo "Building search index...\n";
- $files = $this->get_file_list($this->_api);
- $count = 0;
- foreach($files as $file)
- {
- echo " processing $file...\n";
- $content = $this->get_details($file, $this->_api);
-
- $doc = new Zend_Search_Lucene_Document();
-
- $title = $content['namespace'].'.'.$content['class'];
-
- echo " Adding ".$title."\n";
-
- //unsearchable text
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $title));
- //$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
-
- //searchable
- $body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);
- $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
- $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
- $this->_index->addDocument($doc);
- $count++;
- }
- $this->_index->commit();
- echo "\n {$count} files indexed.\n";
- }
-
- function sanitize($input)
- {
- return htmlentities(strip_tags( $input ));
- }
-
-
- function get_file_list($path)
- {
-
- $d = dir($path);
-
- $files = array();
- while (false !== ($entry = $d->read()))
- {
- $filepath = $path.'/'.$entry;
-
- if(is_dir($filepath) && is_int(strpos($entry, 'System')))
- {
- $files = array_merge($files, $this->get_files($filepath));
- }
- }
-
- $d->close();
- return $files;
- }
-
- function get_files($path)
- {
- $d = dir($path);
-
- $files = array();
- while (false !== ($entry = $d->read()))
- {
- $filepath = $path.'/'.$entry;
- if(is_file($filepath) && $entry[0] !== '_')
- $files[] = realpath($filepath);
- }
- $d->close();
- return $files;
- }
-
- function get_doc_content($file)
- {
- $content = file_get_contents($file);
- $html = preg_replace('/<h1>/','~~~', $content);
- $html = preg_replace('/<![^~]+/m', '', $html);
- $html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
- $html = preg_replace('/ |~+|\s{2,}/',' ',$html);
- $html = preg_replace('/\s{2,}/',' ',$html);
- $text = strip_tags($html);
- $text = str_replace(' , ',', ',$text);
- return $text;
- }
-
- function get_details($file, $base)
- {
- $result['content'] = $this->get_doc_content($file);
- $find = array($base, '.html', '-');
- $replace = array('', '', '.');
- $path = preg_split('/\/|\\\/', str_replace($find, $replace, $file));
- $result['namespace'] = $path[1];
- $result['class'] = $path[2];
- $result['link'] = self::API_URL.$path[1].'/'.$path[2].'.html';
- return $result;
- }
-}
-
-
+<?php +/* + * Created on 10/05/2006 + */ + +class api_index +{ + const API_URL = ''; + + private $_index; + private $_api; + + public function __construct($index_file, $api) + { + $this->_api = $api; + $this->_index = new Zend_Search_Lucene($index_file, true); + + + } + + function create_index() + { + echo "Building search index...\n"; + $files = $this->get_file_list($this->_api); + $count = 0; + foreach($files as $file) + { + echo " processing $file...\n"; + $content = $this->get_details($file, $this->_api); + + $doc = new Zend_Search_Lucene_Document(); + + $title = $content['namespace'].'.'.$content['class']; + + echo " Adding ".$title."\n"; + + //unsearchable text + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link'])); + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $title)); + //$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content'])); + + //searchable + $body = strtolower($this->sanitize($content['content'])).' '.strtolower($title); + $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title)))); + $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body)); + $this->_index->addDocument($doc); + $count++; + } + $this->_index->commit(); + echo "\n {$count} files indexed.\n"; + } + + function sanitize($input) + { + return htmlentities(strip_tags( $input )); + } + + + function get_file_list($path) + { + + $d = dir($path); + + $files = array(); + while (false !== ($entry = $d->read())) + { + $filepath = $path.'/'.$entry; + + if(is_dir($filepath) && is_int(strpos($entry, 'System'))) + { + $files = array_merge($files, $this->get_files($filepath)); + } + } + + $d->close(); + return $files; + } + + function get_files($path) + { + $d = dir($path); + + $files = array(); + while (false !== ($entry = $d->read())) + { + $filepath = $path.'/'.$entry; + if(is_file($filepath) && $entry[0] !== '_') + $files[] = realpath($filepath); + } + $d->close(); + return $files; + } + + function get_doc_content($file) + { + $content = file_get_contents($file); + $html = preg_replace('/<h1>/','~~~', $content); + $html = preg_replace('/<![^~]+/m', '', $html); + $html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html); + $html = preg_replace('/ |~+|\s{2,}/',' ',$html); + $html = preg_replace('/\s{2,}/',' ',$html); + $text = strip_tags($html); + $text = str_replace(' , ',', ',$text); + return $text; + } + + function get_details($file, $base) + { + $result['content'] = $this->get_doc_content($file); + $find = array($base, '.html', '-'); + $replace = array('', '', '.'); + $path = preg_split('/\/|\\\/', str_replace($find, $replace, $file)); + $result['namespace'] = $path[1]; + $result['class'] = $path[2]; + $result['link'] = self::API_URL.$path[1].'/'.$path[2].'.html'; + return $result; + } +} + + ?>
\ No newline at end of file diff --git a/buildscripts/index/build.php b/buildscripts/index/build.php index c02f94ae..bbe151e6 100644 --- a/buildscripts/index/build.php +++ b/buildscripts/index/build.php @@ -1,65 +1,65 @@ -<?php
-/*
- * Created on 10/05/2006
- */
-
-/**
- * Building search index for quickstart tutorials and the API documentation.
- */
-
-
-//quickstart source and the index data target directories.
-$quickstart_source = realpath(dirname(__FILE__).'/../texbuilder/quickstart/pages.php');
-$quickstart_base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/');
-$quickstart_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/quickstart/');
-
-//API source and the index data target directories.
-$api_source = realpath(dirname(__FILE__).'/../../build/docs/manual/');
-$api_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/api/');
-
-//get the ZEND framework
-$zend_path = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index');
-set_include_path(get_include_path().';'.$zend_path);
-require_once ('Zend/Search/Lucene.php');
-
-//get the indexers.
-include('quickstart_index.php');
-include('api_index.php');
-
-if(isset($argv[1]))
-{
- if(strtolower($argv[1]) == "quickstart")
- {
- $quickstart = new quickstart_index($quickstart_target, $quickstart_base, $quickstart_source);
- $quickstart->create_index();
- }
- else if(strtolower($argv[1]) == "api")
- {
- $api = new api_index($api_target, $api_source);
- $api->create_index();
- }
- else
- {
- $q = new Zend_Search_Lucene($quickstart_target);
- $query = $argv[1];
- $hits = $q->find(strtolower($query));
- echo "Found ".count($hits)." for ".$query." in quick start\n";
- foreach($hits as $hit)
- echo " ".$hit->title."\n";
-
- $a = new Zend_Search_Lucene($api_target);
- $query = $argv[1];
- $hits = $a->find(strtolower($query));
- echo "\nFound ".count($hits)." for ".$query." in API\n";
- foreach($hits as $hit)
- {
- echo " ".$hit->link."\n";
- }
- }
-}
-else
-{
- echo "Usage: 'php build.php quickstart' or 'php build.php api'\n";
-}
-
-?>
+<?php +/* + * Created on 10/05/2006 + */ + +/** + * Building search index for quickstart tutorials and the API documentation. + */ + + +//quickstart source and the index data target directories. +$quickstart_source = realpath(dirname(__FILE__).'/../texbuilder/quickstart/pages.php'); +$quickstart_base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/'); +$quickstart_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/quickstart/'); + +//API source and the index data target directories. +$api_source = realpath(dirname(__FILE__).'/../../build/docs/manual/'); +$api_target = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index/api/'); + +//get the ZEND framework +$zend_path = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index'); +set_include_path(get_include_path().';'.$zend_path); +require_once ('Zend/Search/Lucene.php'); + +//get the indexers. +include('quickstart_index.php'); +include('api_index.php'); + +if(isset($argv[1])) +{ + if(strtolower($argv[1]) == "quickstart") + { + $quickstart = new quickstart_index($quickstart_target, $quickstart_base, $quickstart_source); + $quickstart->create_index(); + } + else if(strtolower($argv[1]) == "api") + { + $api = new api_index($api_target, $api_source); + $api->create_index(); + } + else + { + $q = new Zend_Search_Lucene($quickstart_target); + $query = $argv[1]; + $hits = $q->find(strtolower($query)); + echo "Found ".count($hits)." for ".$query." in quick start\n"; + foreach($hits as $hit) + echo " ".$hit->title."\n"; + + $a = new Zend_Search_Lucene($api_target); + $query = $argv[1]; + $hits = $a->find(strtolower($query)); + echo "\nFound ".count($hits)." for ".$query." in API\n"; + foreach($hits as $hit) + { + echo " ".$hit->link."\n"; + } + } +} +else +{ + echo "Usage: 'php build.php quickstart' or 'php build.php api'\n"; +} + +?> diff --git a/buildscripts/index/quickstart_index.php b/buildscripts/index/quickstart_index.php index fb4bc829..61e21514 100644 --- a/buildscripts/index/quickstart_index.php +++ b/buildscripts/index/quickstart_index.php @@ -1,107 +1,107 @@ -<?php
-
-class quickstart_index
-{
- private $_index;
- private $_dir;
-
- private $_base;
- private $_source;
-
- public function __construct($index_file, $base, $source)
- {
- $this->_index = new Zend_Search_Lucene($index_file, true);
- $this->_dir = $index_file;
- $this->_base = $base;
- $this->_source = $source;
- }
-
- public function create_index()
- {
- echo "Building search index...\n";
- $pages = include($this->_source);
- $count = 0;
- foreach($pages as $chapter => $sections)
- {
- foreach($sections as $section)
- {
- echo " Adding $section\n";
- $page = $this->_base.'/'.$section;
- $file_content = file_get_contents($page);
- $this->add($file_content,$section, filemtime($page));
- $count++;
- }
- }
-
- $this->_index->commit();
- echo "\n {$count} files indexed.\n";
- }
-
- public function add($content, $section, $mtime)
- {
- foreach($this->split_headings($content) as $headers)
- {
- $doc = new Zend_Search_Lucene_Document();
- $link = "index.php?page=".preg_replace('/\/|\\\/', '.', $section);
- $link = str_replace('.page', '', $link).'#'.$headers['section'];
-
- //unsearchable text
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link));
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('mtime', $mtime));
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $headers['title']));
- $doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $headers['content']));
-
- //searchable text
- $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower($headers['title'])));
- $body = strtolower($this->sanitize($headers['content'])).' '.strtolower($headers['title']);
- $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
- $this->_index->addDocument($doc);
- }
- }
-
- function sanitize($input)
- {
- return htmlentities(strip_tags( $input ));
- }
-
- public function index()
- {
- return $this->_index;
- }
-
- protected function split_headings($html)
- {
- $html = preg_replace('/<\/?com:TContent[^<]*>/', '', $html);
-
- $html = preg_replace('/<b>([^<]*)<\/b>/', '$1', $html);
- $html = preg_replace('/<i>([^<]*)<\/i>/', '$1', $html);
- $html = preg_replace('/<tt>([^<]*)<\/tt>/', '$1', $html);
-
- $html = preg_replace('/<h1([^>]*)>([^<]*)<\/h1>/', '<hh$1>$2</hh>', $html);
- $html = preg_replace('/<h2([^>]*)>([^<]*)<\/h2>/', '<hh$1>$2</hh>', $html);
- $html = preg_replace('/<h3([^>]*)>([^<]*)<\/h3>/', '<hh$1>$2</hh>', $html);
-
-
- $sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html,-1);
- $headers = array();
- preg_match_all('/<hh([^>]*)>([^<]+)<\/hh>/', $html, $headers);
- $contents = array();
- for($i = 1, $t = count($sections); $i < $t; $i++)
- {
- $content['title'] = trim($this->sanitize($headers[2][$i-1]));
- $content['section'] = str_replace('"', '',trim($headers[1][$i-1],'"'));
- $content['content'] = trim($this->sanitize($sections[$i]));
- $contents[] = $content;
- }
-
- return $contents;
- }
-
- public function commit()
- {
- $this->_index->commit();
- $count = $this->_index->count();
- echo "\nSaving search index ({$count}) to {$this->_dir}\n\n";
- }
-}
+<?php + +class quickstart_index +{ + private $_index; + private $_dir; + + private $_base; + private $_source; + + public function __construct($index_file, $base, $source) + { + $this->_index = new Zend_Search_Lucene($index_file, true); + $this->_dir = $index_file; + $this->_base = $base; + $this->_source = $source; + } + + public function create_index() + { + echo "Building search index...\n"; + $pages = include($this->_source); + $count = 0; + foreach($pages as $chapter => $sections) + { + foreach($sections as $section) + { + echo " Adding $section\n"; + $page = $this->_base.'/'.$section; + $file_content = file_get_contents($page); + $this->add($file_content,$section, filemtime($page)); + $count++; + } + } + + $this->_index->commit(); + echo "\n {$count} files indexed.\n"; + } + + public function add($content, $section, $mtime) + { + foreach($this->split_headings($content) as $headers) + { + $doc = new Zend_Search_Lucene_Document(); + $link = "index.php?page=".preg_replace('/\/|\\\/', '.', $section); + $link = str_replace('.page', '', $link).'#'.$headers['section']; + + //unsearchable text + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link)); + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('mtime', $mtime)); + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('title', $headers['title'])); + $doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $headers['content'])); + + //searchable text + $doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower($headers['title']))); + $body = strtolower($this->sanitize($headers['content'])).' '.strtolower($headers['title']); + $doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body)); + $this->_index->addDocument($doc); + } + } + + function sanitize($input) + { + return htmlentities(strip_tags( $input )); + } + + public function index() + { + return $this->_index; + } + + protected function split_headings($html) + { + $html = preg_replace('/<\/?com:TContent[^<]*>/', '', $html); + + $html = preg_replace('/<b>([^<]*)<\/b>/', '$1', $html); + $html = preg_replace('/<i>([^<]*)<\/i>/', '$1', $html); + $html = preg_replace('/<tt>([^<]*)<\/tt>/', '$1', $html); + + $html = preg_replace('/<h1([^>]*)>([^<]*)<\/h1>/', '<hh$1>$2</hh>', $html); + $html = preg_replace('/<h2([^>]*)>([^<]*)<\/h2>/', '<hh$1>$2</hh>', $html); + $html = preg_replace('/<h3([^>]*)>([^<]*)<\/h3>/', '<hh$1>$2</hh>', $html); + + + $sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html,-1); + $headers = array(); + preg_match_all('/<hh([^>]*)>([^<]+)<\/hh>/', $html, $headers); + $contents = array(); + for($i = 1, $t = count($sections); $i < $t; $i++) + { + $content['title'] = trim($this->sanitize($headers[2][$i-1])); + $content['section'] = str_replace('"', '',trim($headers[1][$i-1],'"')); + $content['content'] = trim($this->sanitize($sections[$i])); + $contents[] = $content; + } + + return $contents; + } + + public function commit() + { + $this->_index->commit(); + $count = $this->_index->count(); + echo "\nSaving search index ({$count}) to {$this->_dir}\n\n"; + } +} ?>
\ No newline at end of file diff --git a/buildscripts/index/search.php b/buildscripts/index/search.php index a34363f4..23948ca5 100644 --- a/buildscripts/index/search.php +++ b/buildscripts/index/search.php @@ -1,36 +1,36 @@ -<?php
-
-if(isset($_GET['keyword']))
- $keyword=trim($_GET['keyword']);
-else
- $keyword='';
-
-$zend_path=realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index');
-set_include_path(get_include_path().PATH_SEPARATOR.$zend_path);
-require_once('Zend/Search/Lucene.php');
-
-if($keyword!=='')
-{
- $search=new Zend_Search_Lucene(realpath(dirname(__FILE__)));
- $results=$search->find(strtolower($keyword));
- $content='';
- foreach($results as $entry)
- $content.="<li><a href=\"{$entry->link}\">{$entry->title}</a></li>\n";
- if($content!=='')
- {
- $count=count($results);
- $content="<p>Total <b>$count</b> pages matching keyword <b>".htmlentities($keyword)."</b>.\n<ol>\n$content</ol>\n";
- }
- else
- $content="<p>No page matches <b>".htmlentities($keyword)."</b>.</p>";
-}
-else
- $content="<p>Please specify a keyword to search for.</p>";
-
-$page=file_get_contents(dirname(__FILE__).'/index.html');
-$page=preg_replace('/<!-- content begin -->.*<!-- content end -->/ms',$content,$page);
-if($keyword!=='')
- $page=preg_replace('/<input type="text" name="keyword"/','<input type="text" name="keyword" value="'.htmlentities($keyword).'"',$page);
-echo $page;
-
+<?php + +if(isset($_GET['keyword'])) + $keyword=trim($_GET['keyword']); +else + $keyword=''; + +$zend_path=realpath(dirname(__FILE__).'/../../demos/quickstart/protected/index'); +set_include_path(get_include_path().PATH_SEPARATOR.$zend_path); +require_once('Zend/Search/Lucene.php'); + +if($keyword!=='') +{ + $search=new Zend_Search_Lucene(realpath(dirname(__FILE__))); + $results=$search->find(strtolower($keyword)); + $content=''; + foreach($results as $entry) + $content.="<li><a href=\"{$entry->link}\">{$entry->title}</a></li>\n"; + if($content!=='') + { + $count=count($results); + $content="<p>Total <b>$count</b> pages matching keyword <b>".htmlentities($keyword)."</b>.\n<ol>\n$content</ol>\n"; + } + else + $content="<p>No page matches <b>".htmlentities($keyword)."</b>.</p>"; +} +else + $content="<p>Please specify a keyword to search for.</p>"; + +$page=file_get_contents(dirname(__FILE__).'/index.html'); +$page=preg_replace('/<!-- content begin -->.*<!-- content end -->/ms',$content,$page); +if($keyword!=='') + $page=preg_replace('/<input type="text" name="keyword"/','<input type="text" name="keyword" value="'.htmlentities($keyword).'"',$page); +echo $page; + ?>
\ No newline at end of file diff --git a/buildscripts/jGrouseDoc/skins/common/js/jgdoc.js b/buildscripts/jGrouseDoc/skins/common/js/jgdoc.js index 0687c039..7b1281bf 100644 --- a/buildscripts/jGrouseDoc/skins/common/js/jgdoc.js +++ b/buildscripts/jGrouseDoc/skins/common/js/jgdoc.js @@ -1,239 +1,239 @@ -/**
- * Searcher for JGrouseDoc
- * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $
- */
-
-jgdoc = {}
-
-jgdoc.Searcher =
-{
- initialize : function()
- {
- this._searchBox = document.getElementById("jgsSearchString");
- this._searchResults = document.getElementById("jgsSearchResults");
- this._info = document.getElementById("jgsInfo");
- this._currentValue = "";
- this._currentItems = [];
- this._currentItem = -1;
- this._data = null;
- return this;
- },
-
- _getEvent : function(event)
- {
- return window.event? window.event : event;
- },
-
- _getTarget : function(event)
- {
- return event.target || event.srcElement
- },
-
- addClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- return;
- }
- }
- a.push(className);
- element.className = a.join(' ');
- },
-
- removeClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- break;
- }
- }
- element.className = a.join(' ');
-
- },
-
- dispatcher : function(event)
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- event = this._getEvent(event);
- var type = event.type;
- var handler = "on" + type;
- this[handler](event, this._getTarget(event));
- },
-
- onclick : function(event, target)
- {
- window.location.href = target._data.ref;
- },
-
- onmouseover : function(event, target)
- {
- this.selectItem(target.index);
- },
-
- onmouseout : function(event, target)
- {
- this.unselectItem(target.index);
- },
-
- selectItem : function(index)
- {
- if (index != this._currentItem)
- {
- this._currentItem = index;
- var item = this._currentItems[index];
- this.addClass(item, 'jgdSelectedItem');
- var text = item._data.summary.split('\n').join('<br/>');
- this._info.innerHTML = text;
- }
- },
-
- unselectItem : function(index)
- {
- this._currentItem = -1;
- var item = this._currentItems[index];
- this.removeClass(item, 'jgdSelectedItem');
- this._info.innerHTML = '';
- },
-
-
- onTimer : function()
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- var val = this._searchBox.value;
- if (val != this._currentValue)
- {
- this._currentValue = val;
- this.redraw();
- }
- },
-
- setData : function(data)
- {
- this._data = data;
- this.redraw();
- this._searchBox.focus();
- },
-
- addListener : function(element, eventName, handler)
- {
- if (element.addEventListener)
- {
- element.addEventListener(eventName, handler, false);
- }
- else
- {
- element.attachEvent('on' + eventName, handler);
- }
- },
-
- removeListener : function(element, eventName, handler)
- {
- if (element.removeEventListener)
- {
- element.removeEventListener(eventName, handler, false);
- }
- else
- {
- element.detachEvent('on' + eventName, handler);
- }
- },
-
- findMatches : function()
- {
- var result = [];
- if (this._currentValue)
- {
- var v = this._currentValue.toUpperCase();
- for (var i = 0; i < this._data.length; i++)
- {
- var item = this._data[i];
- if (item.localName.toUpperCase().indexOf(v) == 0)
- {
- result.push(item);
- }
- }
- }
- return result;
- },
-
-
- clearItem : function(item)
- {
- item._data = null;
- this.removeListener(item, 'click', this.dispatcher);
- this.removeListener(item, 'mouseover', this.dispatcher);
- this.removeListener(item, 'mouseout', this.dispatcher);
- },
-
- clear : function()
- {
- for (var i = 0; i < this._currentItems.length; i++)
- {
- this.clearItem(this._currentItems[i]);
- }
- this._currentItems = [];
- this._searchResults.innerHTML = "";
- this._currentItem = -1;
- },
-
-
- createItem : function(item, index)
- {
- var d = document.createElement("div");
- d.className = "searchItem";
- //d.title = item.summary;
- d.innerHTML = item.fullName;
- d.index = index;
- d._data = item;
- this.addListener(d, 'click', this.dispatcher);
- this.addListener(d, 'mouseover', this.dispatcher);
- this.addListener(d, 'mouseout', this.dispatcher);
- //todo - set listeners
- return d;
- },
-
- redraw : function()
- {
- this.clear();
- var res = this.findMatches();
- if (res.length > 0)
- {
- for (var i = 0; i < res.length; i++)
- {
- var d = this.createItem(res[i], i);
- this._currentItems.push(d);
- this._searchResults.appendChild(d);
- }
- }
- else
- {
- var s = (this._currentValue)? "Not found" : "Start typing the name of the item";
- this._searchResults.innerHTML = s;
- }
- },
-
- start : function()
- {
- var instance = jgdoc.Searcher.initialize();
- instance.setData([]);
- instance._timer = window.setInterval(instance.onTimer, 100);
- }
-}
-
+/** + * Searcher for JGrouseDoc + * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $ + */ + +jgdoc = {} + +jgdoc.Searcher = +{ + initialize : function() + { + this._searchBox = document.getElementById("jgsSearchString"); + this._searchResults = document.getElementById("jgsSearchResults"); + this._info = document.getElementById("jgsInfo"); + this._currentValue = ""; + this._currentItems = []; + this._currentItem = -1; + this._data = null; + return this; + }, + + _getEvent : function(event) + { + return window.event? window.event : event; + }, + + _getTarget : function(event) + { + return event.target || event.srcElement + }, + + addClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + return; + } + } + a.push(className); + element.className = a.join(' '); + }, + + removeClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + a.splice(i, 1); + break; + } + } + element.className = a.join(' '); + + }, + + dispatcher : function(event) + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + event = this._getEvent(event); + var type = event.type; + var handler = "on" + type; + this[handler](event, this._getTarget(event)); + }, + + onclick : function(event, target) + { + window.location.href = target._data.ref; + }, + + onmouseover : function(event, target) + { + this.selectItem(target.index); + }, + + onmouseout : function(event, target) + { + this.unselectItem(target.index); + }, + + selectItem : function(index) + { + if (index != this._currentItem) + { + this._currentItem = index; + var item = this._currentItems[index]; + this.addClass(item, 'jgdSelectedItem'); + var text = item._data.summary.split('\n').join('<br/>'); + this._info.innerHTML = text; + } + }, + + unselectItem : function(index) + { + this._currentItem = -1; + var item = this._currentItems[index]; + this.removeClass(item, 'jgdSelectedItem'); + this._info.innerHTML = ''; + }, + + + onTimer : function() + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + var val = this._searchBox.value; + if (val != this._currentValue) + { + this._currentValue = val; + this.redraw(); + } + }, + + setData : function(data) + { + this._data = data; + this.redraw(); + this._searchBox.focus(); + }, + + addListener : function(element, eventName, handler) + { + if (element.addEventListener) + { + element.addEventListener(eventName, handler, false); + } + else + { + element.attachEvent('on' + eventName, handler); + } + }, + + removeListener : function(element, eventName, handler) + { + if (element.removeEventListener) + { + element.removeEventListener(eventName, handler, false); + } + else + { + element.detachEvent('on' + eventName, handler); + } + }, + + findMatches : function() + { + var result = []; + if (this._currentValue) + { + var v = this._currentValue.toUpperCase(); + for (var i = 0; i < this._data.length; i++) + { + var item = this._data[i]; + if (item.localName.toUpperCase().indexOf(v) == 0) + { + result.push(item); + } + } + } + return result; + }, + + + clearItem : function(item) + { + item._data = null; + this.removeListener(item, 'click', this.dispatcher); + this.removeListener(item, 'mouseover', this.dispatcher); + this.removeListener(item, 'mouseout', this.dispatcher); + }, + + clear : function() + { + for (var i = 0; i < this._currentItems.length; i++) + { + this.clearItem(this._currentItems[i]); + } + this._currentItems = []; + this._searchResults.innerHTML = ""; + this._currentItem = -1; + }, + + + createItem : function(item, index) + { + var d = document.createElement("div"); + d.className = "searchItem"; + //d.title = item.summary; + d.innerHTML = item.fullName; + d.index = index; + d._data = item; + this.addListener(d, 'click', this.dispatcher); + this.addListener(d, 'mouseover', this.dispatcher); + this.addListener(d, 'mouseout', this.dispatcher); + //todo - set listeners + return d; + }, + + redraw : function() + { + this.clear(); + var res = this.findMatches(); + if (res.length > 0) + { + for (var i = 0; i < res.length; i++) + { + var d = this.createItem(res[i], i); + this._currentItems.push(d); + this._searchResults.appendChild(d); + } + } + else + { + var s = (this._currentValue)? "Not found" : "Start typing the name of the item"; + this._searchResults.innerHTML = s; + } + }, + + start : function() + { + var instance = jgdoc.Searcher.initialize(); + instance.setData([]); + instance._timer = window.setInterval(instance.onTimer, 100); + } +} + diff --git a/buildscripts/jGrouseDoc/skins/common/js/jgindex.js b/buildscripts/jGrouseDoc/skins/common/js/jgindex.js index 5a0bf2de..d1944cff 100644 --- a/buildscripts/jGrouseDoc/skins/common/js/jgindex.js +++ b/buildscripts/jGrouseDoc/skins/common/js/jgindex.js @@ -1,96 +1,96 @@ -/**
- * Script that builds jGrouseDoc Index Page
- * Copyright (c) 2007 by Robert Kieffer and jGrouseDoc contributors
- * $Id: jgindex.js 303 2007-12-24 22:52:30Z denis.riabtchik $
- */
-
-var jgindex = {
- load: function() {
- // Sort data by localName
- jgindex.data.sort(function(a,b) {
- var c = (a.localName || a.fullName).toLowerCase();
- var d = (b.localName || b.fullName).toLowerCase();
- return c < d ? -1 : (c > d ? 1 : 0);
- });
-
- // Now render the index
- jgindex.renderEntries();
- },
-
- renderEntries: function() {
- var h = [];
-
- // Use a DL, since this is the most semantically correct structure
- h.push('<dl>');
-
- // Hash to track which letters have entries
- var letters = {};
-
- // Loop through each entry
- for (var i = 0; i < jgindex.data.length; i++) {
- var entry = jgindex.data[i];
-
- // Get name/url for the entry's namespace
- var srcName = entry.parent;
- var srcLink = entry.ref.replace(/#.*/, '');
-
- // Apply odd/even classname (makes styling even/odd rows easy)
- var cn = [(i % 2) ? 'odd' : 'even'];
- cn.push(/^(class|interface|struct|object)/.test(entry.summary) ? 'is_namespace' : 'is_not_namespace');
-
- // Get the entry's first letter
- var ln = entry.localName || entry.fullName || '_unnamed';
- var letter = ln.charAt(0).toUpperCase();
-
- // ... and see if it's the first one for that letter
- if (!letters[letter]) {
- letters[letter] = true;
- } else {
- letter = null;
- }
-
- // ... and if it is, render the section header
- if (letter) {
- h.push('<h3 class="letter_section"><a name="' + letter + '">' + letter + '</a></h3>');
- }
-
- // Render the entry's HTML
- cn = cn.join(' ');
- h.push(
- '<dt title="' + entry.summary + '" class="' + cn + '">' +
- '<a href="' + entry.ref + '">' + ln + '</a>' +
- '</dt>' +
- '<dd class="' + cn + '">' +
- '<a href="' + srcLink + '">' + srcName + '</a>' +
- '</dd>'
- );
- }
- h.push('</dl>');
-
- // Stick it all into the element
- document.getElementById('index').innerHTML = h.join('\n');
-
- // Render the letters table-of-contents at the top
- h = [];
- var toc = '$_ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- for (var i = 0; i < toc.length; i++) {
- var letter = toc.charAt(i);
- h.push(letters[letter] ?
- '<span class="has_entries"><a href="#' + letter + '">' + letter + '</a></span>' :
- '<span class="no_entries">' + letter + '</span>'
- );
- }
- document.getElementById('toc').innerHTML = h.join('\n');
- }
-}
-
-
-// Hack so we can get access to the index data
-var jgdoc = {
- Searcher: {
- setData: function(data) {
- jgindex.data = data;
- jgindex.load();
- }
- }
-}
+/** + * Script that builds jGrouseDoc Index Page + * Copyright (c) 2007 by Robert Kieffer and jGrouseDoc contributors + * $Id: jgindex.js 303 2007-12-24 22:52:30Z denis.riabtchik $ + */ + +var jgindex = { + load: function() { + // Sort data by localName + jgindex.data.sort(function(a,b) { + var c = (a.localName || a.fullName).toLowerCase(); + var d = (b.localName || b.fullName).toLowerCase(); + return c < d ? -1 : (c > d ? 1 : 0); + }); + + // Now render the index + jgindex.renderEntries(); + }, + + renderEntries: function() { + var h = []; + + // Use a DL, since this is the most semantically correct structure + h.push('<dl>'); + + // Hash to track which letters have entries + var letters = {}; + + // Loop through each entry + for (var i = 0; i < jgindex.data.length; i++) { + var entry = jgindex.data[i]; + + // Get name/url for the entry's namespace + var srcName = entry.parent; + var srcLink = entry.ref.replace(/#.*/, ''); + + // Apply odd/even classname (makes styling even/odd rows easy) + var cn = [(i % 2) ? 'odd' : 'even']; + cn.push(/^(class|interface|struct|object)/.test(entry.summary) ? 'is_namespace' : 'is_not_namespace'); + + // Get the entry's first letter + var ln = entry.localName || entry.fullName || '_unnamed'; + var letter = ln.charAt(0).toUpperCase(); + + // ... and see if it's the first one for that letter + if (!letters[letter]) { + letters[letter] = true; + } else { + letter = null; + } + + // ... and if it is, render the section header + if (letter) { + h.push('<h3 class="letter_section"><a name="' + letter + '">' + letter + '</a></h3>'); + } + + // Render the entry's HTML + cn = cn.join(' '); + h.push( + '<dt title="' + entry.summary + '" class="' + cn + '">' + + '<a href="' + entry.ref + '">' + ln + '</a>' + + '</dt>' + + '<dd class="' + cn + '">' + + '<a href="' + srcLink + '">' + srcName + '</a>' + + '</dd>' + ); + } + h.push('</dl>'); + + // Stick it all into the element + document.getElementById('index').innerHTML = h.join('\n'); + + // Render the letters table-of-contents at the top + h = []; + var toc = '$_ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + for (var i = 0; i < toc.length; i++) { + var letter = toc.charAt(i); + h.push(letters[letter] ? + '<span class="has_entries"><a href="#' + letter + '">' + letter + '</a></span>' : + '<span class="no_entries">' + letter + '</span>' + ); + } + document.getElementById('toc').innerHTML = h.join('\n'); + } +} + + +// Hack so we can get access to the index data +var jgdoc = { + Searcher: { + setData: function(data) { + jgindex.data = data; + jgindex.load(); + } + } +} diff --git a/buildscripts/jGrouseDoc/skins/common/js/navTree.js b/buildscripts/jGrouseDoc/skins/common/js/navTree.js index f0c4f133..5a71ec51 100644 --- a/buildscripts/jGrouseDoc/skins/common/js/navTree.js +++ b/buildscripts/jGrouseDoc/skins/common/js/navTree.js @@ -1,213 +1,213 @@ -jgdoc = {};
-jgdoc.TreeItem = function(nodeName, item)
-{
- this._nodeName = nodeName;
- this._data = item;
- this._children = [];
-
-}
-
-jgdoc.Searcher =
-{
- setData : function(data) {
- this._data = data;
- this.processItems();
- this.render();
- },
-
- sorter: function(o1, o2) {
- var l1 = o1.localName;
- var l2 = o2.localName;
- return l1 < l2? -1 : (l1 > l2 ? 1 : 0);
- },
-
- processItems : function() {
- var root;
-
- // Pass 1: Build index by fullName, and locate the root element
- this._byName = {};
- for (var i = 0; i < this._data.length; i++) {
- var d = this._data[i];
- if (d.fullName == "GLOBAL") {
- root = this._root = d;
- }
- this._byName[d.fullName] = d;
- }
-
- // Pass 2: Populate _children arrays
- for (var i = 0; i < this._data.length; i++) {
- var item = this._data[i];
- if (item.elementType == "logical_container" && item != this._root) {
- var parent = this._byName[item.parent];
- parent._children = parent._children || [];
- parent._children.push(item);
- }
- }
- },
-
- addClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- return;
- }
- }
- a.push(className);
- element.className = a.join(' ');
- },
-
- removeClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- var found = false;
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- found = true;
- break;
- }
- }
- element.className = a.join(' ');
- return found;
- },
-
- clicked : function(event)
- {
- event = window.event? window.event : event;
- var target = event.target || event.srcElement;
- var span = target.parentNode;
- var li = span.parentNode;
- var wasOpen = jgdoc.Searcher.removeClass(li, 'open');
- if (wasOpen)
- {
- jgdoc.Searcher.addClass(li, 'closed');
- }
- else
- {
- jgdoc.Searcher.removeClass(li, 'closed');
- jgdoc.Searcher.addClass(li, 'open');
- }
- span.title = "Click to " + (wasOpen? "expand" : "collapse");
-
- },
-
- addListener : function(element, eventName, handler)
- {
- if (element.addEventListener)
- {
- element.addEventListener(eventName, handler, false);
- }
- else
- {
- element.attachEvent('on' + eventName, handler);
- }
- },
-
- removeListener : function(element, eventName, handler)
- {
- if (element.removeEventListener)
- {
- element.removeEventListener(eventName, handler, false);
- }
- else
- {
- element.detachEvent('on' + eventName, handler);
- }
- },
-
-
- render : function()
- {
- var d = document.getElementById('content');
- d.innerHTML = '';
- var athis = this;
- function renderNode(item)
- {
- var node = document.createElement('li');
- node.className = item.type;
- node.innerHTML = "<span class='node'><span class='markerSpace'> </span></span><a href='" + item.ref + "' target='classFrame' title='" + item.summary + "'>" + item.localName + "</a>";
- var span = node.firstChild;
- var img = span.firstChild;
- athis.addListener(img, 'mousedown', athis.clicked);
- if (item._children)
- {
- item._children.sort(jgdoc.Searcher.sorter);
- node.className += (item == athis._root)? ' open' : ' closed';
- span.title = "Click to " + (item != athis._root? 'expand' : 'collapse');
- var subnode = document.createElement("ul");
- subnode.className = 'contents';
- for (var i = 0; i < item._children.length; i++)
- {
- var child = renderNode(item._children[i]);
- subnode.appendChild(child);
- }
- node.appendChild(subnode);
- }
- else
- {
- node.className += ' leaf';
- }
- item._node = node;
- return node;
- }
- var root = renderNode(this._root);
- d.appendChild(root);
- },
-
- cancelEvent : function(event)
- {
- if (event.preventDefault)
- {
- event.preventDefault();
- event.stopPropagation();
- }
- else
- {
- event.preventDefault();
- event.stopPropagation();
- }
- },
-
- switchAll : function(doOpen)
- {
- var ac = doOpen? 'open' : 'closed';
- var rc = doOpen? 'closed' : 'open';
-
- var athis = this;
-
- function doSwitchNode(anode)
- {
- if (anode._children)
- {
- if (doOpen || anode != athis._root)
- {
- athis.removeClass(anode._node, rc);
- athis.addClass(anode._node, ac);
- }
- for (var i = 0; i < anode._children.length; i++)
- {
- doSwitchNode(anode._children[i]);
- }
- }
- }
- doSwitchNode(this._root);
- },
-
- onOpenAll : function()
- {
- jgdoc.Searcher.switchAll(true);
- },
-
- onCloseAll : function()
- {
- jgdoc.Searcher.switchAll(false);
- }
-
-};
+jgdoc = {}; +jgdoc.TreeItem = function(nodeName, item) +{ + this._nodeName = nodeName; + this._data = item; + this._children = []; + +} + +jgdoc.Searcher = +{ + setData : function(data) { + this._data = data; + this.processItems(); + this.render(); + }, + + sorter: function(o1, o2) { + var l1 = o1.localName; + var l2 = o2.localName; + return l1 < l2? -1 : (l1 > l2 ? 1 : 0); + }, + + processItems : function() { + var root; + + // Pass 1: Build index by fullName, and locate the root element + this._byName = {}; + for (var i = 0; i < this._data.length; i++) { + var d = this._data[i]; + if (d.fullName == "GLOBAL") { + root = this._root = d; + } + this._byName[d.fullName] = d; + } + + // Pass 2: Populate _children arrays + for (var i = 0; i < this._data.length; i++) { + var item = this._data[i]; + if (item.elementType == "logical_container" && item != this._root) { + var parent = this._byName[item.parent]; + parent._children = parent._children || []; + parent._children.push(item); + } + } + }, + + addClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + return; + } + } + a.push(className); + element.className = a.join(' '); + }, + + removeClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + var found = false; + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + a.splice(i, 1); + found = true; + break; + } + } + element.className = a.join(' '); + return found; + }, + + clicked : function(event) + { + event = window.event? window.event : event; + var target = event.target || event.srcElement; + var span = target.parentNode; + var li = span.parentNode; + var wasOpen = jgdoc.Searcher.removeClass(li, 'open'); + if (wasOpen) + { + jgdoc.Searcher.addClass(li, 'closed'); + } + else + { + jgdoc.Searcher.removeClass(li, 'closed'); + jgdoc.Searcher.addClass(li, 'open'); + } + span.title = "Click to " + (wasOpen? "expand" : "collapse"); + + }, + + addListener : function(element, eventName, handler) + { + if (element.addEventListener) + { + element.addEventListener(eventName, handler, false); + } + else + { + element.attachEvent('on' + eventName, handler); + } + }, + + removeListener : function(element, eventName, handler) + { + if (element.removeEventListener) + { + element.removeEventListener(eventName, handler, false); + } + else + { + element.detachEvent('on' + eventName, handler); + } + }, + + + render : function() + { + var d = document.getElementById('content'); + d.innerHTML = ''; + var athis = this; + function renderNode(item) + { + var node = document.createElement('li'); + node.className = item.type; + node.innerHTML = "<span class='node'><span class='markerSpace'> </span></span><a href='" + item.ref + "' target='classFrame' title='" + item.summary + "'>" + item.localName + "</a>"; + var span = node.firstChild; + var img = span.firstChild; + athis.addListener(img, 'mousedown', athis.clicked); + if (item._children) + { + item._children.sort(jgdoc.Searcher.sorter); + node.className += (item == athis._root)? ' open' : ' closed'; + span.title = "Click to " + (item != athis._root? 'expand' : 'collapse'); + var subnode = document.createElement("ul"); + subnode.className = 'contents'; + for (var i = 0; i < item._children.length; i++) + { + var child = renderNode(item._children[i]); + subnode.appendChild(child); + } + node.appendChild(subnode); + } + else + { + node.className += ' leaf'; + } + item._node = node; + return node; + } + var root = renderNode(this._root); + d.appendChild(root); + }, + + cancelEvent : function(event) + { + if (event.preventDefault) + { + event.preventDefault(); + event.stopPropagation(); + } + else + { + event.preventDefault(); + event.stopPropagation(); + } + }, + + switchAll : function(doOpen) + { + var ac = doOpen? 'open' : 'closed'; + var rc = doOpen? 'closed' : 'open'; + + var athis = this; + + function doSwitchNode(anode) + { + if (anode._children) + { + if (doOpen || anode != athis._root) + { + athis.removeClass(anode._node, rc); + athis.addClass(anode._node, ac); + } + for (var i = 0; i < anode._children.length; i++) + { + doSwitchNode(anode._children[i]); + } + } + } + doSwitchNode(this._root); + }, + + onOpenAll : function() + { + jgdoc.Searcher.switchAll(true); + }, + + onCloseAll : function() + { + jgdoc.Searcher.switchAll(false); + } + +}; diff --git a/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js b/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js index 9d1f1364..3e6a9aa5 100644 --- a/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js +++ b/buildscripts/jGrouseDoc/skins/noframes/js/jgdoc.js @@ -1,326 +1,326 @@ -/**
- * Searcher for JGrouseDoc
- * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $
- */
-
-if (typeof jgdoc == 'undefined')
-{
- jgdoc = {}
-
- jgdoc._dataHandlers = [];
-
- jgdoc.setData = function(data)
- {
- for (var i = 0; i < jgdoc._dataHandlers.length; i++)
- {
- jgdoc._dataHandlers[i](data);
- }
- }
-}
-
-jgdoc.Searcher =
-{
- initialize : function()
- {
- this._searchBox = document.getElementById("jgsSearchString");
- this._searchResults = document.getElementById("jgsSearchResults");
- this._info = document.getElementById("jgsInfo");
- this._currentValue = "";
- this._currentItems = [];
- this._currentItem = -1;
- this._data = null;
- this._searchPanel = document.getElementById("jgsSearchPanel");
- this.addListener(this._searchBox, 'focus', this.dispatcher);
- this.addListener(this._searchBox, 'blur', this.dispatcher);
- this.addListener(window, 'resize', this.dispatcher);
- var width = this._searchBox.offsetWidth - 4;
- this._searchPanel.style.width = width + 'px';
-
- /*var node = this._searchBox;
- var current = 0;
- var currentTop = 0;
- while (node)
- {
- current += node.offsetLeft;
- currentTop += node.offsetTop;
- node = node.offsetParent;
- }
-
- this._searchPanel.style.left = current + 'px';*/
- this.positionBox();
- return this;
- },
-
- positionBox : function()
- {
- var node = this._searchBox;
- var current = 0;
- var currentTop = 0;
- while (node)
- {
- current += node.offsetLeft;
- currentTop += node.offsetTop;
- node = node.offsetParent;
- }
-
- this._searchPanel.style.left = current + 'px';
- this._searchPanel.style.top = (currentTop + this._searchBox.offsetHeight) + "px";
-
- },
-
- _getEvent : function(event)
- {
- return window.event? window.event : event;
- },
-
- _getTarget : function(event)
- {
- return event.target || event.srcElement
- },
-
- addClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- return;
- }
- }
- a.push(className);
- element.className = a.join(' ');
- },
-
- removeClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- break;
- }
- }
- element.className = a.join(' ');
-
- },
-
- dispatcher : function(event)
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- event = this._getEvent(event);
- var type = event.type;
- var handler = "on" + type;
- this[handler](event, this._getTarget(event));
- },
-
- onclick : function(event, target)
- {
- // workaround for IE bug
- window.location.href = target.getAttribute("href", 1);
- },
-
- onmouseover : function(event, target)
- {
- this.selectItem(target.index);
- },
-
- onresize : function(event, target)
- {
- if (this._searchPanel.style.display != 'none')
- {
- this.positionBox();
- }
- },
-
- onmouseout : function(event, target)
- {
- this.unselectItem(target.index);
- },
-
- onfocus : function(event, target)
- {
- this._searchPanel.style.display = '';
- this.positionBox();
- },
-
- onblur : function(event, target)
- {
- var athis = this;
- window.setTimeout(function()
- {
- athis._searchPanel.style.display = 'none';
- }, 300);
-
- },
-
- selectItem : function(index)
- {
- if (index != this._currentItem)
- {
- this._currentItem = index;
- var item = this._currentItems[index];
- this.addClass(item, 'jgdSelectedItem');
- var text = item._data.summary.split('\n').join('<br/>');
- this._info.innerHTML = text;
- }
- },
-
- unselectItem : function(index)
- {
- this._currentItem = -1;
- var item = this._currentItems[index];
- this.removeClass(item, 'jgdSelectedItem');
- this._info.innerHTML = 'No selection';
- },
-
- openItem : function(name)
- {
-
- },
-
-
- onTimer : function()
- {
- if (this != jgdoc.Searcher)
- {
- arguments.callee.apply(jgdoc.Searcher, arguments)
- return;
- }
- var val = this._searchBox.value;
- if (val != this._currentValue)
- {
- this._currentValue = val;
- this.redraw();
- }
- },
-
- setData : function(data)
- {
- this._data = data;
- this.redraw();
- //this._searchBox.focus();
- },
-
- addListener : function(element, eventName, handler)
- {
- if (element.addEventListener)
- {
- element.addEventListener(eventName, handler, false);
- }
- else
- {
- element.attachEvent('on' + eventName, handler);
- }
- },
-
- removeListener : function(element, eventName, handler)
- {
- if (element.removeEventListener)
- {
- element.removeEventListener(eventName, handler, false);
- }
- else
- {
- element.detachEvent('on' + eventName, handler);
- }
- },
-
- findMatches : function()
- {
- var result = [];
- if (this._currentValue)
- {
- var v = this._currentValue.toUpperCase();
- for (var i = 0; i < this._data.length; i++)
- {
- var item = this._data[i];
- if (item.localName.toUpperCase().indexOf(v) == 0)
- {
- result.push(item);
- }
- }
- }
- return result;
- },
-
-
- clearItem : function(item)
- {
- item._data = null;
- this.removeListener(item, 'click', this.dispatcher);
- this.removeListener(item, 'mouseover', this.dispatcher);
- this.removeListener(item, 'mouseout', this.dispatcher);
- },
-
- clear : function()
- {
- for (var i = 0; i < this._currentItems.length; i++)
- {
- this.clearItem(this._currentItems[i]);
- }
- this._currentItems = [];
- this._searchResults.innerHTML = "";
- this._currentItem = -1;
- },
-
-
- createItem : function(item, index)
- {
- var d1 = document.createElement("div");
- d1.innerHTML = "<a href='" + item.ref + "'>" + item.fullName + "</a>";
- d = d1.firstChild;
- /*d.href = item.ref;
- item.ref = d.href;*/
- d.className = "searchItem";
- //d.title = item.summary;
- //d.innerHTML = item.fullName;
- d.index = index;
- d._data = item;
- this.addListener(d, 'click', this.dispatcher);
- this.addListener(d, 'mouseover', this.dispatcher);
- this.addListener(d, 'mouseout', this.dispatcher);
- //todo - set listeners
- return d;
- },
-
- redraw : function()
- {
- this.clear();
- var res = this.findMatches();
- if (res.length > 0)
- {
- for (var i = 0; i < res.length; i++)
- {
- var d = this.createItem(res[i], i);
- this._currentItems.push(d);
- this._searchResults.appendChild(d);
- }
- }
- else
- {
- var s = (this._currentValue)? "Not found" : "Start typing the name of the item";
- this._searchResults.innerHTML = s;
- }
- },
-
- start : function()
- {
- var instance = jgdoc.Searcher.initialize();
- instance.setData([]);
- instance._timer = window.setInterval(instance.onTimer, 100);
- }
-}
-
-jgdoc._dataHandlers.push(function(data)
-{
- jgdoc.Searcher.setData(data);
+/** + * Searcher for JGrouseDoc + * $Id: jgdoc.js 324 2008-01-06 16:44:39Z denis.riabtchik $ + */ + +if (typeof jgdoc == 'undefined') +{ + jgdoc = {} + + jgdoc._dataHandlers = []; + + jgdoc.setData = function(data) + { + for (var i = 0; i < jgdoc._dataHandlers.length; i++) + { + jgdoc._dataHandlers[i](data); + } + } +} + +jgdoc.Searcher = +{ + initialize : function() + { + this._searchBox = document.getElementById("jgsSearchString"); + this._searchResults = document.getElementById("jgsSearchResults"); + this._info = document.getElementById("jgsInfo"); + this._currentValue = ""; + this._currentItems = []; + this._currentItem = -1; + this._data = null; + this._searchPanel = document.getElementById("jgsSearchPanel"); + this.addListener(this._searchBox, 'focus', this.dispatcher); + this.addListener(this._searchBox, 'blur', this.dispatcher); + this.addListener(window, 'resize', this.dispatcher); + var width = this._searchBox.offsetWidth - 4; + this._searchPanel.style.width = width + 'px'; + + /*var node = this._searchBox; + var current = 0; + var currentTop = 0; + while (node) + { + current += node.offsetLeft; + currentTop += node.offsetTop; + node = node.offsetParent; + } + + this._searchPanel.style.left = current + 'px';*/ + this.positionBox(); + return this; + }, + + positionBox : function() + { + var node = this._searchBox; + var current = 0; + var currentTop = 0; + while (node) + { + current += node.offsetLeft; + currentTop += node.offsetTop; + node = node.offsetParent; + } + + this._searchPanel.style.left = current + 'px'; + this._searchPanel.style.top = (currentTop + this._searchBox.offsetHeight) + "px"; + + }, + + _getEvent : function(event) + { + return window.event? window.event : event; + }, + + _getTarget : function(event) + { + return event.target || event.srcElement + }, + + addClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + return; + } + } + a.push(className); + element.className = a.join(' '); + }, + + removeClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + a.splice(i, 1); + break; + } + } + element.className = a.join(' '); + + }, + + dispatcher : function(event) + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + event = this._getEvent(event); + var type = event.type; + var handler = "on" + type; + this[handler](event, this._getTarget(event)); + }, + + onclick : function(event, target) + { + // workaround for IE bug + window.location.href = target.getAttribute("href", 1); + }, + + onmouseover : function(event, target) + { + this.selectItem(target.index); + }, + + onresize : function(event, target) + { + if (this._searchPanel.style.display != 'none') + { + this.positionBox(); + } + }, + + onmouseout : function(event, target) + { + this.unselectItem(target.index); + }, + + onfocus : function(event, target) + { + this._searchPanel.style.display = ''; + this.positionBox(); + }, + + onblur : function(event, target) + { + var athis = this; + window.setTimeout(function() + { + athis._searchPanel.style.display = 'none'; + }, 300); + + }, + + selectItem : function(index) + { + if (index != this._currentItem) + { + this._currentItem = index; + var item = this._currentItems[index]; + this.addClass(item, 'jgdSelectedItem'); + var text = item._data.summary.split('\n').join('<br/>'); + this._info.innerHTML = text; + } + }, + + unselectItem : function(index) + { + this._currentItem = -1; + var item = this._currentItems[index]; + this.removeClass(item, 'jgdSelectedItem'); + this._info.innerHTML = 'No selection'; + }, + + openItem : function(name) + { + + }, + + + onTimer : function() + { + if (this != jgdoc.Searcher) + { + arguments.callee.apply(jgdoc.Searcher, arguments) + return; + } + var val = this._searchBox.value; + if (val != this._currentValue) + { + this._currentValue = val; + this.redraw(); + } + }, + + setData : function(data) + { + this._data = data; + this.redraw(); + //this._searchBox.focus(); + }, + + addListener : function(element, eventName, handler) + { + if (element.addEventListener) + { + element.addEventListener(eventName, handler, false); + } + else + { + element.attachEvent('on' + eventName, handler); + } + }, + + removeListener : function(element, eventName, handler) + { + if (element.removeEventListener) + { + element.removeEventListener(eventName, handler, false); + } + else + { + element.detachEvent('on' + eventName, handler); + } + }, + + findMatches : function() + { + var result = []; + if (this._currentValue) + { + var v = this._currentValue.toUpperCase(); + for (var i = 0; i < this._data.length; i++) + { + var item = this._data[i]; + if (item.localName.toUpperCase().indexOf(v) == 0) + { + result.push(item); + } + } + } + return result; + }, + + + clearItem : function(item) + { + item._data = null; + this.removeListener(item, 'click', this.dispatcher); + this.removeListener(item, 'mouseover', this.dispatcher); + this.removeListener(item, 'mouseout', this.dispatcher); + }, + + clear : function() + { + for (var i = 0; i < this._currentItems.length; i++) + { + this.clearItem(this._currentItems[i]); + } + this._currentItems = []; + this._searchResults.innerHTML = ""; + this._currentItem = -1; + }, + + + createItem : function(item, index) + { + var d1 = document.createElement("div"); + d1.innerHTML = "<a href='" + item.ref + "'>" + item.fullName + "</a>"; + d = d1.firstChild; + /*d.href = item.ref; + item.ref = d.href;*/ + d.className = "searchItem"; + //d.title = item.summary; + //d.innerHTML = item.fullName; + d.index = index; + d._data = item; + this.addListener(d, 'click', this.dispatcher); + this.addListener(d, 'mouseover', this.dispatcher); + this.addListener(d, 'mouseout', this.dispatcher); + //todo - set listeners + return d; + }, + + redraw : function() + { + this.clear(); + var res = this.findMatches(); + if (res.length > 0) + { + for (var i = 0; i < res.length; i++) + { + var d = this.createItem(res[i], i); + this._currentItems.push(d); + this._searchResults.appendChild(d); + } + } + else + { + var s = (this._currentValue)? "Not found" : "Start typing the name of the item"; + this._searchResults.innerHTML = s; + } + }, + + start : function() + { + var instance = jgdoc.Searcher.initialize(); + instance.setData([]); + instance._timer = window.setInterval(instance.onTimer, 100); + } +} + +jgdoc._dataHandlers.push(function(data) +{ + jgdoc.Searcher.setData(data); });
\ No newline at end of file diff --git a/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js b/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js index ac011da4..98e30a29 100644 --- a/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js +++ b/buildscripts/jGrouseDoc/skins/noframes/js/navTree.js @@ -1,409 +1,409 @@ -if (typeof jgdoc == 'undefined')
-{
- jgdoc = {}
-
- jgdoc._dataHandlers = [];
-
- jgdoc.setData = function(data)
- {
- for (var i = 0; i < jgdoc._dataHandlers.length; i++)
- {
- jgdoc._dataHandlers[i](data);
- }
- }
-}
-
-jgdoc.TreeItem = function(nodeName, item)
-{
- this._nodeName = nodeName;
- this._data = item;
- this._children = [];
-
-}
-
-jgdoc.Common =
-{
- addClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- return;
- }
- }
- a.push(className);
- element.className = a.join(' ');
- },
-
- removeClass : function(element, className)
- {
- var s = element.className;
- var a = s.split(' ');
- var found = false;
- for (var i = 0; i < a.length; i++)
- {
- if (a[i] == className)
- {
- a.splice(i, 1);
- found = true;
- break;
- }
- }
- element.className = a.join(' ');
- return found;
- },
-
- addListener : function(element, eventName, handler)
- {
- if (element.addEventListener)
- {
- element.addEventListener(eventName, handler, false);
- }
- else
- {
- element.attachEvent('on' + eventName, handler);
- }
- },
-
- removeListener : function(element, eventName, handler)
- {
- if (element.removeEventListener)
- {
- element.removeEventListener(eventName, handler, false);
- }
- else
- {
- element.detachEvent('on' + eventName, handler);
- }
- }
-}
-
-jgdoc.NavPanel =
-{
- clicked : function(e)
- {
- e = window.event? window.event : e;
- var target = e.target || e.srcElement;
- var node = target;
- while (node != null && node.tagName != 'UL')
- {
- node = node.parentNode;
- }
- if (node)
- {
- var parent = node.parentNode;
- var current = parent.firstChild;
- while (current)
- {
- if (current != node && current.nodeType === 1)
- {
- jgdoc.Common.addClass(current, "closed");
- }
- current = current.nextSibling;
- }
- jgdoc.Common.removeClass(node, "closed");
- }
- },
-
- dummy : function()
- {
- }
-}
-
-/*
-jgdoc.App =
-{
- initialize : function()
- {
- this._container = document.getElementById("startup");
- this._banner = document.getElementById("banner");
- this._content = document.getElementById("docContent");
- this._navigation = document.getElementById("navigation");
- this._docScroll = document.getElementById("docScroll");
- this._html = document.getElementsByTagName('html')[0];
- this._body = document.getElementsByTagName("body")[0];
- this._searchBlock = document.getElementById("searchBlock");
- this._html.style.overflowY = "hidden";
-
- }
-}*/
-
-jgdoc.NavTree =
-{
- initialize : function(defaultName)
- {
- this._defaultName = defaultName;
- },
-
-
- setData : function(data) {
- this._data = data;
- this.processItems();
- this.render();
- this.openItem(this._defaultName);
- },
-
- sorter: function(o1, o2) {
- var l1 = o1.localName;
- var l2 = o2.localName;
- return l1 < l2? -1 : (l1 > l2 ? 1 : 0);
- },
-
- processItems : function() {
- var root;
-
- // Pass 1: Build index by fullName, and locate the root element
- this._byName = {};
- for (var i = 0; i < this._data.length; i++) {
- var d = this._data[i];
- if (d.fullName == "GLOBAL") {
- root = this._root = d;
- }
- this._byName[d.fullName] = d;
- }
-
- // Pass 2: Populate _children arrays
- for (var i = 0; i < this._data.length; i++) {
- var item = this._data[i];
- if (item.elementType == "logical_container" && item != this._root) {
- var parent = this._byName[item.parent];
- parent._children = parent._children || [];
- parent._children.push(item);
- }
- }
- },
-
- findItem : function(name)
- {
- return this._byName[name];
- },
-
- /*setData : function(data)
- {
- this._data = data;
- data.sort(this.sorter);
- this._root = data[0];
- this.processItems();
- this.render();
- this.openItem(this._defaultName);
- },
-
- findItem : function(name)
- {
- if (name === '' || name == 'GLOBAL')
- {
- return this._root;
- }
- var s = name.split('.');
- var current = this._root._children;
- var found = null;
- for (var i = 0; i < s.length; i++)
- {
- var detected = false;
- for (var j = 0; j < current.length; j++)
- {
- var item = current[j];
- if (item.localName == s[i])
- {
- detected = true;
- current = item._children;
- found = item;
- break;
- }
- }
- if (!detected)
- {
- return false;
- }
- }
- return found;
- },
-
- processItems : function()
- {
- for (var i = 1; i < this._data.length; i++)
- {
- var item = this._data[i];
- if (item.elementType == "logical_container")
- {
- var parent = this.findItem(item.parent);
- if (!parent._children)
- {
- parent._children = [];
- }
- parent._children.push(item);
- }
- }
- },
-
-
- sorter : function(item1, item2)
- {
- if (item1.parent == "")
- {
- return -1;
- }
- if (item2.parent == "")
- {
- return 1;
- }
- if (item1.parent == item2.parent)
- {
- return item1.localName < item2.localName? -1 : item1.localName > item2.localName? 1 : 0;
- }
- if (item1.parent == "GLOBAL")
- {
- return -1;
- }
- if (item2.parent == "GLOBAL")
- {
- return 1;
- }
- return item1.parent < item2.parent? -1 : 1;
- },
- */
-
-
- clicked : function(event)
- {
- event = window.event? window.event : event;
- var target = event.target || event.srcElement;
- var span = target.parentNode;
- var li = span.parentNode;
- var wasOpen = jgdoc.Common.removeClass(li, 'open');
- if (wasOpen)
- {
- jgdoc.Common.addClass(li, 'closed');
- }
- else
- {
- jgdoc.Common.removeClass(li, 'closed');
- jgdoc.Common.addClass(li, 'open');
- }
- span.title = "Click to " + (wasOpen? "expand" : "collapse");
-
- },
-
-
-
-
- render : function()
- {
- var d = document.getElementById('content');
- d.innerHTML = '';
- var athis = this;
- function renderNode(item)
- {
- var node = document.createElement('li');
- node.className = item.type;
- node.innerHTML = "<span class='node'><span class='markerSpace'> </span></span><a href='" + item.ref + "' title='" + item.summary + "'>" + item.localName + "</a>";
- var span = node.firstChild;
- var img = span.firstChild;
- jgdoc.Common.addListener(img, 'mousedown', athis.clicked);
- if (item._children)
- {
- node.className += (item == athis._root)? ' open' : ' closed';
- span.title = "Click to " + (item != athis._root? 'expand' : 'collapse');
- var subnode = document.createElement("ul");
- subnode.className = 'contents';
- for (var i = 0; i < item._children.length; i++)
- {
- var child = renderNode(item._children[i]);
- subnode.appendChild(child);
- }
- node.appendChild(subnode);
- }
- else
- {
- node.className += ' leaf';
- }
- if (item.fullName == athis._defaultName)
- {
- node.firstChild.nextSibling.className += ' currentNode';
- }
- item._node = node;
- return node;
- }
- var root = renderNode(this._root);
- d.appendChild(root);
- },
-
- cancelEvent : function(event)
- {
- if (event.preventDefault)
- {
- event.preventDefault();
- event.stopPropagation();
- }
- else
- {
- event.preventDefault();
- event.stopPropagation();
- }
- },
-
- switchAll : function(doOpen)
- {
- var ac = doOpen? 'open' : 'closed';
- var rc = doOpen? 'closed' : 'open';
-
- var athis = this;
-
- function doSwitchNode(anode)
- {
- if (anode._children)
- {
- if (doOpen || anode != athis._root)
- {
- jgdoc.Common.removeClass(anode._node, rc);
- jgdoc.Common.addClass(anode._node, ac);
- }
- for (var i = 0; i < anode._children.length; i++)
- {
- doSwitchNode(anode._children[i]);
- }
- }
- }
- doSwitchNode(this._root);
- },
-
- openItem : function(name)
- {
- this.switchAll(false);
- while (name != 'GLOBAL')
- {
- var item = this.findItem(name);
- if (item)
- {
- var node = item._node;
- jgdoc.Common.removeClass(node, 'closed');
- jgdoc.Common.addClass(node, 'open');
- name = item.parent;
- }
- else
- {
- return;
- }
- }
- },
-
- onOpenAll : function()
- {
- jgdoc.NavTree.switchAll(true);
- },
-
- onCloseAll : function()
- {
- jgdoc.NavTree.switchAll(false);
- }
-
-};
-
-jgdoc._dataHandlers.push(function(data)
-{
- //jgdoc.App.initialize();
- jgdoc.NavTree.setData(data);
-});
+if (typeof jgdoc == 'undefined') +{ + jgdoc = {} + + jgdoc._dataHandlers = []; + + jgdoc.setData = function(data) + { + for (var i = 0; i < jgdoc._dataHandlers.length; i++) + { + jgdoc._dataHandlers[i](data); + } + } +} + +jgdoc.TreeItem = function(nodeName, item) +{ + this._nodeName = nodeName; + this._data = item; + this._children = []; + +} + +jgdoc.Common = +{ + addClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + return; + } + } + a.push(className); + element.className = a.join(' '); + }, + + removeClass : function(element, className) + { + var s = element.className; + var a = s.split(' '); + var found = false; + for (var i = 0; i < a.length; i++) + { + if (a[i] == className) + { + a.splice(i, 1); + found = true; + break; + } + } + element.className = a.join(' '); + return found; + }, + + addListener : function(element, eventName, handler) + { + if (element.addEventListener) + { + element.addEventListener(eventName, handler, false); + } + else + { + element.attachEvent('on' + eventName, handler); + } + }, + + removeListener : function(element, eventName, handler) + { + if (element.removeEventListener) + { + element.removeEventListener(eventName, handler, false); + } + else + { + element.detachEvent('on' + eventName, handler); + } + } +} + +jgdoc.NavPanel = +{ + clicked : function(e) + { + e = window.event? window.event : e; + var target = e.target || e.srcElement; + var node = target; + while (node != null && node.tagName != 'UL') + { + node = node.parentNode; + } + if (node) + { + var parent = node.parentNode; + var current = parent.firstChild; + while (current) + { + if (current != node && current.nodeType === 1) + { + jgdoc.Common.addClass(current, "closed"); + } + current = current.nextSibling; + } + jgdoc.Common.removeClass(node, "closed"); + } + }, + + dummy : function() + { + } +} + +/* +jgdoc.App = +{ + initialize : function() + { + this._container = document.getElementById("startup"); + this._banner = document.getElementById("banner"); + this._content = document.getElementById("docContent"); + this._navigation = document.getElementById("navigation"); + this._docScroll = document.getElementById("docScroll"); + this._html = document.getElementsByTagName('html')[0]; + this._body = document.getElementsByTagName("body")[0]; + this._searchBlock = document.getElementById("searchBlock"); + this._html.style.overflowY = "hidden"; + + } +}*/ + +jgdoc.NavTree = +{ + initialize : function(defaultName) + { + this._defaultName = defaultName; + }, + + + setData : function(data) { + this._data = data; + this.processItems(); + this.render(); + this.openItem(this._defaultName); + }, + + sorter: function(o1, o2) { + var l1 = o1.localName; + var l2 = o2.localName; + return l1 < l2? -1 : (l1 > l2 ? 1 : 0); + }, + + processItems : function() { + var root; + + // Pass 1: Build index by fullName, and locate the root element + this._byName = {}; + for (var i = 0; i < this._data.length; i++) { + var d = this._data[i]; + if (d.fullName == "GLOBAL") { + root = this._root = d; + } + this._byName[d.fullName] = d; + } + + // Pass 2: Populate _children arrays + for (var i = 0; i < this._data.length; i++) { + var item = this._data[i]; + if (item.elementType == "logical_container" && item != this._root) { + var parent = this._byName[item.parent]; + parent._children = parent._children || []; + parent._children.push(item); + } + } + }, + + findItem : function(name) + { + return this._byName[name]; + }, + + /*setData : function(data) + { + this._data = data; + data.sort(this.sorter); + this._root = data[0]; + this.processItems(); + this.render(); + this.openItem(this._defaultName); + }, + + findItem : function(name) + { + if (name === '' || name == 'GLOBAL') + { + return this._root; + } + var s = name.split('.'); + var current = this._root._children; + var found = null; + for (var i = 0; i < s.length; i++) + { + var detected = false; + for (var j = 0; j < current.length; j++) + { + var item = current[j]; + if (item.localName == s[i]) + { + detected = true; + current = item._children; + found = item; + break; + } + } + if (!detected) + { + return false; + } + } + return found; + }, + + processItems : function() + { + for (var i = 1; i < this._data.length; i++) + { + var item = this._data[i]; + if (item.elementType == "logical_container") + { + var parent = this.findItem(item.parent); + if (!parent._children) + { + parent._children = []; + } + parent._children.push(item); + } + } + }, + + + sorter : function(item1, item2) + { + if (item1.parent == "") + { + return -1; + } + if (item2.parent == "") + { + return 1; + } + if (item1.parent == item2.parent) + { + return item1.localName < item2.localName? -1 : item1.localName > item2.localName? 1 : 0; + } + if (item1.parent == "GLOBAL") + { + return -1; + } + if (item2.parent == "GLOBAL") + { + return 1; + } + return item1.parent < item2.parent? -1 : 1; + }, + */ + + + clicked : function(event) + { + event = window.event? window.event : event; + var target = event.target || event.srcElement; + var span = target.parentNode; + var li = span.parentNode; + var wasOpen = jgdoc.Common.removeClass(li, 'open'); + if (wasOpen) + { + jgdoc.Common.addClass(li, 'closed'); + } + else + { + jgdoc.Common.removeClass(li, 'closed'); + jgdoc.Common.addClass(li, 'open'); + } + span.title = "Click to " + (wasOpen? "expand" : "collapse"); + + }, + + + + + render : function() + { + var d = document.getElementById('content'); + d.innerHTML = ''; + var athis = this; + function renderNode(item) + { + var node = document.createElement('li'); + node.className = item.type; + node.innerHTML = "<span class='node'><span class='markerSpace'> </span></span><a href='" + item.ref + "' title='" + item.summary + "'>" + item.localName + "</a>"; + var span = node.firstChild; + var img = span.firstChild; + jgdoc.Common.addListener(img, 'mousedown', athis.clicked); + if (item._children) + { + node.className += (item == athis._root)? ' open' : ' closed'; + span.title = "Click to " + (item != athis._root? 'expand' : 'collapse'); + var subnode = document.createElement("ul"); + subnode.className = 'contents'; + for (var i = 0; i < item._children.length; i++) + { + var child = renderNode(item._children[i]); + subnode.appendChild(child); + } + node.appendChild(subnode); + } + else + { + node.className += ' leaf'; + } + if (item.fullName == athis._defaultName) + { + node.firstChild.nextSibling.className += ' currentNode'; + } + item._node = node; + return node; + } + var root = renderNode(this._root); + d.appendChild(root); + }, + + cancelEvent : function(event) + { + if (event.preventDefault) + { + event.preventDefault(); + event.stopPropagation(); + } + else + { + event.preventDefault(); + event.stopPropagation(); + } + }, + + switchAll : function(doOpen) + { + var ac = doOpen? 'open' : 'closed'; + var rc = doOpen? 'closed' : 'open'; + + var athis = this; + + function doSwitchNode(anode) + { + if (anode._children) + { + if (doOpen || anode != athis._root) + { + jgdoc.Common.removeClass(anode._node, rc); + jgdoc.Common.addClass(anode._node, ac); + } + for (var i = 0; i < anode._children.length; i++) + { + doSwitchNode(anode._children[i]); + } + } + } + doSwitchNode(this._root); + }, + + openItem : function(name) + { + this.switchAll(false); + while (name != 'GLOBAL') + { + var item = this.findItem(name); + if (item) + { + var node = item._node; + jgdoc.Common.removeClass(node, 'closed'); + jgdoc.Common.addClass(node, 'open'); + name = item.parent; + } + else + { + return; + } + } + }, + + onOpenAll : function() + { + jgdoc.NavTree.switchAll(true); + }, + + onCloseAll : function() + { + jgdoc.NavTree.switchAll(false); + } + +}; + +jgdoc._dataHandlers.push(function(data) +{ + //jgdoc.App.initialize(); + jgdoc.NavTree.setData(data); +}); diff --git a/buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeComment.php b/buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeComment.php index 99434aaa..76780fa6 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeComment.php +++ b/buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeComment.php @@ -1,44 +1,44 @@ -<?php
-/**
- * $Id: IoncubeComment.php 59 2006-04-28 14:49:47Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-/**
- * Wrapper for comments for ionCube tasks
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: IoncubeComment.php 59 2006-04-28 14:49:47Z mrook $
- * @package phing.tasks.ext.ioncube
- * @since 2.2.0
- */
-class IoncubeComment
-{
- private $value = "";
-
- public function getValue()
- {
- return $this->value;
- }
-
- public function addText($txt)
- {
- $this->value = trim($txt);
- }
-}
+<?php +/** + * $Id: IoncubeComment.php 59 2006-04-28 14:49:47Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +/** + * Wrapper for comments for ionCube tasks + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: IoncubeComment.php 59 2006-04-28 14:49:47Z mrook $ + * @package phing.tasks.ext.ioncube + * @since 2.2.0 + */ +class IoncubeComment +{ + private $value = ""; + + public function getValue() + { + return $this->value; + } + + public function addText($txt) + { + $this->value = trim($txt); + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php index 11e360e0..654d65dd 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php +++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php @@ -1,52 +1,52 @@ -<?php
-/**
- * $Id: SimpleTestCountResultFormatter.php 58 2006-04-28 14:41:04Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php';
-
-/**
- * Dummy result formatter used to count SimpleTest results
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: SimpleTestCountResultFormatter.php 58 2006-04-28 14:41:04Z mrook $
- * @package phing.tasks.ext.simpletest
- * @since 2.2.0
- */
-class SimpleTestCountResultFormatter extends SimpleTestResultFormatter
-{
- const SUCCESS = 0;
- const FAILURES = 1;
- const ERRORS = 2;
-
- function getRetCode()
- {
- if ($this->getExceptionCount() != 0)
- {
- return self::ERRORS;
- }
- else if ($this->getFailCount() != 0)
- {
- return self::FAILURES;
- }
-
- return self::SUCCESS;
- }
-}
+<?php +/** + * $Id: SimpleTestCountResultFormatter.php 58 2006-04-28 14:41:04Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; + +/** + * Dummy result formatter used to count SimpleTest results + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: SimpleTestCountResultFormatter.php 58 2006-04-28 14:41:04Z mrook $ + * @package phing.tasks.ext.simpletest + * @since 2.2.0 + */ +class SimpleTestCountResultFormatter extends SimpleTestResultFormatter +{ + const SUCCESS = 0; + const FAILURES = 1; + const ERRORS = 2; + + function getRetCode() + { + if ($this->getExceptionCount() != 0) + { + return self::ERRORS; + } + else if ($this->getFailCount() != 0) + { + return self::FAILURES; + } + + return self::SUCCESS; + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php index 82bf5776..768a041f 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php +++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php @@ -1,126 +1,126 @@ -<?php
-/**
- * $Id: SimpleTestFormatterElement.php 58 2006-04-28 14:41:04Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php';
-require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php';
-require_once 'phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php';
-
-/**
- * Child class of "FormatterElement", overrides setType to provide other
- * formatter classes for SimpleTest
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: SimpleTestFormatterElement.php 58 2006-04-28 14:41:04Z mrook $
- * @package phing.tasks.ext.simpletest
- * @since 2.2.0
- */
-class SimpleTestFormatterElement
-{
- protected $formatter = NULL;
-
- protected $type = "";
-
- protected $useFile = true;
-
- protected $toDir = ".";
-
- protected $outfile = "";
-
- function setType($type)
- {
- $this->type = $type;
-
- if ($this->type == "xml")
- {
- //$destFile = new PhingFile($this->toDir, 'testsuites.xml');
- $this->formatter = new SimpleTestXmlResultFormatter();
- }
- else
- if ($this->type == "plain")
- {
- $this->formatter = new SimpleTestPlainResultFormatter();
- }
- else
- if ($this->type == "summary")
- {
- $this->formatter = new SimpleTestSummaryResultFormatter();
- }
- else
- {
- throw new BuildException("Formatter '" . $this->type . "' not implemented");
- }
- }
-
- function setClassName($className)
- {
- $classNameNoDot = Phing::import($className);
-
- $this->formatter = new $classNameNoDot();
- }
-
- function setUseFile($useFile)
- {
- $this->useFile = $useFile;
- }
-
- function getUseFile()
- {
- return $this->useFile;
- }
-
- function setToDir($toDir)
- {
- $this->toDir = $toDir;
- }
-
- function getToDir()
- {
- return $this->toDir;
- }
-
- function setOutfile($outfile)
- {
- $this->outfile = $outfile;
- }
-
- function getOutfile()
- {
- if ($this->outfile)
- {
- return $this->outfile;
- }
- else
- {
- return $this->formatter->getPreferredOutfile() . $this->getExtension();
- }
- }
-
- function getExtension()
- {
- return $this->formatter->getExtension();
- }
-
- function getFormatter()
- {
- return $this->formatter;
- }
-}
+<?php +/** + * $Id: SimpleTestFormatterElement.php 58 2006-04-28 14:41:04Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php'; +require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php'; +require_once 'phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php'; + +/** + * Child class of "FormatterElement", overrides setType to provide other + * formatter classes for SimpleTest + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: SimpleTestFormatterElement.php 58 2006-04-28 14:41:04Z mrook $ + * @package phing.tasks.ext.simpletest + * @since 2.2.0 + */ +class SimpleTestFormatterElement +{ + protected $formatter = NULL; + + protected $type = ""; + + protected $useFile = true; + + protected $toDir = "."; + + protected $outfile = ""; + + function setType($type) + { + $this->type = $type; + + if ($this->type == "xml") + { + //$destFile = new PhingFile($this->toDir, 'testsuites.xml'); + $this->formatter = new SimpleTestXmlResultFormatter(); + } + else + if ($this->type == "plain") + { + $this->formatter = new SimpleTestPlainResultFormatter(); + } + else + if ($this->type == "summary") + { + $this->formatter = new SimpleTestSummaryResultFormatter(); + } + else + { + throw new BuildException("Formatter '" . $this->type . "' not implemented"); + } + } + + function setClassName($className) + { + $classNameNoDot = Phing::import($className); + + $this->formatter = new $classNameNoDot(); + } + + function setUseFile($useFile) + { + $this->useFile = $useFile; + } + + function getUseFile() + { + return $this->useFile; + } + + function setToDir($toDir) + { + $this->toDir = $toDir; + } + + function getToDir() + { + return $this->toDir; + } + + function setOutfile($outfile) + { + $this->outfile = $outfile; + } + + function getOutfile() + { + if ($this->outfile) + { + return $this->outfile; + } + else + { + return $this->formatter->getPreferredOutfile() . $this->getExtension(); + } + } + + function getExtension() + { + return $this->formatter->getExtension(); + } + + function getFormatter() + { + return $this->formatter; + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php index 688e2fe6..9d570486 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php +++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php @@ -1,95 +1,95 @@ -<?php
-/**
- * $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php';
-
-/**
- * Prints plain text output of the test to a specified Writer.
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
- * @package phing.tasks.ext.simpletest
- * @since 2.2.0
- */
-class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter
-{
- private $inner = "";
-
- function getExtension()
- {
- return ".txt";
- }
-
- function getPreferredOutfile()
- {
- return "testresults";
- }
-
- function paintCaseStart($test_name)
- {
- parent::paintCaseStart($test_name);
-
- $this->inner = "";
- }
-
- function paintCaseEnd($test_name)
- {
- parent::paintCaseEnd($test_name);
-
- /* Only count suites where more than one test was run */
- if ($this->getRunCount())
- {
- $sb = "Testsuite: $test_name\n";
- $sb.= "Tests run: " . $this->getRunCount();
- $sb.= ", Failures: " . $this->getFailureCount();
- $sb.= ", Errors: " . $this->getErrorCount();
- $sb.= ", Time elapsed: " . $this->getElapsedTime();
- $sb.= " sec\n";
-
- if ($this->out != NULL)
- {
- $this->out->write($sb);
- $this->out->write($this->inner);
- }
- }
- }
-
- function paintError($message)
- {
- parent::paintError($message);
-
- $this->formatError("ERROR", $message);
- }
-
- function paintFail($message)
- {
- parent::paintFail($message);
-
- $this->formatError("FAILED", $message);
- }
-
- private function formatError($type, $message)
- {
- $this->inner.= $this->getTestName() . " " . $type . "\n";
- $this->inner.= $message . "\n";
- }
-}
+<?php +/** + * $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; + +/** + * Prints plain text output of the test to a specified Writer. + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $ + * @package phing.tasks.ext.simpletest + * @since 2.2.0 + */ +class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter +{ + private $inner = ""; + + function getExtension() + { + return ".txt"; + } + + function getPreferredOutfile() + { + return "testresults"; + } + + function paintCaseStart($test_name) + { + parent::paintCaseStart($test_name); + + $this->inner = ""; + } + + function paintCaseEnd($test_name) + { + parent::paintCaseEnd($test_name); + + /* Only count suites where more than one test was run */ + if ($this->getRunCount()) + { + $sb = "Testsuite: $test_name\n"; + $sb.= "Tests run: " . $this->getRunCount(); + $sb.= ", Failures: " . $this->getFailureCount(); + $sb.= ", Errors: " . $this->getErrorCount(); + $sb.= ", Time elapsed: " . $this->getElapsedTime(); + $sb.= " sec\n"; + + if ($this->out != NULL) + { + $this->out->write($sb); + $this->out->write($this->inner); + } + } + } + + function paintError($message) + { + parent::paintError($message); + + $this->formatError("ERROR", $message); + } + + function paintFail($message) + { + parent::paintFail($message); + + $this->formatError("FAILED", $message); + } + + private function formatError($type, $message) + { + $this->inner.= $this->getTestName() . " " . $type . "\n"; + $this->inner.= $message . "\n"; + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php index 4583cf27..35077210 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php +++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php @@ -1,162 +1,162 @@ -<?php
-/**
- * $Id: SimpleTestResultFormatter.php 58 2006-04-28 14:41:04Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-//require_once 'simpletest/scorer.php';
-
-require_once 'phing/system/io/Writer.php';
-
-/**
- * This abstract class describes classes that format the results of a SimpleTest testrun.
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: SimpleTestResultFormatter.php 58 2006-04-28 14:41:04Z mrook $
- * @package phing.tasks.ext.phpunit2
- * @since 2.2.0
- */
-abstract class SimpleTestResultFormatter extends SimpleReporter
-{
- protected $out = NULL;
-
- protected $project = NULL;
-
- private $timer = NULL;
-
- private $runCount = 0;
-
- private $failureCount = 0;
-
- private $errorCount = 0;
-
- private $currentTest = "";
-
- /**
- * Sets the writer the formatter is supposed to write its results to.
- */
- function setOutput(Writer $out)
- {
- $this->out = $out;
- }
-
- /**
- * Returns the extension used for this formatter
- *
- * @return string the extension
- */
- function getExtension()
- {
- return "";
- }
-
- /**
- * Sets the project
- *
- * @param Project the project
- */
- function setProject(Project $project)
- {
- $this->project = $project;
- }
-
- function getPreferredOutfile()
- {
- return "";
- }
-
- function paintMethodStart($test_name)
- {
- parent::paintMethodStart($test_name);
-
- $this->currentTest = $test_name;
- }
-
- function paintMethodEnd($test_name)
- {
- parent::paintMethodEnd($test_name);
-
- $this->runCount++;
- }
-
- function paintCaseStart($test_name)
- {
- parent::paintCaseStart($test_name);
-
- $this->runCount = 0;
- $this->failureCount = 0;
- $this->errorCount = 0;
-
- $this->timer = new Timer();
- $this->timer->start();
- }
-
- function paintCaseEnd($test_name)
- {
- parent::paintCaseEnd($test_name);
-
- $this->timer->stop();
- }
-
- function paintError($message)
- {
- parent::paintError($message);
-
- $this->errorCount++;
- }
-
- function paintFail($message)
- {
- parent::paintFail($message);
-
- $this->failureCount++;
- }
-
- function getRunCount()
- {
- return $this->runCount;
- }
-
- function getFailureCount()
- {
- return $this->failureCount;
- }
-
- function getErrorCount()
- {
- return $this->errorCount;
- }
-
- function getTestName()
- {
- return $this->currentTest;
- }
-
- function getElapsedTime()
- {
- if ($this->timer)
- {
- return $this->timer->getElapsedTime();
- }
- else
- {
- return 0;
- }
- }
-}
+<?php +/** + * $Id: SimpleTestResultFormatter.php 58 2006-04-28 14:41:04Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +//require_once 'simpletest/scorer.php'; + +require_once 'phing/system/io/Writer.php'; + +/** + * This abstract class describes classes that format the results of a SimpleTest testrun. + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: SimpleTestResultFormatter.php 58 2006-04-28 14:41:04Z mrook $ + * @package phing.tasks.ext.phpunit2 + * @since 2.2.0 + */ +abstract class SimpleTestResultFormatter extends SimpleReporter +{ + protected $out = NULL; + + protected $project = NULL; + + private $timer = NULL; + + private $runCount = 0; + + private $failureCount = 0; + + private $errorCount = 0; + + private $currentTest = ""; + + /** + * Sets the writer the formatter is supposed to write its results to. + */ + function setOutput(Writer $out) + { + $this->out = $out; + } + + /** + * Returns the extension used for this formatter + * + * @return string the extension + */ + function getExtension() + { + return ""; + } + + /** + * Sets the project + * + * @param Project the project + */ + function setProject(Project $project) + { + $this->project = $project; + } + + function getPreferredOutfile() + { + return ""; + } + + function paintMethodStart($test_name) + { + parent::paintMethodStart($test_name); + + $this->currentTest = $test_name; + } + + function paintMethodEnd($test_name) + { + parent::paintMethodEnd($test_name); + + $this->runCount++; + } + + function paintCaseStart($test_name) + { + parent::paintCaseStart($test_name); + + $this->runCount = 0; + $this->failureCount = 0; + $this->errorCount = 0; + + $this->timer = new Timer(); + $this->timer->start(); + } + + function paintCaseEnd($test_name) + { + parent::paintCaseEnd($test_name); + + $this->timer->stop(); + } + + function paintError($message) + { + parent::paintError($message); + + $this->errorCount++; + } + + function paintFail($message) + { + parent::paintFail($message); + + $this->failureCount++; + } + + function getRunCount() + { + return $this->runCount; + } + + function getFailureCount() + { + return $this->failureCount; + } + + function getErrorCount() + { + return $this->errorCount; + } + + function getTestName() + { + return $this->currentTest; + } + + function getElapsedTime() + { + if ($this->timer) + { + return $this->timer->getElapsedTime(); + } + else + { + return 0; + } + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php index bd691374..a2fafb0a 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php +++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php @@ -1,54 +1,54 @@ -<?php
-/**
- * $Id: SimpleTestSummaryResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php';
-
-/**
- * Prints short summary output of the test to Phing's logging system.
- *
- * @author Michiel Rook <michiel@trendserver.nl>
- * @version $Id: SimpleTestSummaryResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
- * @package phing.tasks.ext.simpletest
- * @since 2.2.0
- */
-class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter
-{
- function paintCaseEnd($test_name)
- {
- parent::paintCaseEnd($test_name);
-
- /* Only count suites where more than one test was run */
- if ($this->getRunCount())
- {
- $sb= "Tests run: " . $this->getRunCount();
- $sb.= ", Failures: " . $this->getFailureCount();
- $sb.= ", Errors: " . $this->getErrorCount();
- $sb.= ", Time elapsed: " . $this->getElapsedTime();
- $sb.= " sec\n";
-
- if ($this->out != NULL)
- {
- $this->out->write($sb);
- }
- }
- }
-}
+<?php +/** + * $Id: SimpleTestSummaryResultFormatter.php 59 2006-04-28 14:49:47Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; + +/** + * Prints short summary output of the test to Phing's logging system. + * + * @author Michiel Rook <michiel@trendserver.nl> + * @version $Id: SimpleTestSummaryResultFormatter.php 59 2006-04-28 14:49:47Z mrook $ + * @package phing.tasks.ext.simpletest + * @since 2.2.0 + */ +class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter +{ + function paintCaseEnd($test_name) + { + parent::paintCaseEnd($test_name); + + /* Only count suites where more than one test was run */ + if ($this->getRunCount()) + { + $sb= "Tests run: " . $this->getRunCount(); + $sb.= ", Failures: " . $this->getFailureCount(); + $sb.= ", Errors: " . $this->getErrorCount(); + $sb.= ", Time elapsed: " . $this->getElapsedTime(); + $sb.= " sec\n"; + + if ($this->out != NULL) + { + $this->out->write($sb); + } + } + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php b/buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php index 71e3ba2e..55c695cf 100644 --- a/buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php +++ b/buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php @@ -1,180 +1,180 @@ -<?php
-/*
- * $Id: SvnBaseTask.php 38 2006-03-09 14:05:11Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-include_once 'phing/Task.php';
-
-/**
- * Send a message by mail()
- *
- * <mail to="user@example.org" subject="build complete">The build process is a success...</mail>
- *
- * @author Francois Harvey at SecuriWeb (http://www.securiweb.net)
- * @version $Id: SvnBaseTask.php 38 2006-03-09 14:05:11Z mrook $
- * @package phing.tasks.ext
- */
-abstract class SvnBaseTask extends Task
-{
- private $workingCopy = "";
-
- private $repositoryUrl = "";
-
- private $svnPath = "/usr/bin/svn";
-
- private $svn = NULL;
-
- private $mode = "";
-
- private $svnArgs = array();
-
- /**
- * Initialize Task.
- * This method includes any necessary SVN libraries and triggers
- * appropriate error if they cannot be found. This is not done in header
- * because we may want this class to be loaded w/o triggering an error.
- */
- function init() {
- include_once 'VersionControl/SVN.php';
- if (!class_exists('VersionControl_SVN')) {
- throw new Exception("SvnLastRevisionTask depends on PEAR VersionControl_SVN package being installed.");
- }
- }
-
- /**
- * Sets the path to the workingcopy
- */
- function setWorkingCopy($workingCopy)
- {
- $this->workingCopy = $workingCopy;
- }
-
- /**
- * Returns the path to the workingcopy
- */
- function getWorkingCopy()
- {
- return $this->workingCopy;
- }
-
- /**
- * Sets the path/URI to the repository
- */
- function setRepositoryUrl($repositoryUrl)
- {
- $this->repositoryUrl = $repositoryUrl;
- }
-
- /**
- * Returns the path/URI to the repository
- */
- function getRepositoryUrl()
- {
- return $this->repositoryUrl;
- }
-
- /**
- * Sets the path to the SVN executable
- */
- function setSvnPath($svnPath)
- {
- $this->svnPath = $svnPath;
- }
-
- /**
- * Returns the path to the SVN executable
- */
- function getSvnPath()
- {
- return $this->svnPath;
- }
-
- /**
- * Creates a VersionControl_SVN class based on $mode
- *
- * @param string The SVN mode to use (info, export, checkout, ...)
- * @throws BuildException
- */
- protected function setup($mode)
- {
- $this->mode = $mode;
-
- // Set up runtime options. Will be passed to all
- // subclasses.
- $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC, 'svn_path' => $this->getSvnPath());
-
- // Pass array of subcommands we need to factory
- $this->svn = VersionControl_SVN::factory($mode, $options);
-
- if (!empty($this->repositoryUrl))
- {
- $this->svnArgs = array($this->repositoryUrl);
- }
- else
- if (!empty($this->workingCopy))
- {
- if (is_dir($this->workingCopy))
- {
- if (in_array(".svn", scandir($this->workingCopy)))
- {
- $this->svnArgs = array($this->workingCopy);
- }
- else
- {
- throw new BuildException("'".$this->workingCopy."' doesn't seem to be a working copy");
- }
- }
- else
- {
- throw new BuildException("'".$this->workingCopy."' is not a directory");
- }
- }
- }
-
- /**
- * Executes the constructed VersionControl_SVN instance
- *
- * @param array Additional arguments to pass to SVN.
- * @param array Switches to pass to SVN.
- * @return string Output generated by SVN.
- */
- protected function run($args = array(), $switches = array())
- {
- $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN');
-
- $tempArgs = $this->svnArgs;
-
- $tempArgs = array_merge($tempArgs, $args);
-
- if ($output = $this->svn->run($tempArgs, $switches))
- {
- return $output;
- }
- else
- {
- if (count($errs = $svnstack->getErrors()))
- {
- $err = current($errs);
-
- throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['message']);
- }
- }
- }
-}
+<?php +/* + * $Id: SvnBaseTask.php 38 2006-03-09 14:05:11Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +include_once 'phing/Task.php'; + +/** + * Send a message by mail() + * + * <mail to="user@example.org" subject="build complete">The build process is a success...</mail> + * + * @author Francois Harvey at SecuriWeb (http://www.securiweb.net) + * @version $Id: SvnBaseTask.php 38 2006-03-09 14:05:11Z mrook $ + * @package phing.tasks.ext + */ +abstract class SvnBaseTask extends Task +{ + private $workingCopy = ""; + + private $repositoryUrl = ""; + + private $svnPath = "/usr/bin/svn"; + + private $svn = NULL; + + private $mode = ""; + + private $svnArgs = array(); + + /** + * Initialize Task. + * This method includes any necessary SVN libraries and triggers + * appropriate error if they cannot be found. This is not done in header + * because we may want this class to be loaded w/o triggering an error. + */ + function init() { + include_once 'VersionControl/SVN.php'; + if (!class_exists('VersionControl_SVN')) { + throw new Exception("SvnLastRevisionTask depends on PEAR VersionControl_SVN package being installed."); + } + } + + /** + * Sets the path to the workingcopy + */ + function setWorkingCopy($workingCopy) + { + $this->workingCopy = $workingCopy; + } + + /** + * Returns the path to the workingcopy + */ + function getWorkingCopy() + { + return $this->workingCopy; + } + + /** + * Sets the path/URI to the repository + */ + function setRepositoryUrl($repositoryUrl) + { + $this->repositoryUrl = $repositoryUrl; + } + + /** + * Returns the path/URI to the repository + */ + function getRepositoryUrl() + { + return $this->repositoryUrl; + } + + /** + * Sets the path to the SVN executable + */ + function setSvnPath($svnPath) + { + $this->svnPath = $svnPath; + } + + /** + * Returns the path to the SVN executable + */ + function getSvnPath() + { + return $this->svnPath; + } + + /** + * Creates a VersionControl_SVN class based on $mode + * + * @param string The SVN mode to use (info, export, checkout, ...) + * @throws BuildException + */ + protected function setup($mode) + { + $this->mode = $mode; + + // Set up runtime options. Will be passed to all + // subclasses. + $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC, 'svn_path' => $this->getSvnPath()); + + // Pass array of subcommands we need to factory + $this->svn = VersionControl_SVN::factory($mode, $options); + + if (!empty($this->repositoryUrl)) + { + $this->svnArgs = array($this->repositoryUrl); + } + else + if (!empty($this->workingCopy)) + { + if (is_dir($this->workingCopy)) + { + if (in_array(".svn", scandir($this->workingCopy))) + { + $this->svnArgs = array($this->workingCopy); + } + else + { + throw new BuildException("'".$this->workingCopy."' doesn't seem to be a working copy"); + } + } + else + { + throw new BuildException("'".$this->workingCopy."' is not a directory"); + } + } + } + + /** + * Executes the constructed VersionControl_SVN instance + * + * @param array Additional arguments to pass to SVN. + * @param array Switches to pass to SVN. + * @return string Output generated by SVN. + */ + protected function run($args = array(), $switches = array()) + { + $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN'); + + $tempArgs = $this->svnArgs; + + $tempArgs = array_merge($tempArgs, $args); + + if ($output = $this->svn->run($tempArgs, $switches)) + { + return $output; + } + else + { + if (count($errs = $svnstack->getErrors())) + { + $err = current($errs); + + throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['message']); + } + } + } +} ?>
\ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php b/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php index 04c1cbbd..09324fb8 100644 --- a/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php +++ b/buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php @@ -1,52 +1,52 @@ -<?php
-/*
- * $Id: ReferenceExistsCondition.php 59 2006-04-28 14:49:47Z mrook $
- *
- * 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, STRICT 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/ProjectComponent.php'; require_once 'phing/tasks/system/condition/Condition.php';
-
-/**
- * Condition that tests whether a given reference exists.
- *
- * @author Matthias Pigulla <mp@webfactory.de> (Phing)
- * @version $Revision: 1.1 $
- * @package phing.tasks.system.condition */
-class ReferenceExistsCondition extends ProjectComponent implements Condition {
-
- private $refid;
-
- public function setRef($id) {
- $this->refid = (string) $id;
- }
-
- /**
- * Check whether the reference exists.
- * @throws BuildException
- */
- public function evaluate() {
- if ($this->refid === null) {
- throw new BuildException("No ref attribute specified for reference-exists "
- . "condition");
- }
- $refs = $this->project->getReferences();
- return isset($refs[$this->refid]);
- }
-
-}
-
+<?php +/* + * $Id: ReferenceExistsCondition.php 59 2006-04-28 14:49:47Z mrook $ + * + * 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, STRICT 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. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the LGPL. For more information please see + * <http://phing.info>. + */ + +require_once 'phing/ProjectComponent.php'; require_once 'phing/tasks/system/condition/Condition.php'; + +/** + * Condition that tests whether a given reference exists. + * + * @author Matthias Pigulla <mp@webfactory.de> (Phing) + * @version $Revision: 1.1 $ + * @package phing.tasks.system.condition */ +class ReferenceExistsCondition extends ProjectComponent implements Condition { + + private $refid; + + public function setRef($id) { + $this->refid = (string) $id; + } + + /** + * Check whether the reference exists. + * @throws BuildException + */ + public function evaluate() { + if ($this->refid === null) { + throw new BuildException("No ref attribute specified for reference-exists " + . "condition"); + } + $refs = $this->project->getReferences(); + return isset($refs[$this->refid]); + } + +} + diff --git a/buildscripts/phing/tasks/ManualIndexTask.php b/buildscripts/phing/tasks/ManualIndexTask.php index 1725880f..c689d4c5 100644 --- a/buildscripts/phing/tasks/ManualIndexTask.php +++ b/buildscripts/phing/tasks/ManualIndexTask.php @@ -1,38 +1,38 @@ -<?php
-
-require_once 'phing/Task.php';
-
-/**
- * Task to index PRADO API docs.
- */
-class ManualIndexTask extends Task
-{
- private $docdir;
- private $todir;
-
- /**
- * @param string the API documentation directory
- */
- public function setDocdir($value)
- {
- $this->docdir=$value;
- }
-
- public function setTodir($value)
- {
- $this->todir=$value;
- }
-
- public function main()
- {
- $srcdir=realpath(dirname(__FILE__).'/../../../');
- $zend_path = $srcdir.'/demos/quickstart/protected/index';
- set_include_path(get_include_path().PATH_SEPARATOR.realpath($zend_path));
- require_once ('Zend/Search/Lucene.php');
- require_once($srcdir.'/buildscripts/index/api_index.php');
- $api = new api_index($this->todir, realpath($this->docdir));
- $api->create_index();
- }
-}
-
+<?php + +require_once 'phing/Task.php'; + +/** + * Task to index PRADO API docs. + */ +class ManualIndexTask extends Task +{ + private $docdir; + private $todir; + + /** + * @param string the API documentation directory + */ + public function setDocdir($value) + { + $this->docdir=$value; + } + + public function setTodir($value) + { + $this->todir=$value; + } + + public function main() + { + $srcdir=realpath(dirname(__FILE__).'/../../../'); + $zend_path = $srcdir.'/demos/quickstart/protected/index'; + set_include_path(get_include_path().PATH_SEPARATOR.realpath($zend_path)); + require_once ('Zend/Search/Lucene.php'); + require_once($srcdir.'/buildscripts/index/api_index.php'); + $api = new api_index($this->todir, realpath($this->docdir)); + $api->create_index(); + } +} + ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/PradoDocTask.php b/buildscripts/phing/tasks/PradoDocTask.php index ac64ac5a..944fde82 100644 --- a/buildscripts/phing/tasks/PradoDocTask.php +++ b/buildscripts/phing/tasks/PradoDocTask.php @@ -1,149 +1,149 @@ -<?php
-require_once 'phing/Task.php';
-
-/**
- * Task to run phpDocumentor for PRADO API docs.
- */
-class PradoDocTask extends Task
-{
- private $phpdoc = 'phpdoc';
-
- private $title = "Default Title";
-
- private $destdir = ".";
-
- private $sourcepath = NULL;
-
- private $ignorelist = '';
-
- private $output = "";
-
- private $linksource = false;
-
- private $parseprivate = false;
-
- private $quite = false;
-
- function setPhpdoc($phpdoc)
- {
- $this->phpdoc=$phpdoc;
- }
-
- function setQuite($quite)
- {
- $this->quite=$quite;
- }
-
- /**
- * Set the title for the generated documentation
- */
- function setTitle($title)
- {
- $this->title = $title;
- }
-
- /**
- * Set the destination directory for the generated documentation
- */
- function setDestdir($destdir)
- {
- $this->destdir = $destdir;
- }
-
- /**
- * Set the source path
- */
- function setSourcepath(Path $sourcepath)
- {
- if ($this->sourcepath === NULL)
- {
- $this->sourcepath = $sourcepath;
- }
- else
- {
- $this->sourcepath->append($sourcepath);
- }
- }
-
- /**
- * Set the output type
- */
- function setOutput($output)
- {
- $this->output = $output;
- }
-
- /**
- * Should sources be linked in the generated documentation
- */
- function setLinksource($linksource)
- {
- $this->linksource = $linksource;
- }
-
- function setIgnorelist($ignorelist)
- {
- $this->ignorelist=$ignorelist;
- }
-
- /**
- * Main entrypoint of the task
- */
- function main()
- {
- $arguments = $this->constructArguments();
- passthru($this->phpdoc . " " . $arguments, $retval);
- }
-
- /**
- * Constructs an argument string for phpDocumentor
- */
- private function constructArguments()
- {
- $arguments = " ";
-
- if($this->quite)
- {
- $arguments .= '-q "on" ';
- }
-
- if ($this->title)
- {
- $arguments.= "-ti \"" . $this->title . "\" ";
- }
-
- if ($this->destdir)
- {
- $arguments.= "-t \"" . $this->destdir . "\" ";
- }
-
- if ($this->sourcepath !== NULL)
- {
- $arguments.= "-d \"" . $this->sourcepath->__toString() . "\" ";
- }
-
- if ($this->output)
- {
- $arguments.= "-o \"" . $this->output . "\" ";
- }
-
- if ($this->linksource)
- {
- $arguments.= "-s ";
- }
-
- if ($this->parseprivate)
- {
- $arguments.= "-pp ";
- }
-
- if ($this->ignorelist)
- {
- $arguments.='-i "'.$this->ignorelist.'" ';
- }
-
- return $arguments;
- }
-}
-
+<?php +require_once 'phing/Task.php'; + +/** + * Task to run phpDocumentor for PRADO API docs. + */ +class PradoDocTask extends Task +{ + private $phpdoc = 'phpdoc'; + + private $title = "Default Title"; + + private $destdir = "."; + + private $sourcepath = NULL; + + private $ignorelist = ''; + + private $output = ""; + + private $linksource = false; + + private $parseprivate = false; + + private $quite = false; + + function setPhpdoc($phpdoc) + { + $this->phpdoc=$phpdoc; + } + + function setQuite($quite) + { + $this->quite=$quite; + } + + /** + * Set the title for the generated documentation + */ + function setTitle($title) + { + $this->title = $title; + } + + /** + * Set the destination directory for the generated documentation + */ + function setDestdir($destdir) + { + $this->destdir = $destdir; + } + + /** + * Set the source path + */ + function setSourcepath(Path $sourcepath) + { + if ($this->sourcepath === NULL) + { + $this->sourcepath = $sourcepath; + } + else + { + $this->sourcepath->append($sourcepath); + } + } + + /** + * Set the output type + */ + function setOutput($output) + { + $this->output = $output; + } + + /** + * Should sources be linked in the generated documentation + */ + function setLinksource($linksource) + { + $this->linksource = $linksource; + } + + function setIgnorelist($ignorelist) + { + $this->ignorelist=$ignorelist; + } + + /** + * Main entrypoint of the task + */ + function main() + { + $arguments = $this->constructArguments(); + passthru($this->phpdoc . " " . $arguments, $retval); + } + + /** + * Constructs an argument string for phpDocumentor + */ + private function constructArguments() + { + $arguments = " "; + + if($this->quite) + { + $arguments .= '-q "on" '; + } + + if ($this->title) + { + $arguments.= "-ti \"" . $this->title . "\" "; + } + + if ($this->destdir) + { + $arguments.= "-t \"" . $this->destdir . "\" "; + } + + if ($this->sourcepath !== NULL) + { + $arguments.= "-d \"" . $this->sourcepath->__toString() . "\" "; + } + + if ($this->output) + { + $arguments.= "-o \"" . $this->output . "\" "; + } + + if ($this->linksource) + { + $arguments.= "-s "; + } + + if ($this->parseprivate) + { + $arguments.= "-pp "; + } + + if ($this->ignorelist) + { + $arguments.='-i "'.$this->ignorelist.'" '; + } + + return $arguments; + } +} + ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/PradoPackageTask.php b/buildscripts/phing/tasks/PradoPackageTask.php index e54a4093..61031206 100644 --- a/buildscripts/phing/tasks/PradoPackageTask.php +++ b/buildscripts/phing/tasks/PradoPackageTask.php @@ -1,142 +1,142 @@ -<?php
-require_once 'phing/Task.php';
-
-/**
- * Task to run phpDocumentor for PRADO API docs.
- */
-class PradoPackageTask extends Task
-{
- protected $filelists = array();
- protected $output;
- protected $strip=false;
-
- function setOutput(PhingFile $file)
- {
- $this->output=$file;
- }
-
- function setStrip($value)
- {
- $this->strip = (boolean)$value;
- }
-
- /**
- * Supports embedded <filelist> element.
- * @return FileList
- */
- function createFileList() {
- $num = array_push($this->filelists, new FileList());
- return $this->filelists[$num-1];
- }
-
- function main()
- {
- $project = $this->getProject();
-
- $content = '';
- $files=array();
- // append the files in the filelists
- foreach($this->filelists as $fl)
- {
- $fromDir = $fl->getDir($project);
- foreach($fl->getFiles($project) as $file)
- {
- $src = new PhingFile($fromDir,$file);
- $files[] = $file;
- $content .= file_get_contents($src->getAbsolutePath());
- }
- }
-
- $content = $this->processPhp($content,$files);
- file_put_contents($this->output->getAbsolutePath(), $content);
- }
-
- function processPhp($content,$files)
- {
- $content = preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content);
- $content = preg_replace('/(PradoBase::using|Prado::using|require_once|include_once)\s*\([^\$].*?\);/mu','',$content);
- $content = str_replace('Prado::', 'PradoBase::', $content);
- $content = str_replace('PradoBase::getApplication()->getMode()', 'true', $content);
- $content = str_replace('TApplicationMode::Debug', 'true', $content);
- $content = str_replace('/Exceptions/messages', '/messages', $content);
- if($this->strip)
- $content=$this->strip_comments($content);
- $content=$this->strip_empty_lines($content);
- $content="<?php".$this->getFileComment($files).preg_replace('/(\?>\s?|<\?php\s?)/mu','',$content)."\n?>";
- return $content;
- }
-
-function strip_comments($source)
-{
- $tokens = token_get_all($source);
- /* T_ML_COMMENT does not exist in PHP 5.
- * The following three lines define it in order to
- * preserve backwards compatibility.
- *
- * The next two lines define the PHP 5-only T_DOC_COMMENT,
- * which we will mask as T_ML_COMMENT for PHP 4.
- */
- if (!defined('T_ML_COMMENT')) {
- @define('T_ML_COMMENT', T_COMMENT);
- } else {
- @define('T_DOC_COMMENT', T_ML_COMMENT);
- }
- $output = '';
- foreach ($tokens as $token) {
- if (is_string($token)) {
- // simple 1-character token
- $output .= $token;
- } else {
- // token array
- list($id, $text) = $token;
- switch ($id) {
- case T_COMMENT:
- case T_ML_COMMENT: // we've defined this
- case T_DOC_COMMENT: // and this
- // no action on comments
- break;
- default:
- // anything else -> output "as is"
- $output .= $text;
- break;
- }
- }
- }
- return $output;
-}
-
-function strip_empty_lines($string)
-{
- $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string);
- $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string);
- return $string;
-}
-function getFileComment($files)
-{
- $lastupdate=date('Y/m/d H:i:s');
- $year=date('Y');
- $fileList=array();
- foreach($files as $file)
- $fileList[] = " * $file";
- $fileListStr = implode("\n", $fileList);
-$comments="
-/**
- * Last Update: $lastupdate
- *
- * Do not modify this file manually. This file was auto-generated by combining
- * the following classes from the Prado framework.
- *
- * Files:
-{$fileListStr}
- *
- * @author Qiang Xue <qiang.xue@gmail.com>, Wei Zhuo <weizhuo@gmail.com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-{$year} PradoSoft
- * @license http://www.pradosoft.com/license/
- */
-
-";
- return $comments;
-}
+<?php +require_once 'phing/Task.php'; + +/** + * Task to run phpDocumentor for PRADO API docs. + */ +class PradoPackageTask extends Task +{ + protected $filelists = array(); + protected $output; + protected $strip=false; + + function setOutput(PhingFile $file) + { + $this->output=$file; + } + + function setStrip($value) + { + $this->strip = (boolean)$value; + } + + /** + * Supports embedded <filelist> element. + * @return FileList + */ + function createFileList() { + $num = array_push($this->filelists, new FileList()); + return $this->filelists[$num-1]; + } + + function main() + { + $project = $this->getProject(); + + $content = ''; + $files=array(); + // append the files in the filelists + foreach($this->filelists as $fl) + { + $fromDir = $fl->getDir($project); + foreach($fl->getFiles($project) as $file) + { + $src = new PhingFile($fromDir,$file); + $files[] = $file; + $content .= file_get_contents($src->getAbsolutePath()); + } + } + + $content = $this->processPhp($content,$files); + file_put_contents($this->output->getAbsolutePath(), $content); + } + + function processPhp($content,$files) + { + $content = preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content); + $content = preg_replace('/(PradoBase::using|Prado::using|require_once|include_once)\s*\([^\$].*?\);/mu','',$content); + $content = str_replace('Prado::', 'PradoBase::', $content); + $content = str_replace('PradoBase::getApplication()->getMode()', 'true', $content); + $content = str_replace('TApplicationMode::Debug', 'true', $content); + $content = str_replace('/Exceptions/messages', '/messages', $content); + if($this->strip) + $content=$this->strip_comments($content); + $content=$this->strip_empty_lines($content); + $content="<?php".$this->getFileComment($files).preg_replace('/(\?>\s?|<\?php\s?)/mu','',$content)."\n?>"; + return $content; + } + +function strip_comments($source) +{ + $tokens = token_get_all($source); + /* T_ML_COMMENT does not exist in PHP 5. + * The following three lines define it in order to + * preserve backwards compatibility. + * + * The next two lines define the PHP 5-only T_DOC_COMMENT, + * which we will mask as T_ML_COMMENT for PHP 4. + */ + if (!defined('T_ML_COMMENT')) { + @define('T_ML_COMMENT', T_COMMENT); + } else { + @define('T_DOC_COMMENT', T_ML_COMMENT); + } + $output = ''; + foreach ($tokens as $token) { + if (is_string($token)) { + // simple 1-character token + $output .= $token; + } else { + // token array + list($id, $text) = $token; + switch ($id) { + case T_COMMENT: + case T_ML_COMMENT: // we've defined this + case T_DOC_COMMENT: // and this + // no action on comments + break; + default: + // anything else -> output "as is" + $output .= $text; + break; + } + } + } + return $output; +} + +function strip_empty_lines($string) +{ + $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string); + $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string); + return $string; +} +function getFileComment($files) +{ + $lastupdate=date('Y/m/d H:i:s'); + $year=date('Y'); + $fileList=array(); + foreach($files as $file) + $fileList[] = " * $file"; + $fileListStr = implode("\n", $fileList); +$comments=" +/** + * Last Update: $lastupdate + * + * Do not modify this file manually. This file was auto-generated by combining + * the following classes from the Prado framework. + * + * Files: +{$fileListStr} + * + * @author Qiang Xue <qiang.xue@gmail.com>, Wei Zhuo <weizhuo@gmail.com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-{$year} PradoSoft + * @license http://www.pradosoft.com/license/ + */ + +"; + return $comments; +} } ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/PradoQuickStartDocs.php b/buildscripts/phing/tasks/PradoQuickStartDocs.php index 06c30a14..1cbc5140 100644 --- a/buildscripts/phing/tasks/PradoQuickStartDocs.php +++ b/buildscripts/phing/tasks/PradoQuickStartDocs.php @@ -1,85 +1,85 @@ -<?php
-require_once 'phing/Task.php';
-
-require_once(dirname(__FILE__).'/../../chmbuilder/ChmQuickstartBuilder.php');
-include(dirname(__FILE__).'/../../../framework/PradoBase.php');
-class Prado extends PradoBase
-{
- protected static $app;
-
- public static function setApplication($application)
- {
- self::$app=$application;
- }
-
- public static function getApplication()
- {
- return self::$app;
- }
-
- public static function setPathOfAlias($alias,$path)
- {
- $aliases = self::getPathAliases();
- if(!isset($aliases[$alias]))
- parent::setPathOfAlias($alias,$path);
- }
-}
-
-include(dirname(__FILE__).'/../../../framework/prado.php');
-
-/**
- * Task to run phpDocumentor for PRADO API docs.
- */
-class PradoQuickStartDocs extends Task
-{
- private $base_dir;
-
- private $destdir;
-
- private $page;
-
- /**
- * Set the destination directory for the generated documentation
- */
- function setOutput(PhingFile $destdir)
- {
- $this->destdir = $destdir;
- }
-
- function setPages($page)
- {
- $this->page = $page;
- }
-
- /**
- * Main entrypoint of the task
- */
- function main()
- {
- $output = $this->destdir->getAbsolutePath();
- $base = dirname(__FILE__).'/../../../demos/quickstart/protected/';
- error_reporting(0);
- $quickstart= new ChmQuickstartBuilder($base,$output);
-
- foreach(preg_split('/\s*[, ]+\s*/', $this->page) as $page)
- {
- $file = str_replace(array('/','.page'), array('_','.html'),$page);
- $this->log("Parsing $page");
- file_put_contents($output.'/'.$file, $this->parsePage($quickstart,$page));
- $this->log("Writing $file");
- }
- }
-
- protected function parsePage($quickstart, $page)
- {
- $_GET['page'] = str_replace(array('/','.page'),array('.',''),$page);
- $_GET['notheme'] = 'true';
- $content = $quickstart->parseHtmlContent($quickstart->getApplicationContent());
- //hide prado specific content
- $content = str_replace('<body>', '<style type="text/css">.prado-specific {display:none;}</style><body>', $content);
- return $content;
- }
-
-}
-
+<?php +require_once 'phing/Task.php'; + +require_once(dirname(__FILE__).'/../../chmbuilder/ChmQuickstartBuilder.php'); +include(dirname(__FILE__).'/../../../framework/PradoBase.php'); +class Prado extends PradoBase +{ + protected static $app; + + public static function setApplication($application) + { + self::$app=$application; + } + + public static function getApplication() + { + return self::$app; + } + + public static function setPathOfAlias($alias,$path) + { + $aliases = self::getPathAliases(); + if(!isset($aliases[$alias])) + parent::setPathOfAlias($alias,$path); + } +} + +include(dirname(__FILE__).'/../../../framework/prado.php'); + +/** + * Task to run phpDocumentor for PRADO API docs. + */ +class PradoQuickStartDocs extends Task +{ + private $base_dir; + + private $destdir; + + private $page; + + /** + * Set the destination directory for the generated documentation + */ + function setOutput(PhingFile $destdir) + { + $this->destdir = $destdir; + } + + function setPages($page) + { + $this->page = $page; + } + + /** + * Main entrypoint of the task + */ + function main() + { + $output = $this->destdir->getAbsolutePath(); + $base = dirname(__FILE__).'/../../../demos/quickstart/protected/'; + error_reporting(0); + $quickstart= new ChmQuickstartBuilder($base,$output); + + foreach(preg_split('/\s*[, ]+\s*/', $this->page) as $page) + { + $file = str_replace(array('/','.page'), array('_','.html'),$page); + $this->log("Parsing $page"); + file_put_contents($output.'/'.$file, $this->parsePage($quickstart,$page)); + $this->log("Writing $file"); + } + } + + protected function parsePage($quickstart, $page) + { + $_GET['page'] = str_replace(array('/','.page'),array('.',''),$page); + $_GET['notheme'] = 'true'; + $content = $quickstart->parseHtmlContent($quickstart->getApplicationContent()); + //hide prado specific content + $content = str_replace('<body>', '<style type="text/css">.prado-specific {display:none;}</style><body>', $content); + return $content; + } + +} + ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/PradoSimpleTestTask.php b/buildscripts/phing/tasks/PradoSimpleTestTask.php index 4d6317b5..91e6e22f 100644 --- a/buildscripts/phing/tasks/PradoSimpleTestTask.php +++ b/buildscripts/phing/tasks/PradoSimpleTestTask.php @@ -1,40 +1,40 @@ -<?php
-require_once 'phing/Task.php';
-require_once 'phing/tasks/ext/simpletest/SimpleTestTask.php';
-
-/**
- * Task to run PRADO unit tests
- */
-class PradoSimpleTestTask extends SimpleTestTask
-{
- private $_appdir;
-
- public function setAppdir($value)
- {
- $this->_appdir=$value;
- }
-
- function init()
- {
- $tools= realpath(dirname(__FILE__).'/../../../tests/test_tools/');
- include_once "$tools/unit_tests.php";
-
- if (!class_exists('SimpleReporter',false))
- throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation());
-
- require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php';
- require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php';
- }
-
- function main()
- {
- if($this->_appdir)
- {
- $app = new TShellApplication($this->_appdir);
- $app->run();
- }
- parent::main();
- }
-}
-
+<?php +require_once 'phing/Task.php'; +require_once 'phing/tasks/ext/simpletest/SimpleTestTask.php'; + +/** + * Task to run PRADO unit tests + */ +class PradoSimpleTestTask extends SimpleTestTask +{ + private $_appdir; + + public function setAppdir($value) + { + $this->_appdir=$value; + } + + function init() + { + $tools= realpath(dirname(__FILE__).'/../../../tests/test_tools/'); + include_once "$tools/unit_tests.php"; + + if (!class_exists('SimpleReporter',false)) + throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation()); + + require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php'; + require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php'; + } + + function main() + { + if($this->_appdir) + { + $app = new TShellApplication($this->_appdir); + $app->run(); + } + parent::main(); + } +} + ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/PradoTestTask.php b/buildscripts/phing/tasks/PradoTestTask.php index ba1e06be..cd2c87f8 100644 --- a/buildscripts/phing/tasks/PradoTestTask.php +++ b/buildscripts/phing/tasks/PradoTestTask.php @@ -1,18 +1,18 @@ -<?php
-require_once 'phing/Task.php';
-require_once 'phing/tasks/ext/phpunit2/PHPUnit2Task.php';
-
-/**
- * Task to run PRADO unit tests
- */
-class PradoTestTask extends PHPUnit2Task
-{
- function init()
- {
- $phpunit2_path = realpath(dirname(__FILE__).'/../..');
- set_include_path(get_include_path().PATH_SEPARATOR.$phpunit2_path);
- parent::init();
- }
-}
-
+<?php +require_once 'phing/Task.php'; +require_once 'phing/tasks/ext/phpunit2/PHPUnit2Task.php'; + +/** + * Task to run PRADO unit tests + */ +class PradoTestTask extends PHPUnit2Task +{ + function init() + { + $phpunit2_path = realpath(dirname(__FILE__).'/../..'); + set_include_path(get_include_path().PATH_SEPARATOR.$phpunit2_path); + parent::init(); + } +} + ?>
\ No newline at end of file diff --git a/buildscripts/phing/tasks/QuickstartIndexTask.php b/buildscripts/phing/tasks/QuickstartIndexTask.php index 64a48d4a..5179d8ad 100644 --- a/buildscripts/phing/tasks/QuickstartIndexTask.php +++ b/buildscripts/phing/tasks/QuickstartIndexTask.php @@ -1,32 +1,32 @@ -<?php
-
-require_once 'phing/Task.php';
-
-/**
- * Task to index quickstart
- */
-class QuickstartIndexTask extends Task
-{
- private $todir;
-
- public function setTodir($value)
- {
- $this->todir=$value;
- }
-
- public function main()
- {
- $srcdir=realpath(dirname(__FILE__).'/../../../');
- $zend_path = $srcdir.'/demos/quickstart/protected/index';
- set_include_path(get_include_path().PATH_SEPARATOR.realpath($zend_path));
- require_once ('Zend/Search/Lucene.php');
-
- require_once($srcdir.'/buildscripts/index/quickstart_index.php');
- $quickstart_source = $srcdir.'/buildscripts/texbuilder/quickstart/pages.php';
- $quickstart_base = $srcdir.'/demos/quickstart/protected/pages/';
- $quickstart = new quickstart_index($this->todir, realpath($quickstart_base), realpath($quickstart_source));
- $quickstart->create_index();
- }
-}
-
+<?php + +require_once 'phing/Task.php'; + +/** + * Task to index quickstart + */ +class QuickstartIndexTask extends Task +{ + private $todir; + + public function setTodir($value) + { + $this->todir=$value; + } + + public function main() + { + $srcdir=realpath(dirname(__FILE__).'/../../../'); + $zend_path = $srcdir.'/demos/quickstart/protected/index'; + set_include_path(get_include_path().PATH_SEPARATOR.realpath($zend_path)); + require_once ('Zend/Search/Lucene.php'); + + require_once($srcdir.'/buildscripts/index/quickstart_index.php'); + $quickstart_source = $srcdir.'/buildscripts/texbuilder/quickstart/pages.php'; + $quickstart_base = $srcdir.'/demos/quickstart/protected/pages/'; + $quickstart = new quickstart_index($this->todir, realpath($quickstart_base), realpath($quickstart_source)); + $quickstart->create_index(); + } +} + ?>
\ No newline at end of file diff --git a/buildscripts/phpbuilder/build.php b/buildscripts/phpbuilder/build.php index 1df70b58..17e02806 100644 --- a/buildscripts/phpbuilder/build.php +++ b/buildscripts/phpbuilder/build.php @@ -1,148 +1,148 @@ -#!/usr/bin/php
-<?php
-/**
- * Prado build file.
- *
- * This is a command line script that can be run simply by "php build.php".
- *
- * This script expands prado.php into a file that contains the content
- * of prado.php and all its included (directly or indirectly) files.
- * Comments and trace statements are stripped off to further improve
- * performance.
- *
- * The generated file is named pradolite.php and is placed under the
- * 'framework' directory.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright © 2005 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Tools
- */
-
-/**
- * The framework directory
- */
-define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework'));
-/**
- * The merged file name
- */
-define('OUTPUT_FILE','pradolite.php');
-
-
-if(FRAMEWORK_DIR===false || !is_file(FRAMEWORK_DIR.'/prado.php'))
- die('Unable to determine the installation directory of Prado Framework.');
-
-$lastupdate=date('Y/m/d H:i:s');
-$comments="
-/**
- * File Name: pradolite.php
- * Last Update: $lastupdate
- * Generated By: buildscripts/phpbuilder/build.php
- *
- * This file is used in lieu of prado.php to boost PRADO application performance.
- * It is generated by expanding prado.php with included files.
- * Comments and trace statements are stripped off.
- *
- * Do not modify this file manually.
- */
-";
-
-$content=unfold_file(FRAMEWORK_DIR.'/prado.php');
-$content="<?php\n".preg_replace('/^(\?>|<\?php)/mu','',$content)."\n?>";
-$content=strip_comments($content);
-$content=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content);
-$content=strip_empty_lines($content);
-$content=substr_replace($content,$comments,5,0);
-file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$content);
-echo "Done.\n";
-
-exit();
-
-function strip_comments($source)
-{
- $tokens = token_get_all($source);
- /* T_ML_COMMENT does not exist in PHP 5.
- * The following three lines define it in order to
- * preserve backwards compatibility.
- *
- * The next two lines define the PHP 5-only T_DOC_COMMENT,
- * which we will mask as T_ML_COMMENT for PHP 4.
- */
- if (!defined('T_ML_COMMENT')) {
- @define('T_ML_COMMENT', T_COMMENT);
- } else {
- @define('T_DOC_COMMENT', T_ML_COMMENT);
- }
- $output = '';
- foreach ($tokens as $token) {
- if (is_string($token)) {
- // simple 1-character token
- $output .= $token;
- } else {
- // token array
- list($id, $text) = $token;
- switch ($id) {
- case T_COMMENT:
- case T_ML_COMMENT: // we've defined this
- case T_DOC_COMMENT: // and this
- // no action on comments
- break;
- default:
- // anything else -> output "as is"
- $output .= $text;
- break;
- }
- }
- }
- return $output;
-}
-
-function strip_empty_lines($string)
-{
- $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string);
- $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string);
- return $string;
-}
-
-function unfold_file($fileName)
-{
- static $unfoldedFiles=array();
- $pattern='^(Prado::using|require_once|include_once)\s*\(([^\*]*?)\);';
- echo "adding $fileName...\n";
- $content=file_get_contents($fileName);
- while(preg_match("/$pattern/m",$content,$matches,PREG_OFFSET_CAPTURE))
- {
- $offset=$matches[0][1];
- $length=strlen($matches[0][0]);
- $type=$matches[1][0];
- $file=trim($matches[2][0],"'\"");
- if($type==='Prado::using')
- {
- $file=substr_replace(strtr($file,'.','/'),FRAMEWORK_DIR,0,6).'.php';
- }
- else
- {
- $file=strtr($file,'"',"'");
- if(($pos=strpos($file,"'"))!==false)
- $file=FRAMEWORK_DIR.'/'.substr($file,$pos+1);
- else
- die('Unable to process file '.$fileName.' about '.$matches[0][0]);
- }
- if(($file=realpath($file))===false || !is_file($file))
- die('Unable to process file '.$fileName.' about '.$matches[0][0]);
- if(isset($unfoldedFiles[$file]))
- {
- $content=substr_replace($content,'',$offset,$length);
- }
- else
- {
- $unfoldedFiles[$file]=true;
- $content=substr_replace($content,unfold_file($file),$offset,$length);
- }
- }
- return $content;
-}
-
+#!/usr/bin/php +<?php +/** + * Prado build file. + * + * This is a command line script that can be run simply by "php build.php". + * + * This script expands prado.php into a file that contains the content + * of prado.php and all its included (directly or indirectly) files. + * Comments and trace statements are stripped off to further improve + * performance. + * + * The generated file is named pradolite.php and is placed under the + * 'framework' directory. + * + * @author Qiang Xue <qiang.xue@gmail.com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package Tools + */ + +/** + * The framework directory + */ +define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework')); +/** + * The merged file name + */ +define('OUTPUT_FILE','pradolite.php'); + + +if(FRAMEWORK_DIR===false || !is_file(FRAMEWORK_DIR.'/prado.php')) + die('Unable to determine the installation directory of Prado Framework.'); + +$lastupdate=date('Y/m/d H:i:s'); +$comments=" +/** + * File Name: pradolite.php + * Last Update: $lastupdate + * Generated By: buildscripts/phpbuilder/build.php + * + * This file is used in lieu of prado.php to boost PRADO application performance. + * It is generated by expanding prado.php with included files. + * Comments and trace statements are stripped off. + * + * Do not modify this file manually. + */ +"; + +$content=unfold_file(FRAMEWORK_DIR.'/prado.php'); +$content="<?php\n".preg_replace('/^(\?>|<\?php)/mu','',$content)."\n?>"; +$content=strip_comments($content); +$content=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content); +$content=strip_empty_lines($content); +$content=substr_replace($content,$comments,5,0); +file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$content); +echo "Done.\n"; + +exit(); + +function strip_comments($source) +{ + $tokens = token_get_all($source); + /* T_ML_COMMENT does not exist in PHP 5. + * The following three lines define it in order to + * preserve backwards compatibility. + * + * The next two lines define the PHP 5-only T_DOC_COMMENT, + * which we will mask as T_ML_COMMENT for PHP 4. + */ + if (!defined('T_ML_COMMENT')) { + @define('T_ML_COMMENT', T_COMMENT); + } else { + @define('T_DOC_COMMENT', T_ML_COMMENT); + } + $output = ''; + foreach ($tokens as $token) { + if (is_string($token)) { + // simple 1-character token + $output .= $token; + } else { + // token array + list($id, $text) = $token; + switch ($id) { + case T_COMMENT: + case T_ML_COMMENT: // we've defined this + case T_DOC_COMMENT: // and this + // no action on comments + break; + default: + // anything else -> output "as is" + $output .= $text; + break; + } + } + } + return $output; +} + +function strip_empty_lines($string) +{ + $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string); + $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string); + return $string; +} + +function unfold_file($fileName) +{ + static $unfoldedFiles=array(); + $pattern='^(Prado::using|require_once|include_once)\s*\(([^\*]*?)\);'; + echo "adding $fileName...\n"; + $content=file_get_contents($fileName); + while(preg_match("/$pattern/m",$content,$matches,PREG_OFFSET_CAPTURE)) + { + $offset=$matches[0][1]; + $length=strlen($matches[0][0]); + $type=$matches[1][0]; + $file=trim($matches[2][0],"'\""); + if($type==='Prado::using') + { + $file=substr_replace(strtr($file,'.','/'),FRAMEWORK_DIR,0,6).'.php'; + } + else + { + $file=strtr($file,'"',"'"); + if(($pos=strpos($file,"'"))!==false) + $file=FRAMEWORK_DIR.'/'.substr($file,$pos+1); + else + die('Unable to process file '.$fileName.' about '.$matches[0][0]); + } + if(($file=realpath($file))===false || !is_file($file)) + die('Unable to process file '.$fileName.' about '.$matches[0][0]); + if(isset($unfoldedFiles[$file])) + { + $content=substr_replace($content,'',$offset,$length); + } + else + { + $unfoldedFiles[$file]=true; + $content=substr_replace($content,unfold_file($file),$offset,$length); + } + } + return $content; +} + ?>
\ No newline at end of file diff --git a/buildscripts/texbuilder/Page2Tex.php b/buildscripts/texbuilder/Page2Tex.php index 008b30fa..eea0ab7e 100644 --- a/buildscripts/texbuilder/Page2Tex.php +++ b/buildscripts/texbuilder/Page2Tex.php @@ -1,347 +1,347 @@ -<?php
-
-class Page2Tex
-{
- private $_current_page;
- private static $header_count = 0;
- private static $p_count=0;
- private static $hil_count=0;
- private $page_count=0;
- private $_base;
- private $_dir;
-
- private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``','`');
- private $_verb_replace = array('$', '%', '{','}', " ",'"','\'');
-
- function __construct($base, $dir, $current='')
- {
- $this->_base = $base;
- $this->_current_page = $current;
- $this->_dir = $dir;
- }
-
- function setCurrentPage($current)
- {
- self::$header_count = self::$header_count+1000;
- $this->_current_page = $current;
- }
-
- function escape_verbatim($matches)
- {
- return "\begin{small}\begin{verbatim}".
- str_replace($this->_verb_find, $this->_verb_replace, $matches[1]).
- "\end{verbatim}\end{small}\n";
- }
-
- function escape_verb($matches)
- {
- $text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]);
- return '\begin{small}\verb<'.$text.'< \end{small}';
- }
-
- function include_image($matches)
- {
-
- $current_path = $this->_current_page;
-
- $image = dirname($current_path).'/'.trim($matches[1]);
-
- $file = realpath($image);
- $info = getimagesize($file);
- switch($info[2])
- {
- case 1:
- $im = imagecreatefromgif($file);
- break;
- case 2: $im = imagecreatefromjpeg($file); break;
- case 3: $im = imagecreatefrompng($file); break;
- }
- $base = $this->_base;
-
- if(isset($im))
- {
- $prefix = strtolower(str_replace(realpath($base), '', $file));
- $filename = preg_replace('/\\\|\//', '_', substr($prefix,1));
- $filename = substr($filename, 0, strrpos($filename,'.')).'.png';
- $newfile = $this->_dir.'/'.$filename;
- imagepng($im,$newfile);
- imagedestroy($im);
-
- return $this->include_figure($info, $filename);
- }
- }
-
- function include_figure($info, $filename)
- {
- $width = sprintf('%0.2f', $info[0]/(135/2.54));
- return '
- \begin{figure}[!ht]
- \centering
- \includegraphics[width='.$width.'cm]{'.$filename.'}
- \label{fig:'.$filename.'}
- \end{figure}
- ';
- }
-
- function anchor($matches)
- {
- $page = $this->get_current_path();
- return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
- }
-
- function texttt($matches)
- {
- $text ='\texttt{'.str_replace(array('#','_','&'),array('\#','\_','\&'), $matches[1]).'}';
- //$text = preg_replace('/([^\\\\])&([^;]+)/', '$1\&$2', $text);
- return $text;
- }
-
- function get_current_path()
- {
- $current_path = $this->_current_page;
- $base = $this->_base;
- $page = strtolower(substr(str_replace($base, '', $current_path),1));
- return $page;
- }
-
- function make_link($matches)
- {
- if(is_int(strpos($matches[1], '#')))
- {
- if(strpos($matches[1],'?') ===false)
- {
- if(strpos($matches[1],'http://')===false)
- {
- $target = $this->get_current_path().'/'.substr($matches[1],1);
- return '\hyperlink{'.$target.'}{'.$matches[2].'}';
- }
- }
- else
- {
- $page = strtolower(str_replace('?page=', '', $matches[1]));
- $page = str_replace('.','/',$page);
- $page = str_replace('#','.page/',$page);
- return '\hyperlink{'.$page.'}{'.$matches[2].'}';
- }
- }
- else if(is_int(strpos($matches[1],'?')))
- {
- $page = str_replace('?page=','',$matches[1]);
- return '\hyperlink{'.$page.'}{'.$matches[2].'}';
- }
- return '\href{'.str_replace('#','\\#',$matches[1]).'}{'.$matches[2].'}';
- }
-
- function parse_html($page,$html)
- {
- $html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
- $html = preg_replace('/<\/?p [^>]*>/', '', $html);
- $html = preg_replace('/<\/?p>/', '', $html);
-
- $html = preg_replace('/(\s+|\(+|\[+)"/', '$1``', $html);
- $html = preg_replace('/(\s+|\(+|\[+)\'/', '$1`', $html);
-
- //escape { and }
- $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html);
-
- $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^>]*\/>/', array($this, 'include_image'), $html);
-
- //escape %
- $html = str_replace('%', '\%', $html);
-
- //codes
- $html = str_replace('$', '\$', $html);
-
- $html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this,'escape_verbatim'), $html);
-// $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
-// $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
- $html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html);
- $html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
-
- //<code>
- $html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html);
-
- //runbar
- $html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
- '\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html);
-
- //DocLink
- $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^."]*)"\s+Text="([^"]+)"\s*\/>/',
- '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$3}', $html);
-
- $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/',
- '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
-
- //text modifiers
- $html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
- $html = preg_replace('/<i [^>]*>([^<]*)+?<\/i>/', '\emph{$1}', $html);
- $html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
-
- //links
- $html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
- array($this,'make_link'), $html);
- //anchor
- $html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
-
- //description <dl>
- $html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
- $html = preg_replace('/<\/?dd>/', '', $html);
- $html = preg_replace('/<dl>/', '\begin{description}', $html);
- $html = preg_replace('/<\/dl>/', '\end{description}', $html);
-
- //item lists
- $html = preg_replace('/<ul[^>]*>/', '\begin{itemize}', $html);
- $html = preg_replace('/<\/ul>/', '\end{itemize}', $html);
- $html = preg_replace('/<ol[^>]*>/', '\begin{enumerate}', $html);
- $html = preg_replace('/<\/ol>/', '\end{enumerate}', $html);
- $html = preg_replace('/<li[^>]*>/', '\item ', $html);
- $html = preg_replace('/<\/li>/', '', $html);
-
- //headings
- $html = preg_replace('/<h1(\s+id="[^"]+")?>([^<]+)<\/h1>/', '\section{$2}', $html);
- $html = preg_replace('/<h2(\s+id="[^"]+")?>([^<]+)<\/h2>/', '\subsection{$2}', $html);
- $html = preg_replace('/<h3(\s+id="[^"]+")?>([^<]+)<\/h3>/', '\subsubsection{$2}', $html);
-
- //div box
- $html = preg_replace_callback('/<div class="[tipnofe]*?">((.|\n)*?)<\/div>/',
- array($this, 'mbox'), $html);
-
- //tabular
- $html = preg_replace_callback('/<!--\s*tabular:([^-]*)-->\s*<table[^>]*>((.|\n)*?)<\/table>/',
- array($this, 'tabular'), $html);
-
- $html = preg_replace('/<!--((.|\n)*?)-->/', '', $html);
- $html = preg_replace('/<div class="last-modified">((.|\n)*?)<\/div>/', '', $html);
-
- //useless divs
- $html = preg_replace('/<div [^>]*">((.|\n)*?)<\/div>/', '$1', $html);
-
- //since
- $html = preg_replace('/<com:SinceVersion[^>]+>/', '', $html);
-
- //requiresversion
- $html = preg_replace('/<com:RequiresVersion[^>]+>/', '', $html);
-
- $html = html_entity_decode($html);
-
- return $html;
- }
-
- function tabular($matches)
- {
- $options = array();
- foreach(explode(',', $matches[1]) as $string)
- {
- $sub = explode('=', trim($string));
- $options[trim($sub[0])] = trim($sub[1]);
- }
-
- $widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
- $this->_tabular_widths = $widths;
-
- $this->_tabular_total = count($widths);
- $this->_tabular_col = 0;
-
- $begin = "\begin{table}[!hpt]\centering \n \begin{tabular}{".$options['align']."}\\hline";
- $end = "\end{tabular} \n \end{table}\n";
- $table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
- $table = preg_replace('/<tr>/', '', $table);
- $table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table);
- $table = preg_replace_callback('/<td>((.|\n)*?)<\/td>/', array($this, 'table_column'), $table);
- $table = preg_replace('/<br \/>/', ' \\\\\\\\', $table);
-
- $table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
- return $begin.$table.$end;
- }
-
- function table_column($matches)
- {
- $width = $this->_tabular_widths[$this->_tabular_col];
- if($this->_tabular_col >= $this->_tabular_total-1)
- $this->_tabular_col = 0;
- else
- $this->_tabular_col++;
- return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
- $matches[1].'\vspace{3mm}\end{minipage} & ';
- }
-
- function mbox($matches)
- {
- return "\n\begin{mybox}\n".$matches[1]."\n\end{mybox}\n";
- }
-
- function get_chapter_label($chapter)
- {
- return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
- }
-
- function get_section_label($section)
- {
- $section = str_replace('.page', '', $section);
- return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
- }
-
-
- function set_header_id($content, $j)
- {
- $this->page_count=$j;
- $content = preg_replace_callback('/<h1>/', array($this,"h1"), $content);
- $content = preg_replace_callback('/<h2>/', array($this,"h2"), $content);
- $content = preg_replace_callback('/<h3>/', array($this,"h3"), $content);
- $content = $this->set_block_content_id($content);
- return $content;
- }
-
- function h1($matches)
- {
- $page = $this->page_count*1000;
- return "<h1 id=\"".($page + (++self::$header_count))."\">";
- }
-
- function h2($matches)
- {
- $page = $this->page_count*1000;
- return "<h2 id=\"".($page + (++self::$header_count))."\">";
- }
-
- function h3($matches)
- {
- $page = $this->page_count*1000;
- return "<h3 id=\"".($page + (++self::$header_count))."\">";
- }
-
- function set_block_content_id($content)
- {
- $content = preg_replace_callback('/<p>/', array($this, 'add_p'), $content);
- $content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content);
- return $content;
- }
-
- function hil($matches)
- {
- $id = ($this->page_count*10000) + (++self::$hil_count);
- if(preg_match('/id="code-\d+"/i', $matches[1]))
- {
- $code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
- //var_dump($code);
- return $code;
- }
- else if(preg_match('/id="[^"]+"/i', $matches[1]))
- {
- return $matches[0];
- }
- else
- {
- $changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
- return $changes;
- }
- }
-
- function add_p($matches)
- {
- $page = $this->page_count*10000;
- return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">";
- }
-}
-
-?>
+<?php + +class Page2Tex +{ + private $_current_page; + private static $header_count = 0; + private static $p_count=0; + private static $hil_count=0; + private $page_count=0; + private $_base; + private $_dir; + + private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``','`'); + private $_verb_replace = array('$', '%', '{','}', " ",'"','\''); + + function __construct($base, $dir, $current='') + { + $this->_base = $base; + $this->_current_page = $current; + $this->_dir = $dir; + } + + function setCurrentPage($current) + { + self::$header_count = self::$header_count+1000; + $this->_current_page = $current; + } + + function escape_verbatim($matches) + { + return "\begin{small}\begin{verbatim}". + str_replace($this->_verb_find, $this->_verb_replace, $matches[1]). + "\end{verbatim}\end{small}\n"; + } + + function escape_verb($matches) + { + $text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]); + return '\begin{small}\verb<'.$text.'< \end{small}'; + } + + function include_image($matches) + { + + $current_path = $this->_current_page; + + $image = dirname($current_path).'/'.trim($matches[1]); + + $file = realpath($image); + $info = getimagesize($file); + switch($info[2]) + { + case 1: + $im = imagecreatefromgif($file); + break; + case 2: $im = imagecreatefromjpeg($file); break; + case 3: $im = imagecreatefrompng($file); break; + } + $base = $this->_base; + + if(isset($im)) + { + $prefix = strtolower(str_replace(realpath($base), '', $file)); + $filename = preg_replace('/\\\|\//', '_', substr($prefix,1)); + $filename = substr($filename, 0, strrpos($filename,'.')).'.png'; + $newfile = $this->_dir.'/'.$filename; + imagepng($im,$newfile); + imagedestroy($im); + + return $this->include_figure($info, $filename); + } + } + + function include_figure($info, $filename) + { + $width = sprintf('%0.2f', $info[0]/(135/2.54)); + return ' + \begin{figure}[!ht] + \centering + \includegraphics[width='.$width.'cm]{'.$filename.'} + \label{fig:'.$filename.'} + \end{figure} + '; + } + + function anchor($matches) + { + $page = $this->get_current_path(); + return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}'; + } + + function texttt($matches) + { + $text ='\texttt{'.str_replace(array('#','_','&'),array('\#','\_','\&'), $matches[1]).'}'; + //$text = preg_replace('/([^\\\\])&([^;]+)/', '$1\&$2', $text); + return $text; + } + + function get_current_path() + { + $current_path = $this->_current_page; + $base = $this->_base; + $page = strtolower(substr(str_replace($base, '', $current_path),1)); + return $page; + } + + function make_link($matches) + { + if(is_int(strpos($matches[1], '#'))) + { + if(strpos($matches[1],'?') ===false) + { + if(strpos($matches[1],'http://')===false) + { + $target = $this->get_current_path().'/'.substr($matches[1],1); + return '\hyperlink{'.$target.'}{'.$matches[2].'}'; + } + } + else + { + $page = strtolower(str_replace('?page=', '', $matches[1])); + $page = str_replace('.','/',$page); + $page = str_replace('#','.page/',$page); + return '\hyperlink{'.$page.'}{'.$matches[2].'}'; + } + } + else if(is_int(strpos($matches[1],'?'))) + { + $page = str_replace('?page=','',$matches[1]); + return '\hyperlink{'.$page.'}{'.$matches[2].'}'; + } + return '\href{'.str_replace('#','\\#',$matches[1]).'}{'.$matches[2].'}'; + } + + function parse_html($page,$html) + { + $html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html); + $html = preg_replace('/<\/?p [^>]*>/', '', $html); + $html = preg_replace('/<\/?p>/', '', $html); + + $html = preg_replace('/(\s+|\(+|\[+)"/', '$1``', $html); + $html = preg_replace('/(\s+|\(+|\[+)\'/', '$1`', $html); + + //escape { and } + $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html); + + $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^>]*\/>/', array($this, 'include_image'), $html); + + //escape % + $html = str_replace('%', '\%', $html); + + //codes + $html = str_replace('$', '\$', $html); + + $html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this,'escape_verbatim'), $html); +// $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html); +// $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html); + $html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html); + $html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html); + + //<code> + $html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html); + + //runbar + $html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/', + '\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html); + + //DocLink + $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^."]*)"\s+Text="([^"]+)"\s*\/>/', + '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$3}', $html); + + $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/', + '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html); + + //text modifiers + $html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html); + $html = preg_replace('/<i [^>]*>([^<]*)+?<\/i>/', '\emph{$1}', $html); + $html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html); + + //links + $html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/', + array($this,'make_link'), $html); + //anchor + $html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html); + + //description <dl> + $html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html); + $html = preg_replace('/<\/?dd>/', '', $html); + $html = preg_replace('/<dl>/', '\begin{description}', $html); + $html = preg_replace('/<\/dl>/', '\end{description}', $html); + + //item lists + $html = preg_replace('/<ul[^>]*>/', '\begin{itemize}', $html); + $html = preg_replace('/<\/ul>/', '\end{itemize}', $html); + $html = preg_replace('/<ol[^>]*>/', '\begin{enumerate}', $html); + $html = preg_replace('/<\/ol>/', '\end{enumerate}', $html); + $html = preg_replace('/<li[^>]*>/', '\item ', $html); + $html = preg_replace('/<\/li>/', '', $html); + + //headings + $html = preg_replace('/<h1(\s+id="[^"]+")?>([^<]+)<\/h1>/', '\section{$2}', $html); + $html = preg_replace('/<h2(\s+id="[^"]+")?>([^<]+)<\/h2>/', '\subsection{$2}', $html); + $html = preg_replace('/<h3(\s+id="[^"]+")?>([^<]+)<\/h3>/', '\subsubsection{$2}', $html); + + //div box + $html = preg_replace_callback('/<div class="[tipnofe]*?">((.|\n)*?)<\/div>/', + array($this, 'mbox'), $html); + + //tabular + $html = preg_replace_callback('/<!--\s*tabular:([^-]*)-->\s*<table[^>]*>((.|\n)*?)<\/table>/', + array($this, 'tabular'), $html); + + $html = preg_replace('/<!--((.|\n)*?)-->/', '', $html); + $html = preg_replace('/<div class="last-modified">((.|\n)*?)<\/div>/', '', $html); + + //useless divs + $html = preg_replace('/<div [^>]*">((.|\n)*?)<\/div>/', '$1', $html); + + //since + $html = preg_replace('/<com:SinceVersion[^>]+>/', '', $html); + + //requiresversion + $html = preg_replace('/<com:RequiresVersion[^>]+>/', '', $html); + + $html = html_entity_decode($html); + + return $html; + } + + function tabular($matches) + { + $options = array(); + foreach(explode(',', $matches[1]) as $string) + { + $sub = explode('=', trim($string)); + $options[trim($sub[0])] = trim($sub[1]); + } + + $widths = explode(' ',preg_replace('/\(|\)/', '', $options['width'])); + $this->_tabular_widths = $widths; + + $this->_tabular_total = count($widths); + $this->_tabular_col = 0; + + $begin = "\begin{table}[!hpt]\centering \n \begin{tabular}{".$options['align']."}\\hline"; + $end = "\end{tabular} \n \end{table}\n"; + $table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]); + $table = preg_replace('/<tr>/', '', $table); + $table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table); + $table = preg_replace_callback('/<td>((.|\n)*?)<\/td>/', array($this, 'table_column'), $table); + $table = preg_replace('/<br \/>/', ' \\\\\\\\', $table); + + $table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table); + return $begin.$table.$end; + } + + function table_column($matches) + { + $width = $this->_tabular_widths[$this->_tabular_col]; + if($this->_tabular_col >= $this->_tabular_total-1) + $this->_tabular_col = 0; + else + $this->_tabular_col++; + return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'. + $matches[1].'\vspace{3mm}\end{minipage} & '; + } + + function mbox($matches) + { + return "\n\begin{mybox}\n".$matches[1]."\n\end{mybox}\n"; + } + + function get_chapter_label($chapter) + { + return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}'; + } + + function get_section_label($section) + { + $section = str_replace('.page', '', $section); + return '\hypertarget{'.str_replace('/', '.', $section).'}{}'; + } + + + function set_header_id($content, $j) + { + $this->page_count=$j; + $content = preg_replace_callback('/<h1>/', array($this,"h1"), $content); + $content = preg_replace_callback('/<h2>/', array($this,"h2"), $content); + $content = preg_replace_callback('/<h3>/', array($this,"h3"), $content); + $content = $this->set_block_content_id($content); + return $content; + } + + function h1($matches) + { + $page = $this->page_count*1000; + return "<h1 id=\"".($page + (++self::$header_count))."\">"; + } + + function h2($matches) + { + $page = $this->page_count*1000; + return "<h2 id=\"".($page + (++self::$header_count))."\">"; + } + + function h3($matches) + { + $page = $this->page_count*1000; + return "<h3 id=\"".($page + (++self::$header_count))."\">"; + } + + function set_block_content_id($content) + { + $content = preg_replace_callback('/<p>/', array($this, 'add_p'), $content); + $content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content); + return $content; + } + + function hil($matches) + { + $id = ($this->page_count*10000) + (++self::$hil_count); + if(preg_match('/id="code-\d+"/i', $matches[1])) + { + $code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]); + //var_dump($code); + return $code; + } + else if(preg_match('/id="[^"]+"/i', $matches[1])) + { + return $matches[0]; + } + else + { + $changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]); + return $changes; + } + } + + function add_p($matches) + { + $page = $this->page_count*10000; + return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">"; + } +} + +?> diff --git a/buildscripts/texbuilder/quickstart/build.php b/buildscripts/texbuilder/quickstart/build.php index 81a12d4c..a42d6be3 100644 --- a/buildscripts/texbuilder/quickstart/build.php +++ b/buildscripts/texbuilder/quickstart/build.php @@ -1,81 +1,81 @@ -<?php
-
-// TBD: subsections in Control Reference
-
-$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe";
-$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s";
-
-$mainTexFile = dirname(__FILE__).'/quickstart.tex';
-
-//page root location
-$base = realpath(dirname(__FILE__).'/../../../demos/quickstart/protected/pages/');
-
-$pages = include('pages.php');
-
-//-------------- END CONFIG ------------------
-
-include(dirname(__FILE__).'.../../../texbuilder/Page2Tex.php');
-
-// ---------------- Create the Tex files ---------
-$count = 1;
-$j = 1;
-$current_path = '';
-echo "Compiling .page files to Latex files\n\n";
-
-$parser = new Page2Tex($base, dirname(__FILE__));
-
-foreach($pages as $chapter => $sections)
-{
- $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter);
- echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n";
- echo str_repeat('-',60)."\n";
- foreach($sections as $section)
- {
- echo " Adding $section\n";
- $page = $base.'/'.$section;
- $current_path = $page;
- $parser->setCurrentPage($current_path);
-
- //add id to <h1>, <h2>, <h3> and <p>
- $tmp_content = $parser->set_header_id(file_get_contents($page),$j++);
- file_put_contents($page, $tmp_content);
-
- $content .= $parser->get_section_label($section);
- $file_content = file_get_contents($page);
- //$tex =
- $content .= $parser->parse_html($page,$file_content);
- }
-
- //var_dump($content);
- file_put_contents("ch{$count}.tex", $content);
- $count++;
- echo "\n";
-}
-
-//$indexer->commit();
-
-if($argc <= 1 && $count > 1)
-{
- echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n";
- exit;
-}
-if($argv[1] == 'pdf')
-{
- if(is_file($pdflatexExec))
- {
- //build pdfTex
- $command=sprintf($pdfTex,$mainTexFile);
- system($command);
- system($command); //run it twice
-
- echo "\n\n** PDF file quickstart.pdf created **\n\n";
-
- }
- else
- {
- echo " Unable to find pdfLatex executable $pdflatexExec";
- }
-}
-
-
-?>
+<?php + +// TBD: subsections in Control Reference + +$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe"; +$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s"; + +$mainTexFile = dirname(__FILE__).'/quickstart.tex'; + +//page root location +$base = realpath(dirname(__FILE__).'/../../../demos/quickstart/protected/pages/'); + +$pages = include('pages.php'); + +//-------------- END CONFIG ------------------ + +include(dirname(__FILE__).'.../../../texbuilder/Page2Tex.php'); + +// ---------------- Create the Tex files --------- +$count = 1; +$j = 1; +$current_path = ''; +echo "Compiling .page files to Latex files\n\n"; + +$parser = new Page2Tex($base, dirname(__FILE__)); + +foreach($pages as $chapter => $sections) +{ + $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter); + echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n"; + echo str_repeat('-',60)."\n"; + foreach($sections as $section) + { + echo " Adding $section\n"; + $page = $base.'/'.$section; + $current_path = $page; + $parser->setCurrentPage($current_path); + + //add id to <h1>, <h2>, <h3> and <p> + $tmp_content = $parser->set_header_id(file_get_contents($page),$j++); + file_put_contents($page, $tmp_content); + + $content .= $parser->get_section_label($section); + $file_content = file_get_contents($page); + //$tex = + $content .= $parser->parse_html($page,$file_content); + } + + //var_dump($content); + file_put_contents("ch{$count}.tex", $content); + $count++; + echo "\n"; +} + +//$indexer->commit(); + +if($argc <= 1 && $count > 1) +{ + echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n"; + exit; +} +if($argv[1] == 'pdf') +{ + if(is_file($pdflatexExec)) + { + //build pdfTex + $command=sprintf($pdfTex,$mainTexFile); + system($command); + system($command); //run it twice + + echo "\n\n** PDF file quickstart.pdf created **\n\n"; + + } + else + { + echo " Unable to find pdfLatex executable $pdflatexExec"; + } +} + + +?> diff --git a/buildscripts/texbuilder/quickstart/pages.php b/buildscripts/texbuilder/quickstart/pages.php index a99a2a35..8bb34625 100644 --- a/buildscripts/texbuilder/quickstart/pages.php +++ b/buildscripts/texbuilder/quickstart/pages.php @@ -1,179 +1,179 @@ -<?php
-/*
- * $Id$
- */
-
-//list page into chapters
-$pages['Getting Started'] = array(
- 'GettingStarted/Introduction.page',
- 'GettingStarted/AboutPrado.page',
- 'GettingStarted/Installation.page',
- 'GettingStarted/NewFeatures.page',
- 'GettingStarted/Upgrading.page'
- );
-
-$pages['Tutorials'] = array(
- 'GettingStarted/HelloWorld.page',
- 'Fundamentals/Hangman.page',
- 'GettingStarted/CommandLine.page'
- );
-
-$pages['Tutorial: Currency Converter'] = array(
- 'Tutorial/CurrencyConverter.page'
- );
-
-$pages['Tutorial: Building an AJAX Chat Application'] = array(
- 'Tutorial/AjaxChat.page'
- );
-
-$pages['Tutorial: Addressbook'] = array(
- 'Tutorial/AddressBook.page'
- );
-
-$pages['Fundamentals'] = array(
- 'Fundamentals/Architecture.page',
- 'Fundamentals/Components.page',
- 'Fundamentals/Controls.page',
- 'Fundamentals/Pages.page',
- 'Fundamentals/Modules.page',
- 'Fundamentals/Services.page',
- 'Fundamentals/Applications.page'
- );
-
-$pages['Configurations'] = array(
- 'Configurations/Overview.page',
- 'Configurations/Templates1.page',
- 'Configurations/Templates2.page',
- 'Configurations/Templates3.page',
- 'Configurations/AppConfig.page',
- 'Configurations/PageConfig.page',
- 'Configurations/UrlMapping.page'
- );
-
-$pages['Control Reference : Standard Controls'] = array(
- 'Controls/Standard.page',
- 'Controls/Button.page',
- 'Controls/Captcha.page',
- 'Controls/CheckBox.page',
- 'Controls/ClientScript.page',
- 'Controls/ClientScriptLoader.page',
- 'Controls/Conditional.page',
- 'Controls/ColorPicker.page',
- 'Controls/DatePicker.page',
- 'Controls/Expression.page',
- 'Controls/FileUpload.page',
- 'Controls/Head.page',
- 'Controls/HiddenField.page',
- 'Controls/HtmlArea.page',
- 'Controls/HyperLink.page',
- 'Controls/ImageButton.page',
- 'Controls/ImageMap.page',
- 'Controls/Image.page',
- 'Controls/InlineFrame.page',
- 'Controls/JavascriptLogger.page',
- 'Controls/Keyboard.page',
- 'Controls/Label.page',
- 'Controls/LinkButton.page',
- 'Controls/Literal.page',
- 'Controls/MultiView.page',
- 'Controls/OutputCache.page',
- 'Controls/Pager.page',
- 'Controls/Panel.page',
- 'Controls/PlaceHolder.page',
- 'Controls/RadioButton.page',
- 'Controls/SafeHtml.page',
- 'Controls/Slider.page',
- 'Controls/Statements.page',
- 'Controls/Table.page',
- 'Controls/TabPanel.page',
- 'Controls/TextBox.page',
- 'Controls/TextHighlighter.page',
- 'Controls/Wizard.page');
-
-$pages['Control Reference : List Controls'] = array(
- 'Controls/List.page');
-
-$pages['Control Reference : Validation Controls'] = array(
- 'Controls/Validation.page');
-
-$pages['Control Reference : Data Controls'] = array(
- 'Controls/Data.page',
- 'Controls/DataList.page',
- 'Controls/DataGrid.page',
- 'Controls/Repeater.page');
-
-$pages['Control Reference : Active Controls (AJAX)'] = array(
- 'ActiveControls/ActiveButton.page',
- 'ActiveControls/ActiveCheckBox.page',
- 'ActiveControls/ActiveCheckBoxList.page',
- 'ActiveControls/ActiveCustomValidator.page',
- 'ActiveControls/ActiveDataList.page',
- 'ActiveControls/ActiveDataGrid.page',
- 'ActiveControls/ActiveDatePicker.page',
- 'ActiveControls/ActiveDropDownList.page',
- 'ActiveControls/ActiveFileUpload.page',
- 'ActiveControls/ActiveHiddenField.page',
- 'ActiveControls/ActiveHyperLink.page',
- 'ActiveControls/ActiveImage.page',
- 'ActiveControls/ActiveImageButton.page',
- 'ActiveControls/ActiveLabel.page',
- 'ActiveControls/ActiveLinkButton.page',
- 'ActiveControls/ActiveListBox.page',
- 'ActiveControls/ActiveMultiView.page',
- 'ActiveControls/ActivePager.page',
- 'ActiveControls/ActivePanel.page',
- 'ActiveControls/ActiveRadioButton.page',
- 'ActiveControls/ActiveRadioButtonList.page',
- 'ActiveControls/ActiveRepeater.page',
- 'ActiveControls/ActiveTextBox.page',
- 'ActiveControls/AutoComplete.page',
- 'ActiveControls/Callback.page',
- 'ActiveControls/CallbackClientScript.page',
- 'ActiveControls/CallbackClientSide.page',
- 'ActiveControls/CallbackEventParameter.page',
- 'ActiveControls/CallbackOptions.page',
- 'ActiveControls/DragDrop.page',
- 'ActiveControls/EventTriggeredCallback.page',
- 'ActiveControls/InPlaceTextBox.page',
- 'ActiveControls/TimeTriggeredCallback.page',
- 'ActiveControls/ValueTriggeredCallback.page');
-
-$pages['Active Control Overview'] = array(
- 'ActiveControls/Home.page',
- 'ActiveControls/Introduction.page');
-
-$pages['Write New Controls'] = array(
- 'Controls/NewControl.page');
-
-$pages['Service References'] = array(
- 'Services/SoapService.page');
-
-$pages['Working with Databases'] = array(
- 'Database/DAO.page',
- 'Database/ActiveRecord.page',
- 'Database/Scaffold.page',
- 'Database/SqlMap.page');
-
-$pages['Advanced Topics'] = array(
- 'Advanced/Collections.page',
- 'Advanced/Auth.page',
- 'Advanced/Security.page',
- 'Advanced/Assets.page',
- 'Advanced/MasterContent.page',
- 'Advanced/Themes.page',
- 'Advanced/State.page',
- 'Advanced/Logging.page',
- 'Advanced/I18N.page',
- 'Advanced/Error.page',
- 'Advanced/Performance.page');
-
-$pages['Client-side Scripting'] = array(
- 'Advanced/Scripts.page',
- 'Advanced/Scripts1.page',
- 'Advanced/Scripts2.page',
- 'Advanced/Scripts3.page');
-
-return $pages;
-//-------------- END CONFIG ----------------
-
+<?php +/* + * $Id$ + */ + +//list page into chapters +$pages['Getting Started'] = array( + 'GettingStarted/Introduction.page', + 'GettingStarted/AboutPrado.page', + 'GettingStarted/Installation.page', + 'GettingStarted/NewFeatures.page', + 'GettingStarted/Upgrading.page' + ); + +$pages['Tutorials'] = array( + 'GettingStarted/HelloWorld.page', + 'Fundamentals/Hangman.page', + 'GettingStarted/CommandLine.page' + ); + +$pages['Tutorial: Currency Converter'] = array( + 'Tutorial/CurrencyConverter.page' + ); + +$pages['Tutorial: Building an AJAX Chat Application'] = array( + 'Tutorial/AjaxChat.page' + ); + +$pages['Tutorial: Addressbook'] = array( + 'Tutorial/AddressBook.page' + ); + +$pages['Fundamentals'] = array( + 'Fundamentals/Architecture.page', + 'Fundamentals/Components.page', + 'Fundamentals/Controls.page', + 'Fundamentals/Pages.page', + 'Fundamentals/Modules.page', + 'Fundamentals/Services.page', + 'Fundamentals/Applications.page' + ); + +$pages['Configurations'] = array( + 'Configurations/Overview.page', + 'Configurations/Templates1.page', + 'Configurations/Templates2.page', + 'Configurations/Templates3.page', + 'Configurations/AppConfig.page', + 'Configurations/PageConfig.page', + 'Configurations/UrlMapping.page' + ); + +$pages['Control Reference : Standard Controls'] = array( + 'Controls/Standard.page', + 'Controls/Button.page', + 'Controls/Captcha.page', + 'Controls/CheckBox.page', + 'Controls/ClientScript.page', + 'Controls/ClientScriptLoader.page', + 'Controls/Conditional.page', + 'Controls/ColorPicker.page', + 'Controls/DatePicker.page', + 'Controls/Expression.page', + 'Controls/FileUpload.page', + 'Controls/Head.page', + 'Controls/HiddenField.page', + 'Controls/HtmlArea.page', + 'Controls/HyperLink.page', + 'Controls/ImageButton.page', + 'Controls/ImageMap.page', + 'Controls/Image.page', + 'Controls/InlineFrame.page', + 'Controls/JavascriptLogger.page', + 'Controls/Keyboard.page', + 'Controls/Label.page', + 'Controls/LinkButton.page', + 'Controls/Literal.page', + 'Controls/MultiView.page', + 'Controls/OutputCache.page', + 'Controls/Pager.page', + 'Controls/Panel.page', + 'Controls/PlaceHolder.page', + 'Controls/RadioButton.page', + 'Controls/SafeHtml.page', + 'Controls/Slider.page', + 'Controls/Statements.page', + 'Controls/Table.page', + 'Controls/TabPanel.page', + 'Controls/TextBox.page', + 'Controls/TextHighlighter.page', + 'Controls/Wizard.page'); + +$pages['Control Reference : List Controls'] = array( + 'Controls/List.page'); + +$pages['Control Reference : Validation Controls'] = array( + 'Controls/Validation.page'); + +$pages['Control Reference : Data Controls'] = array( + 'Controls/Data.page', + 'Controls/DataList.page', + 'Controls/DataGrid.page', + 'Controls/Repeater.page'); + +$pages['Control Reference : Active Controls (AJAX)'] = array( + 'ActiveControls/ActiveButton.page', + 'ActiveControls/ActiveCheckBox.page', + 'ActiveControls/ActiveCheckBoxList.page', + 'ActiveControls/ActiveCustomValidator.page', + 'ActiveControls/ActiveDataList.page', + 'ActiveControls/ActiveDataGrid.page', + 'ActiveControls/ActiveDatePicker.page', + 'ActiveControls/ActiveDropDownList.page', + 'ActiveControls/ActiveFileUpload.page', + 'ActiveControls/ActiveHiddenField.page', + 'ActiveControls/ActiveHyperLink.page', + 'ActiveControls/ActiveImage.page', + 'ActiveControls/ActiveImageButton.page', + 'ActiveControls/ActiveLabel.page', + 'ActiveControls/ActiveLinkButton.page', + 'ActiveControls/ActiveListBox.page', + 'ActiveControls/ActiveMultiView.page', + 'ActiveControls/ActivePager.page', + 'ActiveControls/ActivePanel.page', + 'ActiveControls/ActiveRadioButton.page', + 'ActiveControls/ActiveRadioButtonList.page', + 'ActiveControls/ActiveRepeater.page', + 'ActiveControls/ActiveTextBox.page', + 'ActiveControls/AutoComplete.page', + 'ActiveControls/Callback.page', + 'ActiveControls/CallbackClientScript.page', + 'ActiveControls/CallbackClientSide.page', + 'ActiveControls/CallbackEventParameter.page', + 'ActiveControls/CallbackOptions.page', + 'ActiveControls/DragDrop.page', + 'ActiveControls/EventTriggeredCallback.page', + 'ActiveControls/InPlaceTextBox.page', + 'ActiveControls/TimeTriggeredCallback.page', + 'ActiveControls/ValueTriggeredCallback.page'); + +$pages['Active Control Overview'] = array( + 'ActiveControls/Home.page', + 'ActiveControls/Introduction.page'); + +$pages['Write New Controls'] = array( + 'Controls/NewControl.page'); + +$pages['Service References'] = array( + 'Services/SoapService.page'); + +$pages['Working with Databases'] = array( + 'Database/DAO.page', + 'Database/ActiveRecord.page', + 'Database/Scaffold.page', + 'Database/SqlMap.page'); + +$pages['Advanced Topics'] = array( + 'Advanced/Collections.page', + 'Advanced/Auth.page', + 'Advanced/Security.page', + 'Advanced/Assets.page', + 'Advanced/MasterContent.page', + 'Advanced/Themes.page', + 'Advanced/State.page', + 'Advanced/Logging.page', + 'Advanced/I18N.page', + 'Advanced/Error.page', + 'Advanced/Performance.page'); + +$pages['Client-side Scripting'] = array( + 'Advanced/Scripts.page', + 'Advanced/Scripts1.page', + 'Advanced/Scripts2.page', + 'Advanced/Scripts3.page'); + +return $pages; +//-------------- END CONFIG ---------------- + ?>
\ No newline at end of file diff --git a/buildscripts/texbuilder/sqlmap/build.php b/buildscripts/texbuilder/sqlmap/build.php index 46773390..4ea4d75e 100644 --- a/buildscripts/texbuilder/sqlmap/build.php +++ b/buildscripts/texbuilder/sqlmap/build.php @@ -1,81 +1,81 @@ -<?php
-
-// TBD: subsections in Control Reference
-
-$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe";
-$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s";
-
-$mainTexFile = dirname(__FILE__).'/sqlmap.tex';
-
-//page root location
-$base = realpath(dirname(__FILE__).'/../../../demos/sqlmap/protected/pages/');
-
-//-------------- END CONFIG ------------------
-
-$pages = include('pages.php');
-
-include('../../../../prado-3.0/buildscripts/texbuilder/Page2Tex.php');
-
-// ---------------- Create the Tex files ---------
-$count = 1;
-$j = 1;
-$current_path = '';
-echo "Compiling .page files to Latex files\n\n";
-
-$parser = new Page2Tex($base, dirname(__FILE__));
-
-foreach($pages as $chapter => $sections)
-{
- $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter);
- echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n";
- echo str_repeat('-',60)."\n";
- foreach($sections as $section)
- {
- echo " Adding $section\n";
- $page = $base.'/'.$section;
- $current_path = $page;
- $parser->setCurrentPage($current_path);
-
- //add id to <h1>, <h2>, <3>
- $tmp_content = $parser->set_header_id(file_get_contents($page),$j++);
-// file_put_contents($page, $tmp_content);
-
- $content .= $parser->get_section_label($section);
- $file_content = file_get_contents($page);
- $tex =
- $content .= $parser->parse_html($page,$file_content);
- }
-
- //var_dump($content);
- file_put_contents("ch{$count}.tex", $content);
- $count++;
- echo "\n";
-}
-
-//$indexer->commit();
-
-if($argc <= 1 && $count > 1)
-{
- echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n";
- exit;
-}
-if($argv[1] == 'pdf')
-{
- if(is_file($pdflatexExec))
- {
- //build pdfTex
- $command=sprintf($pdfTex,$mainTexFile);
- system($command);
- system($command); //run it twice
-
- echo "\n\n** PDF file quickstart.pdf created **\n\n";
-
- }
- else
- {
- echo " Unable to find pdfLatex executable $pdflatexExec";
- }
-}
-
-
-?>
+<?php + +// TBD: subsections in Control Reference + +$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe"; +$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s"; + +$mainTexFile = dirname(__FILE__).'/sqlmap.tex'; + +//page root location +$base = realpath(dirname(__FILE__).'/../../../demos/sqlmap/protected/pages/'); + +//-------------- END CONFIG ------------------ + +$pages = include('pages.php'); + +include('../../../../prado-3.0/buildscripts/texbuilder/Page2Tex.php'); + +// ---------------- Create the Tex files --------- +$count = 1; +$j = 1; +$current_path = ''; +echo "Compiling .page files to Latex files\n\n"; + +$parser = new Page2Tex($base, dirname(__FILE__)); + +foreach($pages as $chapter => $sections) +{ + $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter); + echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n"; + echo str_repeat('-',60)."\n"; + foreach($sections as $section) + { + echo " Adding $section\n"; + $page = $base.'/'.$section; + $current_path = $page; + $parser->setCurrentPage($current_path); + + //add id to <h1>, <h2>, <3> + $tmp_content = $parser->set_header_id(file_get_contents($page),$j++); +// file_put_contents($page, $tmp_content); + + $content .= $parser->get_section_label($section); + $file_content = file_get_contents($page); + $tex = + $content .= $parser->parse_html($page,$file_content); + } + + //var_dump($content); + file_put_contents("ch{$count}.tex", $content); + $count++; + echo "\n"; +} + +//$indexer->commit(); + +if($argc <= 1 && $count > 1) +{ + echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n"; + exit; +} +if($argv[1] == 'pdf') +{ + if(is_file($pdflatexExec)) + { + //build pdfTex + $command=sprintf($pdfTex,$mainTexFile); + system($command); + system($command); //run it twice + + echo "\n\n** PDF file quickstart.pdf created **\n\n"; + + } + else + { + echo " Unable to find pdfLatex executable $pdflatexExec"; + } +} + + +?> diff --git a/buildscripts/texbuilder/sqlmap/pages.php b/buildscripts/texbuilder/sqlmap/pages.php index adf788ff..57fff767 100644 --- a/buildscripts/texbuilder/sqlmap/pages.php +++ b/buildscripts/texbuilder/sqlmap/pages.php @@ -1,62 +1,62 @@ -<?php
-
-$pages['Introduction'] = array(
- 'Manual/Overview.page',
- 'Manual/BigPicture.page'
-);
-
-$pages['Installation and Setup'] = array(
- 'Manual/Installing.page',
- 'Manual/Configuring.page',
-// 'Manual/DataMapperConfiguration.page',
- 'Manual/ConfigurationElements.page'
-);
-
-$pages['SQLMap for PHP Tutorial'] = array(
- 'Manual/Tutorial/TestFirst.page',
- 'Manual/Tutorial/TestSecond.page',
- 'Manual/Tutorial/TestAgain.page'
-);
-
-$pages['Using SQLMap DataMapper'] = array(
- 'Manual/BuildingTSqlMapper.page',
- 'Manual/DataMapperAPI.page',
- 'Manual/CodingExamples.page'
-);
-
-$pages['Working with Data Maps'] = array(
- 'Manual/WorkingWithDataMaps.page',
-// 'Manual/DataMapDefinition.page',
- 'Manual/MappedStatements.page',
- 'Manual/TheSQL.page',
- 'Manual/StatementElementAttributes.page'
-);
-
-$pages['Parameter Maps and Inline Parameters'] = array(
- 'Manual/ParameterMap.page',
-// 'Manual/Parameter.page',
- 'Manual/InlineParameterMaps.page',
-// 'Manual/StandardTypeParameters.page',
-// 'Manual/ArrayTypeParameters.page'
-);
-
-$pages['Parameter Maps and Inline Parameters'] = array(
- 'Manual/ResultMaps.page',
-// 'Manual/ExtendingResultMaps.page',
- 'Manual/ResultMapAttributes.page',
-// 'Manual/ResultElements.page',
- 'Manual/CustomTypeHandlers.page',
- 'Manual/InheritanceMapping.page',
- 'Manual/ImplicitResultMaps.page',
- 'Manual/ComplexProperties.page',
- 'Manual/CompositeKeys.page'
-);
-
-$pages['Advanced Topics'] = array(
- 'Manual/CacheModels.page',
- 'Manual/DynamicSQL.page'
-);
-
-return $pages;
-
+<?php + +$pages['Introduction'] = array( + 'Manual/Overview.page', + 'Manual/BigPicture.page' +); + +$pages['Installation and Setup'] = array( + 'Manual/Installing.page', + 'Manual/Configuring.page', +// 'Manual/DataMapperConfiguration.page', + 'Manual/ConfigurationElements.page' +); + +$pages['SQLMap for PHP Tutorial'] = array( + 'Manual/Tutorial/TestFirst.page', + 'Manual/Tutorial/TestSecond.page', + 'Manual/Tutorial/TestAgain.page' +); + +$pages['Using SQLMap DataMapper'] = array( + 'Manual/BuildingTSqlMapper.page', + 'Manual/DataMapperAPI.page', + 'Manual/CodingExamples.page' +); + +$pages['Working with Data Maps'] = array( + 'Manual/WorkingWithDataMaps.page', +// 'Manual/DataMapDefinition.page', + 'Manual/MappedStatements.page', + 'Manual/TheSQL.page', + 'Manual/StatementElementAttributes.page' +); + +$pages['Parameter Maps and Inline Parameters'] = array( + 'Manual/ParameterMap.page', +// 'Manual/Parameter.page', + 'Manual/InlineParameterMaps.page', +// 'Manual/StandardTypeParameters.page', +// 'Manual/ArrayTypeParameters.page' +); + +$pages['Parameter Maps and Inline Parameters'] = array( + 'Manual/ResultMaps.page', +// 'Manual/ExtendingResultMaps.page', + 'Manual/ResultMapAttributes.page', +// 'Manual/ResultElements.page', + 'Manual/CustomTypeHandlers.page', + 'Manual/InheritanceMapping.page', + 'Manual/ImplicitResultMaps.page', + 'Manual/ComplexProperties.page', + 'Manual/CompositeKeys.page' +); + +$pages['Advanced Topics'] = array( + 'Manual/CacheModels.page', + 'Manual/DynamicSQL.page' +); + +return $pages; + ?>
\ No newline at end of file diff --git a/buildscripts/texbuilder/time-tracker/pages.php b/buildscripts/texbuilder/time-tracker/pages.php index 5ec3335a..732f675d 100644 --- a/buildscripts/texbuilder/time-tracker/pages.php +++ b/buildscripts/texbuilder/time-tracker/pages.php @@ -1,18 +1,18 @@ -<?php
-
-//list page into chapters
-$pages['Getting Started'] = array(
- 'Docs/Introduction.page',
- 'Docs/GettingStarted.page',
- 'Docs/WritingUnitTest.page',
- 'Docs/WritingFunctionalTest.page'
- );
-
-$pages['Testing Business Code'] = array(
- 'Docs/CreateBusinessCode.page',
- 'Docs/UsingSQLMap.page',
- 'Docs/UserClassAndExceptions.page'
- );
-return $pages;
-
+<?php + +//list page into chapters +$pages['Getting Started'] = array( + 'Docs/Introduction.page', + 'Docs/GettingStarted.page', + 'Docs/WritingUnitTest.page', + 'Docs/WritingFunctionalTest.page' + ); + +$pages['Testing Business Code'] = array( + 'Docs/CreateBusinessCode.page', + 'Docs/UsingSQLMap.page', + 'Docs/UserClassAndExceptions.page' + ); +return $pages; + ?>
\ No newline at end of file |