You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/08/02 16:11:44 UTC

svn commit: r681982 [17/27] - in /incubator/shindig/trunk/php: external/ external/PHPUnit/ external/PHPUnit/Extensions/ external/PHPUnit/Extensions/Database/ external/PHPUnit/Extensions/Database/Constraint/ external/PHPUnit/Extensions/Database/DB/ exte...

Added: incubator/shindig/trunk/php/external/PHPUnit/TextUI/Command.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/TextUI/Command.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/TextUI/Command.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/TextUI/Command.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,529 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, 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, 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.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: Command.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/TextUI/TestRunner.php';
+require_once 'PHPUnit/Util/Log/PMD.php';
+require_once 'PHPUnit/Util/Log/TAP.php';
+require_once 'PHPUnit/Util/Configuration.php';
+require_once 'PHPUnit/Util/Fileloader.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Getopt.php';
+require_once 'PHPUnit/Util/Skeleton.php';
+require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestRunner for the Command Line Interface (CLI)
+ * PHP SAPI Module.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.0.0
+ */
+class PHPUnit_TextUI_Command
+{
+    /**
+     * @access public
+     * @static
+     */
+    public static function main()
+    {
+        $arguments = self::handleArguments();
+        $runner    = new PHPUnit_TextUI_TestRunner;
+
+        if (is_object($arguments['test']) && $arguments['test'] instanceof PHPUnit_Framework_Test) {
+            $suite = $arguments['test'];
+        } else {
+            $suite = $runner->getTest(
+              $arguments['test'],
+              $arguments['testFile'],
+              $arguments['syntaxCheck']
+            );
+        }
+
+        if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning &&
+            strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
+            $skeleton = new PHPUnit_Util_Skeleton(
+                $arguments['test'],
+                $arguments['testFile']
+            );
+
+            $result = $skeleton->generate(TRUE);
+
+            if (!$result['incomplete']) {
+                eval(str_replace(array('<?php', '?>'), '', $result['code']));
+                $suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
+            }
+        }
+
+        try {
+            $result = $runner->doRun(
+              $suite,
+              $arguments
+            );
+        }
+
+        catch (Exception $e) {
+            throw new RuntimeException(
+              'Could not create and run test suite: ' . $e->getMessage()
+            );
+        }
+
+        if ($result->wasSuccessful()) {
+            exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
+        }
+
+        else if($result->errorCount() > 0) {
+            exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
+        }
+
+        else {
+            exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
+        }
+    }
+
+    /**
+     * @access protected
+     * @static
+     */
+    protected static function handleArguments()
+    {
+        $arguments = array('syntaxCheck' => TRUE);
+
+        $longOptions = array(
+          'configuration=',
+          'exclude-group=',
+          'filter=',
+          'group=',
+          'help',
+          'loader=',
+          'log-json=',
+          'log-tap=',
+          'log-xml=',
+          'repeat=',
+          'skeleton',
+          'stop-on-failure',
+          'tap',
+          'testdox',
+          'testdox-html=',
+          'testdox-text=',
+          'no-syntax-check',
+          'verbose',
+          'version',
+          'wait'
+        );
+
+        if (class_exists('Image_GraphViz', FALSE)) {
+            $longOptions[] = 'log-graphviz=';
+        }
+
+        if (extension_loaded('pdo')) {
+            $longOptions[] = 'test-db-dsn=';
+            $longOptions[] = 'test-db-log-rev=';
+            $longOptions[] = 'test-db-log-prefix=';
+            $longOptions[] = 'test-db-log-info=';
+        }
+
+        if (extension_loaded('xdebug')) {
+            $longOptions[] = 'coverage-html=';
+            $longOptions[] = 'coverage-xml=';
+            $longOptions[] = 'log-metrics=';
+            $longOptions[] = 'log-pmd=';
+            $longOptions[] = 'report=';
+        }
+
+        try {
+            $options = PHPUnit_Util_Getopt::getopt(
+              $_SERVER['argv'],
+              'd:',
+              $longOptions
+            );
+        }
+
+        catch (RuntimeException $e) {
+            PHPUnit_TextUI_TestRunner::showError($e->getMessage());
+        }
+
+        if (isset($options[1][0])) {
+            $arguments['test'] = $options[1][0];
+        }
+
+        if (isset($options[1][1])) {
+            $arguments['testFile'] = $options[1][1];
+        } else {
+            $arguments['testFile'] = '';
+        }
+
+        foreach ($options[0] as $option) {
+            switch ($option[0]) {
+                case '--configuration': {
+                    $arguments['configuration'] = $option[1];
+                }
+                break;
+
+                case '--coverage-xml': {
+                    $arguments['coverageXML'] = $option[1];
+                }
+                break;
+
+                case 'd': {
+                    $ini = explode('=', $option[1]);
+
+                    if (isset($ini[0])) {
+                        if (isset($ini[1])) {
+                            ini_set($ini[0], $ini[1]);
+                        } else {
+                            ini_set($ini[0], TRUE);
+                        }
+                    }
+                }
+                break;
+
+                case '--help': {
+                    self::showHelp();
+                    exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
+                }
+                break;
+
+                case '--filter': {
+                    if (preg_match('/^[a-zA-Z0-9_]/', $option[1])) {
+                        $arguments['filter'] = '/^' . $option[1] . '$/';
+                    } else {
+                        $arguments['filter'] = $option[1];
+                    }
+                }
+                break;
+
+                case '--group': {
+                    $arguments['groups'] = explode(',', $option[1]);
+                }
+                break;
+
+                case '--exclude-group': {
+                    $arguments['excludeGroups'] = explode(',', $option[1]);
+                }
+                break;
+
+                case '--loader': {
+                    self::handleLoader($option[1]);
+                }
+                break;
+
+                case '--log-json': {
+                    $arguments['jsonLogfile'] = $option[1];
+                }
+                break;
+
+                case '--log-graphviz': {
+                    $arguments['graphvizLogfile'] = $option[1];
+                }
+                break;
+
+                case '--log-tap': {
+                    $arguments['tapLogfile'] = $option[1];
+                }
+                break;
+
+                case '--log-xml': {
+                    $arguments['xmlLogfile'] = $option[1];
+                }
+                break;
+
+                case '--log-pmd': {
+                    $arguments['pmdXML'] = $option[1];
+                }
+                break;
+
+                case '--log-metrics': {
+                    $arguments['metricsXML'] = $option[1];
+                }
+                break;
+
+                case '--repeat': {
+                    $arguments['repeat'] = (int)$option[1];
+                }
+                break;
+
+                case '--stop-on-failure': {
+                    $arguments['stopOnFailure'] = TRUE;
+                }
+                break;
+
+                case '--test-db-dsn': {
+                    $arguments['testDatabaseDSN'] = $option[1];
+                }
+                break;
+
+                case '--test-db-log-rev': {
+                    $arguments['testDatabaseLogRevision'] = $option[1];
+                }
+                break;
+
+                case '--test-db-prefix': {
+                    $arguments['testDatabasePrefix'] = $option[1];
+                }
+                break;
+
+                case '--test-db-log-info': {
+                    $arguments['testDatabaseLogInfo'] = $option[1];
+                }
+                break;
+
+                case '--coverage-html':
+                case '--report': {
+                    $arguments['reportDirectory'] = $option[1];
+                }
+                break;
+
+                case '--skeleton': {
+                    if (isset($arguments['test']) && isset($arguments['testFile'])) {
+                        self::doSkeleton($arguments['test'], $arguments['testFile']);
+                    } else {
+                        self::showHelp();
+                        exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
+                    }
+                }
+                break;
+
+                case '--tap': {
+                    $arguments['printer'] = new PHPUnit_Util_Log_TAP;
+                }
+                break;
+
+                case '--testdox': {
+                    $arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text;
+                }
+                break;
+
+                case '--testdox-html': {
+                    $arguments['testdoxHTMLFile'] = $option[1];
+                }
+                break;
+
+                case '--testdox-text': {
+                    $arguments['testdoxTextFile'] = $option[1];
+                }
+                break;
+
+                case '--no-syntax-check': {
+                    $arguments['syntaxCheck'] = FALSE;
+                }
+                break;
+
+                case '--verbose': {
+                    $arguments['verbose'] = TRUE;
+                }
+                break;
+
+                case '--version': {
+                    PHPUnit_TextUI_TestRunner::printVersionString();
+                    exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
+                }
+                break;
+
+                case '--wait': {
+                    $arguments['wait'] = TRUE;
+                }
+                break;
+            }
+        }
+
+        if (!isset($arguments['test']) && isset($arguments['configuration'])) {
+            $configuration = new PHPUnit_Util_Configuration(
+              $arguments['configuration']
+            );
+
+            $testSuite = $configuration->getTestSuiteConfiguration();
+
+            if ($testSuite !== NULL) {
+                $arguments['test'] = $testSuite;
+            }
+        }
+
+        if (!isset($arguments['test']) ||
+            (isset($arguments['testDatabaseLogRevision']) && !isset($arguments['testDatabaseDSN']))) {
+            self::showHelp();
+            exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
+        }
+
+        return $arguments;
+    }
+
+    /**
+     * @param  string  $test
+     * @param  string  $testFile
+     * @access protected
+     * @static
+     */
+    protected static function doSkeleton($test, $testFile)
+    {
+        if ($test !== FALSE) {
+            PHPUnit_TextUI_TestRunner::printVersionString();
+
+            try {
+                $skeleton = new PHPUnit_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,
+                  $testFile
+                );
+
+                exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
+            }
+
+            printf(
+              'Wrote test class skeleton for "%s" to "%s".' . "\n",
+              $test,
+              $skeleton->getTestSourceFile()
+            );
+
+            exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
+        }
+    }
+
+    /**
+     * @param  string  $loaderName
+     * @access protected
+     * @static
+     */
+    protected static function handleLoader($loaderName)
+    {
+        if (!class_exists($loaderName, FALSE)) {
+            PHPUnit_Util_Fileloader::checkAndLoad(
+              str_replace('_', '/', $loaderName) . '.php'
+            );
+        }
+
+        if (class_exists($loaderName, FALSE)) {
+            $class = new ReflectionClass($loaderName);
+
+            if ($class->implementsInterface('PHPUnit_Runner_TestSuiteLoader') &&
+                $class->isInstantiable()) {
+                $loader = $class->newInstance();
+            }
+        }
+
+        if (!isset($loader)) {
+            PHPUnit_TextUI_TestRunner::showError(
+              sprintf(
+                'Could not use "%s" as loader.',
+
+                $loaderName
+              )
+            );
+        }
+
+        PHPUnit_TextUI_TestRunner::setLoader($loader);
+    }
+
+    /**
+     * @access public
+     * @static
+     */
+    public static function showHelp()
+    {
+        PHPUnit_TextUI_TestRunner::printVersionString();
+
+        print "Usage: phpunit [switches] UnitTest [UnitTest.php]\n\n";
+
+        if (class_exists('Image_GraphViz', FALSE)) {
+            print "  --log-graphviz <file>  Log test execution in GraphViz markup.\n";
+        }
+
+        print "  --log-json <file>      Log test execution in JSON format.\n" .
+              "  --log-tap <file>       Log test execution in TAP format to file.\n" .
+              "  --log-xml <file>       Log test execution in XML format to file.\n";
+
+        if (extension_loaded('xdebug')) {
+            print "  --log-metrics <file>   Write metrics report in XML format.\n" .
+                  "  --log-pmd <file>       Write violations report in PMD XML format.\n\n" .
+                  "  --coverage-html <dir>  Generate code coverage report in HTML format.\n" .
+                  "  --coverage-xml <file>  Write code coverage information in XML format.\n\n";
+        }
+
+        if (extension_loaded('pdo')) {
+            print "  --test-db-dsn <dsn>    DSN for the test database.\n" .
+                  "  --test-db-log-rev <r>  Revision information for database logging.\n" .
+                  "  --test-db-prefix ...   Prefix that should be stripped from filenames.\n" .
+                  "  --test-db-log-info ... Additional information for database logging.\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\n" .
+              "  --filter <pattern>     Filter which tests to run.\n" .
+              "  --group ...            Only runs tests from the specified group(s).\n" .
+              "  --exclude-group ...    Exclude tests from the specified group(s).\n\n" .
+              "  --loader <loader>      TestSuiteLoader implementation to use.\n" .
+              "  --repeat <times>       Runs the test(s) repeatedly.\n\n" .
+              "  --tap                  Report test execution progress in TAP format.\n" .
+              "  --testdox              Report test execution progress in TestDox format.\n\n" .
+              "  --no-syntax-check      Disable syntax check of test source files.\n" .
+              "  --stop-on-failure      Stop execution upon first error or failure.\n" .
+              "  --verbose              Output more verbose information.\n" .
+              "  --wait                 Waits for a keystroke after each test.\n\n" .
+              "  --skeleton             Generate skeleton UnitTest class for Unit in Unit.php.\n\n" .
+              "  --help                 Prints this usage information.\n" .
+              "  --version              Prints the version and exits.\n\n" .
+              "  --configuration <file> Read configuration from XML file.\n" .
+              "  -d key[=value]         Sets a php.ini value.\n";
+    }
+}
+
+define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
+PHPUnit_TextUI_Command::main();
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/TextUI/ResultPrinter.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/TextUI/ResultPrinter.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/TextUI/ResultPrinter.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/TextUI/ResultPrinter.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,567 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, 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, 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.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: ResultPrinter.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Printer.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Prints the result of a TextUI TestRunner run.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 2.0.0
+ */
+class PHPUnit_TextUI_ResultPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener
+{
+    const EVENT_TEST_START      = 0;
+    const EVENT_TEST_END        = 1;
+    const EVENT_TESTSUITE_START = 2;
+    const EVENT_TESTSUITE_END   = 3;
+
+    /**
+     * @var    integer
+     * @access protected
+     */
+    protected $column = 0;
+
+    /**
+     * @var    array
+     * @access protected
+     */
+    protected $numberOfTests = array();
+
+    /**
+     * @var    array
+     * @access protected
+     */
+    protected $testSuiteSize = array();
+
+    /**
+     * @var    integer
+     * @access protected
+     */
+    protected $lastEvent = -1;
+
+    /**
+     * @var    boolean
+     * @access protected
+     */
+    protected $lastTestFailed = FALSE;
+
+    /**
+     * @var    boolean
+     * @access protected
+     */
+    protected $verbose = FALSE;
+
+    /**
+     * Constructor.
+     *
+     * @param  mixed   $out
+     * @param  boolean $verbose
+     * @throws InvalidArgumentException
+     * @access public
+     * @since  Method available since Release 3.0.0
+     */
+    public function __construct($out = NULL, $verbose = FALSE)
+    {
+        parent::__construct($out);
+
+        if (is_bool($verbose)) {
+            $this->verbose = $verbose;
+        } else {
+            throw new InvalidArgumentException;
+        }
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult $result
+     * @access public
+     */
+    public function printResult(PHPUnit_Framework_TestResult $result)
+    {
+        $this->printHeader($result->time());
+
+        if ($result->errorCount() > 0) {
+            $this->printErrors($result);
+        }
+
+        if ($result->failureCount() > 0) {
+            if ($result->errorCount() > 0) {
+                print "\n--\n\n";
+            }
+
+            $this->printFailures($result);
+        }
+
+        if ($this->verbose) {
+            if ($result->notImplementedCount() > 0) {
+                if ($result->failureCount() > 0) {
+                    print "\n--\n\n";
+                }
+
+                $this->printIncompletes($result);
+            }
+
+            if ($result->skippedCount() > 0) {
+                if ($result->notImplementedCount() > 0) {
+                    print "\n--\n\n";
+                }
+
+                $this->printSkipped($result);
+            }
+        }
+
+        $this->printFooter($result);
+    }
+
+    /**
+     * @param  array   $defects
+     * @param  integer $count
+     * @param  string  $type
+     * @access protected
+     */
+    protected function printDefects(array $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  PHPUnit_Framework_TestFailure $defect
+     * @param  integer                       $count
+     * @access protected
+     */
+    protected function printDefect(PHPUnit_Framework_TestFailure $defect, $count)
+    {
+        $this->printDefectHeader($defect, $count);
+        $this->printDefectTrace($defect);
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestFailure $defect
+     * @param  integer                       $count
+     * @access protected
+     */
+    protected function printDefectHeader(PHPUnit_Framework_TestFailure $defect, $count)
+    {
+        $failedTest = $defect->failedTest();
+
+        if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) {
+            $testName = $failedTest->toString();
+        } else {
+            $testName = get_class($failedTest);
+        }
+
+        $this->write(
+          sprintf(
+            "\n%d) %s\n",
+
+            $count,
+            $testName
+          )
+        );
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestFailure $defect
+     * @access protected
+     */
+    protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
+    {
+        $this->write(
+          $defect->toStringVerbose($this->verbose) .
+          PHPUnit_Util_Filter::getFilteredStacktrace(
+            $defect->thrownException(),
+            FALSE
+          )
+        );
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult  $result
+     * @access protected
+     */
+    protected function printErrors(PHPUnit_Framework_TestResult $result)
+    {
+        $this->printDefects($result->errors(), $result->errorCount(), 'error');
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult  $result
+     * @access protected
+     */
+    protected function printFailures(PHPUnit_Framework_TestResult $result)
+    {
+        $this->printDefects($result->failures(), $result->failureCount(), 'failure');
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult  $result
+     * @access protected
+     */
+    protected function printIncompletes(PHPUnit_Framework_TestResult $result)
+    {
+        $this->printDefects($result->notImplemented(), $result->notImplementedCount(), 'incomplete test');
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult  $result
+     * @access protected
+     * @since  Method available since Release 3.0.0
+     */
+    protected function printSkipped(PHPUnit_Framework_TestResult $result)
+    {
+        $this->printDefects($result->skipped(), $result->skippedCount(), 'skipped test');
+    }
+
+    /**
+     * @param  float   $timeElapsed
+     * @access protected
+     */
+    protected function printHeader($timeElapsed)
+    {
+        $this->write("\n\nTime: " . PHPUnit_Util_Timer::secondsToTimeString($timeElapsed) . "\n\n");
+    }
+
+    /**
+     * @param  PHPUnit_Framework_TestResult  $result
+     * @access protected
+     */
+    protected function printFooter(PHPUnit_Framework_TestResult $result)
+    {
+        if ($result->wasSuccessful() &&
+            $result->allCompletlyImplemented() &&
+            $result->noneSkipped()) {
+            $this->write(
+              sprintf(
+                "\nOK (%d test%s)\n",
+
+                count($result),
+                (count($result) == 1) ? '' : 's'
+              )
+            );
+        }
+
+        else if ((!$result->allCompletlyImplemented() ||
+                  !$result->noneSkipped())&&
+                 $result->wasSuccessful()) {
+            $this->write(
+              sprintf(
+                "\nOK, but incomplete or skipped tests!\n" .
+                "Tests: %d%s%s.\n",
+
+                count($result),
+                $this->getCountString($result->notImplementedCount(), 'Incomplete'),
+                $this->getCountString($result->skippedCount(), 'Skipped')
+              )
+            );
+        }
+
+        else {
+            $this->write(
+              sprintf(
+                "\nFAILURES!\n" .
+                "Tests: %d%s%s%s%s.\n",
+
+                count($result),
+                $this->getCountString($result->failureCount(), 'Failures'),
+                $this->getCountString($result->errorCount(), 'Errors'),
+                $this->getCountString($result->notImplementedCount(), 'Incomplete'),
+                $this->getCountString($result->skippedCount(), 'Skipped')
+              )
+            );
+        }
+    }
+
+    /**
+     * @param  integer $count
+     * @param  string  $name
+     * @return string
+     * @access protected
+     * @since  Method available since Release 3.0.0
+     */
+    protected function getCountString($count, $name)
+    {
+        $string = '';
+
+        if ($count > 0) {
+            $string = sprintf(
+              ', %s: %d',
+
+              $name,
+              $count
+            );
+        }
+
+        return $string;
+    }
+
+    /**
+     * @access public
+     */
+    public function printWaitPrompt()
+    {
+        $this->write("\n<RETURN> to continue\n");
+    }
+
+    /**
+     * An error occurred.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     */
+    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        $this->writeProgress('E');
+        $this->lastTestFailed = TRUE;
+    }
+
+    /**
+     * A failure occurred.
+     *
+     * @param  PHPUnit_Framework_Test                 $test
+     * @param  PHPUnit_Framework_AssertionFailedError $e
+     * @param  float                                  $time
+     * @access public
+     */
+    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+    {
+        $this->writeProgress('F');
+        $this->lastTestFailed = TRUE;
+    }
+
+    /**
+     * Incomplete test.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     */
+    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        $this->writeProgress('I');
+        $this->lastTestFailed = TRUE;
+    }
+
+    /**
+     * Skipped test.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  Exception              $e
+     * @param  float                  $time
+     * @access public
+     * @since  Method available since Release 3.0.0
+     */
+    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+    {
+        $this->writeProgress('S');
+        $this->lastTestFailed = TRUE;
+    }
+
+    /**
+     * A testsuite started.
+     *
+     * @param  PHPUnit_Framework_TestSuite $suite
+     * @access public
+     * @since  Method available since Release 2.2.0
+     */
+    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+    {
+        if ($this->verbose) {
+            $name = $suite->getName();
+
+            if (empty($name)) {
+                $name = 'Test Suite';
+            }
+
+            $this->write(
+              sprintf(
+                "%s%s%s\n",
+
+                $this->lastEvent == self::EVENT_TESTSUITE_END ? "\n" : '',
+                str_repeat(' ', count($this->testSuiteSize)),
+                $name
+              )
+            );
+
+            array_push($this->numberOfTests, 0);
+            array_push($this->testSuiteSize, count($suite));
+        }
+
+        else if (empty($this->numberOfTests)) {
+            array_push($this->numberOfTests, 0);
+            array_push($this->testSuiteSize, count($suite));
+        }
+
+        $this->lastEvent = self::EVENT_TESTSUITE_START;
+    }
+
+    /**
+     * A testsuite ended.
+     *
+     * @param  PHPUnit_Framework_TestSuite $suite
+     * @access public
+     * @since  Method available since Release 2.2.0
+     */
+    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+    {
+        if ($this->verbose) {
+            array_pop($this->numberOfTests);
+            array_pop($this->testSuiteSize);
+
+            $this->column = 0;
+
+            if ($this->lastEvent != self::EVENT_TESTSUITE_END) {
+                $this->write("\n");
+            }
+        }
+
+        $this->lastEvent = self::EVENT_TESTSUITE_END;
+    }
+
+    /**
+     * A test started.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @access public
+     */
+    public function startTest(PHPUnit_Framework_Test $test)
+    {
+        if ($this->verbose) {
+            $this->numberOfTests[count($this->numberOfTests)-1]++;
+        } else {
+            $this->numberOfTests[0]++;
+        }
+
+        $this->lastEvent = self::EVENT_TEST_START;
+    }
+
+    /**
+     * A test ended.
+     *
+     * @param  PHPUnit_Framework_Test $test
+     * @param  float                  $time
+     * @access public
+     */
+    public function endTest(PHPUnit_Framework_Test $test, $time)
+    {
+        if (!$this->lastTestFailed) {
+            $this->writeProgress('.');
+        }
+
+        $this->lastEvent = self::EVENT_TEST_END;
+        $this->lastTestFailed = FALSE;
+    }
+
+    /**
+     * @param  string $progress
+     * @access protected
+     */
+    protected function writeProgress($progress)
+    {
+        $indent = max(0, count($this->testSuiteSize) - 1);
+
+        if ($this->column == 0) {
+            $this->write(str_repeat(' ', $indent));
+        }
+
+        $this->write($progress);
+
+        if ($this->column++ == 60 - 1 - $indent) {
+            if ($this->verbose) {
+                $numberOfTests = $this->numberOfTests[count($this->numberOfTests)-1];
+                $testSuiteSize = $this->testSuiteSize[count($this->testSuiteSize)-1];
+            } else {
+                $numberOfTests = $this->numberOfTests[0];
+                $testSuiteSize = $this->testSuiteSize[0];
+            }
+
+            $width = strlen((string)$testSuiteSize);
+
+            $this->write(
+              sprintf(
+                ' %' . $width . 'd / %' . $width . "d\n",
+
+                $numberOfTests,
+                $testSuiteSize
+              )
+            );
+
+            $this->column = 0;
+        }
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/TextUI/TestRunner.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/TextUI/TestRunner.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/TextUI/TestRunner.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/TextUI/TestRunner.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,745 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, 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, 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.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: TestRunner.php 2144 2008-01-17 10:53:25Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Runner/BaseTestRunner.php';
+require_once 'PHPUnit/Extensions/RepeatedTest.php';
+require_once 'PHPUnit/Runner/StandardTestSuiteLoader.php';
+require_once 'PHPUnit/Runner/Version.php';
+require_once 'PHPUnit/TextUI/ResultPrinter.php';
+require_once 'PHPUnit/Util/TestDox/ResultPrinter.php';
+require_once 'PHPUnit/Util/Configuration.php';
+require_once 'PHPUnit/Util/PDO.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Report.php';
+require_once 'PHPUnit/Util/Timer.php';
+require_once 'PHPUnit/Util/Log/CodeCoverage/Database.php';
+require_once 'PHPUnit/Util/Log/CodeCoverage/XML.php';
+require_once 'PHPUnit/Util/Log/CPD.php';
+require_once 'PHPUnit/Util/Log/Database.php';
+require_once 'PHPUnit/Util/Log/GraphViz.php';
+require_once 'PHPUnit/Util/Log/JSON.php';
+require_once 'PHPUnit/Util/Log/Metrics.php';
+require_once 'PHPUnit/Util/Log/TAP.php';
+require_once 'PHPUnit/Util/Log/PMD.php';
+require_once 'PHPUnit/Util/Log/XML.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestRunner for the Command Line Interface (CLI)
+ * PHP SAPI Module.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 2.0.0
+ */
+class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner
+{
+    const SUCCESS_EXIT   = 0;
+    const FAILURE_EXIT   = 1;
+    const EXCEPTION_EXIT = 2;
+
+    /**
+     * @var    PHPUnit_Runner_TestSuiteLoader
+     * @access protected
+     * @static
+     */
+    protected static $loader = NULL;
+
+    /**
+     * @var    PHPUnit_TextUI_ResultPrinter
+     * @access protected
+     */
+    protected $printer = NULL;
+
+    /**
+     * @var    boolean
+     * @access protected
+     * @static
+     */
+    protected static $versionStringPrinted = FALSE;
+
+    /**
+     * @param  mixed $test
+     * @param  array $arguments
+     * @throws InvalidArgumentException
+     * @access public
+     * @static
+     */
+    public static function run($test, array $arguments = array())
+    {
+        if ($test instanceof ReflectionClass) {
+            $test = new PHPUnit_Framework_TestSuite($test);
+        }
+
+        if ($test instanceof PHPUnit_Framework_Test) {
+            $aTestRunner = new PHPUnit_TextUI_TestRunner;
+
+            return $aTestRunner->doRun(
+              $test,
+              $arguments
+            );
+        } else {
+            throw new InvalidArgumentException(
+              'No test case or test suite found.'
+            );
+        }
+    }
+
+    /**
+     * Runs a single test and waits until the user types RETURN.
+     *
+     * @param  PHPUnit_Framework_Test $suite
+     * @access public
+     * @static
+     */
+    public static function runAndWait(PHPUnit_Framework_Test $suite)
+    {
+        $aTestRunner = new PHPUnit_TextUI_TestRunner;
+
+        $aTestRunner->doRun(
+          $suite,
+          array(
+            'wait' => TRUE
+          )
+        );
+
+    }
+
+    /**
+     * @return PHPUnit_Framework_TestResult
+     * @access protected
+     */
+    protected function createTestResult()
+    {
+        return new PHPUnit_Framework_TestResult;
+    }
+
+    /**
+     * @param  PHPUnit_Framework_Test $suite
+     * @param  array                  $arguments
+     * @return PHPUnit_Framework_TestResult
+     * @access public
+     */
+    public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
+    {
+        $this->handleConfiguration($arguments);
+
+        if (is_integer($arguments['repeat'])) {
+            $suite = new PHPUnit_Extensions_RepeatedTest(
+              $suite,
+              $arguments['repeat'],
+              $arguments['filter'],
+              $arguments['groups'],
+              $arguments['excludeGroups']
+            );
+        }
+
+        $result = $this->createTestResult();
+
+        if ($arguments['stopOnFailure']) {
+            $result->stopOnFailure(TRUE);
+        }
+
+        if ($this->printer === NULL) {
+            if (isset($arguments['printer']) &&
+                $arguments['printer'] instanceof PHPUnit_Util_Printer) {
+                $this->printer = $arguments['printer'];
+            } else {
+                $this->printer = new PHPUnit_TextUI_ResultPrinter(
+                  NULL, $arguments['verbose']
+                );
+            }
+        }
+
+        $this->printer->write(
+          PHPUnit_Runner_Version::getVersionString() . "\n\n"
+        );
+
+        foreach ($arguments['listeners'] as $listener) {
+            $result->addListener($listener);
+        }
+
+        $result->addListener($this->printer);
+
+        if (isset($arguments['testdoxHTMLFile'])) {
+            $result->addListener(
+              new PHPUnit_Util_TestDox_ResultPrinter_HTML(
+                $arguments['testdoxHTMLFile']
+              )
+            );
+        }
+
+        if (isset($arguments['testdoxTextFile'])) {
+            $result->addListener(
+              new PHPUnit_Util_TestDox_ResultPrinter_Text(
+                $arguments['testdoxTextFile']
+              )
+            );
+        }
+
+        if (isset($arguments['graphvizLogfile'])) {
+            if (class_exists('Image_GraphViz', FALSE)) {
+                $result->addListener(
+                  new PHPUnit_Util_Log_GraphViz($arguments['graphvizLogfile'])
+                );
+            }
+        }
+
+        if ((isset($arguments['coverageXML']) ||
+             isset($arguments['metricsXML'])  ||
+             isset($arguments['pmdXML'])) &&
+             extension_loaded('xdebug')) {
+            $result->collectCodeCoverageInformation(TRUE);
+        }
+
+        if (isset($arguments['reportDirectory']) &&
+            extension_loaded('xdebug')) {
+            $result->collectCodeCoverageInformation(TRUE);
+        }
+
+        if (isset($arguments['jsonLogfile'])) {
+            $result->addListener(
+              new PHPUnit_Util_Log_JSON($arguments['jsonLogfile'])
+            );
+        }
+
+        if (isset($arguments['tapLogfile'])) {
+            $result->addListener(
+              new PHPUnit_Util_Log_TAP($arguments['tapLogfile'])
+            );
+        }
+
+        if (isset($arguments['xmlLogfile'])) {
+            $result->addListener(
+              new PHPUnit_Util_Log_XML(
+                $arguments['xmlLogfile'], $arguments['logIncompleteSkipped']
+              )
+            );
+        }
+
+        if (isset($arguments['testDatabaseDSN']) &&
+            isset($arguments['testDatabaseLogRevision']) &&
+            extension_loaded('pdo')) {
+            $writeToTestDatabase = TRUE;
+        } else {
+            $writeToTestDatabase = FALSE;
+        }
+
+        if ($writeToTestDatabase) {
+            $dbh = PHPUnit_Util_PDO::factory($arguments['testDatabaseDSN']);
+
+            $dbListener = PHPUnit_Util_Log_Database::getInstance(
+              $dbh,
+              $arguments['testDatabaseLogRevision'],
+              isset($arguments['testDatabaseLogInfo']) ? $arguments['testDatabaseLogInfo'] : ''
+            );
+
+            $result->addListener($dbListener);
+            $result->collectCodeCoverageInformation(TRUE);
+        }
+
+        $suite->run(
+          $result,
+          $arguments['filter'],
+          $arguments['groups'],
+          $arguments['excludeGroups']
+        );
+
+        $result->flushListeners();
+
+        if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
+            $this->printer->printResult($result);
+        }
+
+        if (isset($arguments['coverageXML']) &&
+            extension_loaded('tokenizer') &&
+            extension_loaded('xdebug')) {
+            $this->printer->write("\nWriting code coverage data to XML file, this may take a moment.");
+
+            $writer = new PHPUnit_Util_Log_CodeCoverage_XML(
+              $arguments['coverageXML']
+            );
+
+            $writer->process($result);
+            $this->printer->write("\n");
+        }
+
+        if ($writeToTestDatabase &&
+            extension_loaded('tokenizer') &&
+            extension_loaded('xdebug')) {
+            $this->printer->write("\nStoring code coverage and software metrics data in database.\nThis may take a moment.");
+
+            $testDb = new PHPUnit_Util_Log_CodeCoverage_Database($dbh);
+            $testDb->storeCodeCoverage(
+              $result,
+              $dbListener->getRunId(),
+              $arguments['testDatabaseLogRevision'],
+              $arguments['testDatabasePrefix']
+            );
+
+            $this->printer->write("\n");
+        }
+
+        if (isset($arguments['metricsXML']) &&
+            extension_loaded('tokenizer') &&
+            extension_loaded('xdebug')) {
+            $this->printer->write("\nWriting metrics report XML file, this may take a moment.");
+
+            $writer = new PHPUnit_Util_Log_Metrics(
+              $arguments['metricsXML']
+            );
+
+            $writer->process($result);
+            $this->printer->write("\n");
+        }
+
+        if (isset($arguments['pmdXML']) &&
+            extension_loaded('tokenizer') &&
+            extension_loaded('xdebug')) {
+            $writer = new PHPUnit_Util_Log_PMD(
+              $arguments['pmdXML'], $arguments['pmd']
+            );
+
+            $this->printer->write("\nWriting violations report XML file, this may take a moment.");
+            $writer->process($result);
+
+            $writer = new PHPUnit_Util_Log_CPD(
+              str_replace('.xml', '-cpd.xml', $arguments['pmdXML'])
+            );
+
+            $writer->process(
+              $result, $arguments['cpdMinLines'], $arguments['cpdMinMatches']
+            );
+
+            $this->printer->write("\n");
+        }
+
+        if (isset($arguments['reportDirectory']) &&
+            extension_loaded('xdebug')) {
+            $this->printer->write("\nGenerating code coverage report, this may take a moment.");
+
+            PHPUnit_Util_Report::render(
+              $result,
+              $arguments['reportDirectory'],
+              $arguments['reportCharset'],
+              $arguments['reportYUI'],
+              $arguments['reportHighlight'],
+              $arguments['reportLowUpperBound'],
+              $arguments['reportHighLowerBound']
+            );
+
+            $this->printer->write("\n");
+        }
+
+        $this->pause($arguments['wait']);
+
+        return $result;
+    }
+
+    /**
+     * @param  boolean $wait
+     * @access protected
+     */
+    protected function pause($wait)
+    {
+        if (!$wait) {
+            return;
+        }
+
+        if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
+            $this->printer->printWaitPrompt();
+        }
+
+        fgets(STDIN);
+    }
+
+    /**
+     * @param  PHPUnit_TextUI_ResultPrinter $resultPrinter
+     * @access public
+     */
+    public function setPrinter(PHPUnit_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  PHPUnit_Framework_Test                 $test
+     * @param  PHPUnit_Framework_AssertionFailedError $e
+     * @access public
+     */
+    public function testFailed($status, PHPUnit_Framework_Test $test, PHPUnit_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();
+        self::write($message);
+        exit(self::FAILURE_EXIT);
+    }
+
+    /**
+     * @param  string $directory
+     * @return string
+     * @throws RuntimeException
+     * @access protected
+     * @since  Method available since Release 3.0.0
+     */
+    protected function getDirectory($directory)
+    {
+        if (substr($directory, -1, 1) != DIRECTORY_SEPARATOR) {
+            $directory .= DIRECTORY_SEPARATOR;
+        }
+
+        if (is_dir($directory) || mkdir($directory, 0777, TRUE)) {
+            return $directory;
+        } else {
+            throw new RuntimeException(
+              sprintf(
+                'Directory "%s" does not exist.',
+                $directory
+              )
+            );
+        }
+    }
+
+    /**
+     * @param  string $buffer
+     * @access protected
+     * @since  Method available since Release 3.1.0
+     */
+    protected static function write($buffer)
+    {
+        if (php_sapi_name() != 'cli') {
+            $buffer = htmlentities($buffer);
+        }
+
+        print $buffer;
+    }
+
+    /**
+     * Returns the loader to be used.
+     *
+     * @return PHPUnit_Runner_TestSuiteLoader
+     * @access public
+     * @since  Method available since Release 2.2.0
+     */
+    public function getLoader()
+    {
+        if (self::$loader === NULL) {
+            self::$loader = new PHPUnit_Runner_StandardTestSuiteLoader;
+        }
+
+        return self::$loader;
+    }
+
+    /**
+     * Sets the loader to be used.
+     *
+     * @param PHPUnit_Runner_TestSuiteLoader $loader
+     * @access public
+     * @static
+     * @since  Method available since Release 3.0.0
+     */
+    public static function setLoader(PHPUnit_Runner_TestSuiteLoader $loader)
+    {
+        self::$loader = $loader;
+    }
+
+    /**
+     * @access public
+     */
+    public static function showError($message)
+    {
+        self::printVersionString();
+        self::write($message . "\n");
+
+        exit(self::FAILURE_EXIT);
+    }
+
+
+    /**
+     * @access public
+     * @static
+     */
+    public static function printVersionString()
+    {
+        if (!self::$versionStringPrinted) {
+            self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
+            self::$versionStringPrinted = TRUE;
+        }
+    }
+
+    /**
+     * @param  array $arguments
+     * @access protected
+     * @since  Method available since Release 3.2.1
+     */
+    protected function handleConfiguration(array &$arguments)
+    {
+        if (isset($arguments['configuration'])) {
+            $arguments['configuration'] = new PHPUnit_Util_Configuration(
+              $arguments['configuration']
+            );
+
+            $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration();
+        } else {
+            $arguments['pmd'] = array();
+        }
+
+        $arguments['filter']             = isset($arguments['filter'])             ? $arguments['filter']             : FALSE;
+        $arguments['listeners']          = isset($arguments['listeners'])          ? $arguments['listeners']          : array();
+        $arguments['repeat']             = isset($arguments['repeat'])             ? $arguments['repeat']             : FALSE;
+        $arguments['stopOnFailure']      = isset($arguments['stopOnFailure'])      ? $arguments['stopOnFailure']      : FALSE;
+        $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
+        $arguments['verbose']            = isset($arguments['verbose'])            ? $arguments['verbose']            : FALSE;
+        $arguments['wait']               = isset($arguments['wait'])               ? $arguments['wait']               : FALSE;
+
+        if (isset($arguments['configuration'])) {
+            $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
+
+            PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
+
+            foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
+                PHPUnit_Util_Filter::addDirectoryToFilter(
+                  $dir['path'], $dir['suffix']
+                );
+            }
+
+            foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
+                PHPUnit_Util_Filter::addFileToFilter($file);
+            }
+
+            foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
+                PHPUnit_Util_Filter::removeDirectoryFromFilter(
+                  $dir['path'], $dir['suffix']
+                );
+            }
+
+            foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
+                PHPUnit_Util_Filter::removeFileFromFilter($file);
+            }
+
+            foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
+                PHPUnit_Util_Filter::addDirectoryToWhitelist(
+                  $dir['path'], $dir['suffix']
+                );
+            }
+
+            foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
+                PHPUnit_Util_Filter::addFileToWhitelist($file);
+            }
+
+            foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
+                PHPUnit_Util_Filter::removeDirectoryFromWhitelist(
+                  $dir['path'], $dir['suffix']
+                );
+            }
+
+            foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
+                PHPUnit_Util_Filter::removeFileFromWhitelist($file);
+            }
+
+            $phpConfiguration = $arguments['configuration']->getPHPConfiguration();
+
+            foreach ($phpConfiguration['ini'] as $name => $value) {
+                ini_set($name, $value);
+            }
+
+            foreach ($phpConfiguration['var'] as $name => $value) {
+                $GLOBALS[$name] = $value;
+            }
+
+            $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
+
+            if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
+                $arguments['groups'] = $groupConfiguration['include'];
+            }
+
+            if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
+                $arguments['excludeGroups'] = $groupConfiguration['exclude'];
+            }
+
+            $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
+
+            if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
+                if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
+                    $arguments['reportCharset'] = $loggingConfiguration['charset'];
+                }
+
+                if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
+                    $arguments['reportYUI'] = $loggingConfiguration['yui'];
+                }
+
+                if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
+                    $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
+                }
+
+                if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
+                    $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
+                }
+
+                if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
+                    $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
+                }
+
+                $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
+            }
+
+            if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXML'])) {
+                $arguments['coverageXML'] = $loggingConfiguration['coverage-xml'];
+            }
+
+            if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
+                $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
+            }
+
+            if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
+                $arguments['jsonLogfile'] = $loggingConfiguration['json'];
+            }
+
+            if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
+                $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
+            }
+
+            if (isset($loggingConfiguration['plain'])) {
+                $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
+            }
+
+            if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
+                if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
+                    $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
+                }
+
+                if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
+                    $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
+                }
+
+                $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
+            }
+
+            if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
+                $arguments['tapLogfile'] = $loggingConfiguration['tap'];
+            }
+
+            if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
+                $arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
+
+                if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
+                    $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
+                }
+            }
+
+            if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
+                $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
+            }
+
+            if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
+                $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
+            }
+
+            $browsers = $arguments['configuration']->getSeleniumBrowserConfiguration();
+
+            if (!empty($browsers)) {
+                require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
+                PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
+            }
+        }
+
+        $arguments['cpdMinLines']          = isset($arguments['cpdMinLines'])          ? $arguments['cpdMinLines']          : 5;
+        $arguments['cpdMinMatches']        = isset($arguments['cpdMinMatches'])        ? $arguments['cpdMinMatches']        : 70;
+        $arguments['groups']               = isset($arguments['groups'])               ? $arguments['groups']               : array();
+        $arguments['excludeGroups']        = isset($arguments['excludeGroups'])        ? $arguments['excludeGroups']        : array();
+        $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
+        $arguments['reportCharset']        = isset($arguments['reportCharset'])        ? $arguments['reportCharset']        : 'ISO-8859-1';
+        $arguments['reportYUI']            = isset($arguments['reportYUI'])            ? $arguments['reportYUI']            : TRUE;
+        $arguments['reportHighlight']      = isset($arguments['reportHighlight'])      ? $arguments['reportHighlight']      : FALSE;
+        $arguments['reportLowUpperBound']  = isset($arguments['reportLowUpperBound'])  ? $arguments['reportLowUpperBound']  : 35;
+        $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
+
+        if (isset($arguments['reportDirectory'])) {
+            $arguments['reportDirectory'] = $this->getDirectory($arguments['reportDirectory']);
+        }
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/Class.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/Class.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/Class.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/Class.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,417 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, 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, 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.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: Class.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.1.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Class helpers.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.1.0
+ */
+class PHPUnit_Util_Class
+{
+    protected static $buffer = array();
+    protected static $fileClassMap = array();
+    protected static $fileFunctionMap = array();
+
+    /**
+     * Starts the collection of loaded classes.
+     *
+     * @access public
+     * @static
+     */
+    public static function collectStart()
+    {
+        self::$buffer = get_declared_classes();
+    }
+
+    /**
+     * Stops the collection of loaded classes and
+     * returns the names of the loaded classes.
+     *
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function collectEnd()
+    {
+        return array_values(
+          array_diff(get_declared_classes(), self::$buffer)
+        );
+    }
+
+    /**
+     * Stops the collection of loaded classes and
+     * returns the names of the files that declare the loaded classes.
+     *
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function collectEndAsFiles()
+    {
+        $result = self::collectEnd();
+        $count  = count($result);
+
+        for ($i = 0; $i < $count; $i++) {
+            $class = new ReflectionClass($result[$i]);
+
+            if ($class->isUserDefined()) {
+                $file = $class->getFileName();
+
+                if (file_exists($file)) {
+                    $result[$i] = $file;
+                } else {
+                    unset($result[$i]);
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    /**
+     * Returns the names of the classes declared in a sourcefile.
+     *
+     * @param  string  $filename
+     * @param  string  $commonPath
+     * @param  boolean $clearCache
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getClassesInFile($filename, $commonPath = '', $clearCache = FALSE)
+    {
+        if ($commonPath != '') {
+            $filename = str_replace($commonPath, '', $filename);
+        }
+
+        if ($clearCache) {
+            self::$fileClassMap = array();
+        }
+
+        if (empty(self::$fileClassMap)) {
+            $classes = array_merge(get_declared_classes(), get_declared_interfaces());
+
+            foreach ($classes as $className) {
+                $class = new ReflectionClass($className);
+
+                if ($class->isUserDefined()) {
+                    $file = $class->getFileName();
+
+                    if ($commonPath != '') {
+                        $file = str_replace($commonPath, '', $file);
+                    }
+
+                    if (!isset(self::$fileClassMap[$file])) {
+                        self::$fileClassMap[$file] = array($class);
+                    } else {
+                        self::$fileClassMap[$file][] = $class;
+                    }
+                }
+            }
+        }
+
+        return isset(self::$fileClassMap[$filename]) ? self::$fileClassMap[$filename] : array();
+    }
+
+    /**
+     * Returns the names of the classes declared in a sourcefile.
+     *
+     * @param  string  $filename
+     * @param  string  $commonPath
+     * @param  boolean $clearCache
+     * @return array
+     * @access public
+     * @static
+     * @since  Class available since Release 3.2.0
+     * @todo   Find a better place for this method.
+     */
+    public static function getFunctionsInFile($filename, $commonPath = '', $clearCache = FALSE)
+    {
+        if ($commonPath != '') {
+            $filename = str_replace($commonPath, '', $filename);
+        }
+
+        if ($clearCache) {
+            self::$fileFunctionMap = array();
+        }
+
+        if (empty(self::$fileFunctionMap)) {
+            $functions = get_defined_functions();
+
+            foreach ($functions['user'] as $functionName) {
+                $function = new ReflectionFunction($functionName);
+
+                $file = $function->getFileName();
+
+                if ($commonPath != '') {
+                    $file = str_replace($commonPath, '', $file);
+                }
+
+                if (!isset(self::$fileFunctionMap[$file])) {
+                    self::$fileFunctionMap[$file] = array($function);
+                } else {
+                    self::$fileFunctionMap[$file][] = $function;
+                }
+            }
+        }
+
+        return isset(self::$fileFunctionMap[$filename]) ? self::$fileFunctionMap[$filename] : array();
+    }
+
+    /**
+     * Returns the class hierarchy for a given class.
+     *
+     * @param  string  $className
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getHierarchy($className)
+    {
+        $classes = array($className);
+        $done    = FALSE;
+
+        while (!$done) {
+            $class  = new ReflectionClass($classes[count($classes)-1]);
+            $parent = $class->getParentClass();
+
+            if ($parent !== FALSE) {
+                $classes[] = $parent->getName();
+            } else {
+                $done = TRUE;
+            }
+        }
+
+        return $classes;
+    }
+
+    /**
+     * Returns the signature of a method.
+     *
+     * @param  ReflectionClass $method
+     * @return string
+     * @access public
+     * @static
+     * @since  Class available since Release 3.2.0
+     */
+    public static function getMethodSignature(ReflectionMethod $method)
+    {
+        if ($method->isPrivate()) {
+            $modifier = 'private';
+        }
+
+        else if ($method->isProtected()) {
+            $modifier = 'protected';
+        }
+
+        else {
+            $modifier = 'public';
+        }
+
+        if ($method->isStatic()) {
+            $modifier .= ' static';
+        }
+
+        if ($method->returnsReference()) {
+            $reference = '&';
+        } else {
+            $reference = '';
+        }
+
+        return sprintf(
+          '%s function %s%s(%s)',
+
+          $modifier,
+          $reference,
+          $method->getName(),
+          self::getMethodParameters($method)
+        );
+    }
+
+    /**
+     * Returns the parameters of a method.
+     *
+     * @param  ReflectionClass $method
+     * @return string
+     * @access public
+     * @static
+     * @since  Class available since Release 3.2.0
+     */
+    public static function getMethodParameters(ReflectionMethod $method)
+    {
+        $parameters = array();
+
+        foreach ($method->getParameters() as $parameter) {
+            $name     = '$' . $parameter->getName();
+            $typeHint = '';
+
+            if ($parameter->isArray()) {
+                $typeHint = 'array ';
+            } else {
+                try {
+                    $class = $parameter->getClass();
+                }
+
+                catch (ReflectionException $e) {
+                    $class = FALSE;
+                }
+
+                if ($class) {
+                    $typeHint = $class->getName() . ' ';
+                }
+            }
+
+            $default = '';
+
+            if ($parameter->isDefaultValueAvailable()) {
+                $value   = $parameter->getDefaultValue();
+                $default = ' = ' . var_export($value, TRUE);
+            }
+
+            $ref = '';
+
+            if ($parameter->isPassedByReference()) {
+                $ref = '&';
+            }
+
+            $parameters[] = $typeHint . $ref . $name . $default;
+        }
+
+        return join(', ', $parameters);
+    }
+
+    /**
+     * Returns the sourcecode of a user-defined class.
+     *
+     * @param  string  $className
+     * @param  string  $methodName
+     * @return mixed
+     * @access public
+     * @static
+     */
+    public static function getMethodSource($className, $methodName)
+    {
+        if ($className != 'global') {
+            $function = new ReflectionMethod($className, $methodName);
+        } else {
+            $function = new ReflectionFunction($methodName);
+        }
+
+        $filename = $function->getFileName();
+
+        if (file_exists($filename)) {
+            $file   = file($filename);
+            $result = '';
+
+            for ($line = $function->getStartLine() - 1; $line <= $function->getEndLine() - 1; $line++) {
+                $result .= $file[$line];
+            }
+
+            return $result;
+        } else {
+            return FALSE;
+        }
+    }
+
+    /**
+     * Returns the package information of a user-defined class.
+     *
+     * @param  string $className
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getPackageInformation($className)
+    {
+        $result = array(
+          'fullPackage' => '',
+          'category'    => '',
+          'package'     => '',
+          'subpackage'  => ''
+        );
+
+        $class      = new ReflectionClass($className);
+        $docComment = $class->getDocComment();
+
+        if (preg_match('/@category[\s]+([\.\w]+)/', $docComment, $matches)) {
+            $result['category'] = $matches[1];
+        }
+
+        if (preg_match('/@package[\s]+([\.\w]+)/', $docComment, $matches)) {
+            $result['package']     = $matches[1];
+            $result['fullPackage'] = $matches[1];
+        }
+
+        if (preg_match('/@subpackage[\s]+([\.\w]+)/', $docComment, $matches)) {
+            $result['subpackage'] = $matches[1];
+            $result['fullPackage'] .= '.' . $matches[1];
+        }
+
+        if (empty($result['fullPackage'])) {
+            $tmp = explode('_', $className);
+
+            if (count($tmp) > 1) {
+                unset($tmp[count($tmp)-1]);
+
+                $result['fullPackage'] = join('.', $tmp);
+            }
+        }
+
+        return $result;
+    }
+}
+?>

Added: incubator/shindig/trunk/php/external/PHPUnit/Util/CodeCoverage.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Util/CodeCoverage.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Util/CodeCoverage.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Util/CodeCoverage.php Sat Aug  2 07:11:35 2008
@@ -0,0 +1,255 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, 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, 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.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    SVN: $Id: CodeCoverage.php 1985 2007-12-26 18:11:55Z sb $
+ * @link       http://www.phpunit.de/
+ * @since      File available since Release 3.1.0
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Code Coverage helpers.
+ *
+ * @category   Testing
+ * @package    PHPUnit
+ * @author     Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright  2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
+ * @version    Release: 3.2.9
+ * @link       http://www.phpunit.de/
+ * @since      Class available since Release 3.1.0
+ * @abstract
+ */
+abstract class PHPUnit_Util_CodeCoverage
+{
+    protected static $lineToTestMap = array();
+    protected static $summary = array();
+
+    /**
+     * Returns the names of the covered files.
+     *
+     * @param  array $data
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getCoveredFiles(array &$data)
+    {
+        $files = array();
+
+        foreach ($data as $test) {
+            $_files = array_keys($test['files']);
+
+            foreach ($_files as $file) {
+                if (self::isFile($file) && !in_array($file, $files)) {
+                    $files[] = $file;
+                }
+            }
+        }
+
+        return $files;
+    }
+
+    /**
+     * Returns the tests that cover a given line.
+     *
+     * @param  array   $data
+     * @param  string  $file
+     * @param  string  $line
+     * @param  boolean $clear
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getCoveringTests(array &$data, $file, $line, $clear = FALSE)
+    {
+        if (empty(self::$lineToTestMap) || $clear) {
+            foreach ($data as $test) {
+                foreach ($test['files'] as $_file => $lines) {
+                    foreach ($lines as $_line => $flag) {
+                        if ($flag > 0) {
+                            if (!isset(self::$lineToTestMap[$_file][$_line])) {
+                                self::$lineToTestMap[$_file][$_line] = array($test['test']);
+                            } else {
+                                self::$lineToTestMap[$_file][$_line][] = $test['test'];
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (isset(self::$lineToTestMap[$file][$line])) {
+            return self::$lineToTestMap[$file][$line];
+        } else {
+            return FALSE;
+        }
+    }
+
+    /**
+     * Returns summarized code coverage data.
+     *
+     * Format of the result array:
+     *
+     * <code>
+     * array(
+     *   "/tested/code.php" => array(
+     *     linenumber => number of tests that executed the line
+     *   )
+     * )
+     * </code>
+     *
+     * @param  array $data
+     * @param  boolean $clear
+     * @return array
+     * @access public
+     * @static
+     */
+    public static function getSummary(array &$data, $clear = FALSE)
+    {
+        if (empty(self::$summary) || $clear) {
+            $isFileCache = array();
+
+            foreach ($data as $test) {
+                foreach ($test['files'] as $file => $lines) {
+                    if (!isset($isFileCache[$file])) {
+                        $isFileCache[$file] = self::isFile($file);
+                    }
+
+                    if (!$isFileCache[$file]) {
+                        continue;
+                    }
+
+                    $fileSummary = &self::$summary[$file];
+
+                    foreach ($lines as $line => $flag) {
+                        // +1: Line is executable and was executed.
+                        if ($flag == 1) {
+                            if (isset($fileSummary[$line][0])) {
+                                $fileSummary[$line][] = $test['test'];
+                            }
+                            else {
+                                $fileSummary[$line] = array($test['test']);
+                            }
+                        }
+
+                        // -1: Line is executable and was not executed.
+                        // -2: Line is dead code.
+                        else if (!isset($fileSummary[$line])) {
+                            $fileSummary[$line] = $flag;
+                        }
+                    }
+
+                    unset($fileSummary);
+                }
+            }
+        }
+
+        return self::$summary;
+    }
+
+    /**
+     * Returns the coverage statistics for a section of a file.
+     *
+     * @param  array   $data
+     * @param  string  $filename
+     * @param  integer $startLine
+     * @param  integer $endLine
+     * @return array
+     * @access public
+     * @static
+     * @since  Method available since Release 3.2.0
+     */
+    public static function getStatistics(array &$data, $filename, $startLine = 1, $endLine = FALSE) {
+        $coverage      = 0;
+        $locExecutable = 0;
+        $locExecuted   = 0;
+
+        if (isset($data[$filename])) {
+            if ($endLine == FALSE) {
+                $endLine = count(file($filename));
+            }
+
+            foreach ($data[$filename] as $line => $_data) {
+                if ($line >= $startLine && $line <= $endLine) {
+                    if (is_array($_data)) {
+                        $locExecutable++;
+                        $locExecuted++;
+                    }
+                    
+                    else if ($_data == -1) {
+                        $locExecutable++;
+                    }
+                }
+            }
+
+            if ($locExecutable > 0) {
+                $coverage = ($locExecuted / $locExecutable) * 100;
+            }
+        }
+
+        return array(
+          'coverage'      => $coverage,
+          'loc'           => $endLine - $startLine + 1,
+          'locExecutable' => $locExecutable,
+          'locExecuted'   => $locExecuted
+        );
+    }
+
+    /**
+     * @param  string $file
+     * @return boolean
+     * @access protected
+     * @static
+     */
+    protected static function isFile($file)
+    {
+        if (strpos($file, 'eval()\'d code') || strpos($file, 'runtime-created function') || strpos($file, 'assert code')) {
+            return FALSE;
+        }
+
+        return TRUE;
+    }
+}
+?>