Source for file TestRunner.php
Documentation is available at TestRunner.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license 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: TestRunner.php,v 1.9.2.5 2004/07/19 13:18:41 sebastian Exp $
if (!defined('PHPUnit2_MAIN_METHOD')) {
define('PHPUnit2_MAIN_METHOD', 'PHPUnit2_TextUI_TestRunner::main');
require_once 'Console/Getopt.php';
require_once 'PHPUnit2/Framework/AssertionFailedError.php';
require_once 'PHPUnit2/Framework/Test.php';
require_once 'PHPUnit2/Framework/TestResult.php';
require_once 'PHPUnit2/Runner/BaseTestRunner.php';
require_once 'PHPUnit2/Runner/Version.php';
require_once 'PHPUnit2/TextUI/ResultPrinter.php';
@include_once 'Benchmark/Timer.php';
* A TestRunner for the Command Line Interface (CLI)
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
* @var PHPUnit2_TextUI_ResultPrinter
// {{{ public static function main()
public static function main() {
$result = $aTestRunner->start ($_SERVER['argv']);
if (!$result->wasSuccessful ()) {
exit (self ::FAILURE_EXIT );
exit (self ::SUCCESS_EXIT );
exit (self ::EXCEPTION_EXIT );
// {{{ protected function start($arguments)
* @param array $arguments
protected function start($arguments) {
$possibleOptions = array (
$options = Console_Getopt ::getopt (
foreach ($options[0 ] as $option) {
exit (self ::SUCCESS_EXIT );
exit (self ::SUCCESS_EXIT );
$test = isset ($options[1 ][0 ]) ? $options[1 ][0 ] : false;
exit (self ::SUCCESS_EXIT );
'Could not create and run test suite: ' . $e->getMessage ()
// {{{ public static function run($test)
public static function run($test) {
if ($test instanceof ReflectionClass ) {
return $aTestRunner->doRun ($test);
// {{{ public static function runAndWait(PHPUnit2_Framework_Test $suite)
* @param PHPUnit2_Framework_Test $suite
public static function runAndWait(PHPUnit2_Framework_Test $suite) {
$aTestRunner->doRun ($suite, true );
// {{{ protected TestResult createTestResult()
* @return PHPUnit2_Framework_TestResult
// {{{ public function doRun(PHPUnit2_Framework_Test $suite, $wait = false)
* @param PHPUnit2_Framework_Test $suite
* @return PHPUnit2_Framework_TestResult
public function doRun(PHPUnit2_Framework_Test $suite, $wait = false ) {
if ($this->printer === null ) {
$result->addListener ($this->printer);
$timer = new Benchmark_Timer;
$timeElapsed = $timer->timeElapsed ();
// {{{ public function showHelp()
"Usage: phpunit [switches] UnitTest\n" .
" --wait Waits for a keystroke after each test.\n" .
" --help Prints this usage information.\n" .
" --version Prints the version and exits.\n";
// {{{ protected function pause($wait)
protected function pause($wait) {
// {{{ public function testEnded($testName)
* @param string $testName
// {{{ public function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e)
* @param PHPUnit2_Framework_Test $test
* @param PHPUnit2_Framework_AssertionFailedError $e
public function testFailed($status, PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) {
// {{{ public function testStarted($testName)
* @param string $testName
// {{{ protected function runFailed($message)
* Override to define how to handle a failed loading of
exit (self ::FAILURE_EXIT );
// {{{ public function setPrinter(PHPUnit2_TextUI_ResultPrinter $resultPrinter)
* @param PHPUnit2_TextUI_ResultPrinter $resultPrinter
public function setPrinter(PHPUnit2_TextUI_ResultPrinter $resultPrinter) {
$this->printer = $resultPrinter;
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 13:55:59 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|