Source for file TestResult.php
Documentation is available at TestResult.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2005 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: TestResult.php,v 1.16.2.5 2005/05/25 11:57:44 sebastian Exp $
require_once 'PHPUnit2/Framework/AssertionFailedError.php';
require_once 'PHPUnit2/Framework/Error.php';
require_once 'PHPUnit2/Framework/IncompleteTest.php';
require_once 'PHPUnit2/Framework/Test.php';
require_once 'PHPUnit2/Framework/TestFailure.php';
require_once 'PHPUnit2/Framework/TestListener.php';
require_once 'PHPUnit2/Framework/TestSuite.php';
* A TestResult collects the results of executing a test case.
* @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
// {{{ Instance Variables
* Code Coverage information provided by Xdebug.
private $codeCoverageInformation = array ();
// {{{ public function addListener(PHPUnit2_Framework_TestListener $listener)
* Registers a TestListener.
* @param PHPUnit2_Framework_TestListener
public function addListener(PHPUnit2_Framework_TestListener $listener) {
// {{{ public function removeListener(PHPUnit2_Framework_TestListener $listener)
* Unregisters a TestListener.
* @param PHPUnit2_Framework_TestListener $listener
public function removeListener(PHPUnit2_Framework_TestListener $listener) {
// {{{ public function addError(PHPUnit2_Framework_Test $test, Exception $e)
* Adds an error to the list of errors.
* The passed in exception caused the error.
* @param PHPUnit2_Framework_Test $test
public function addError(PHPUnit2_Framework_Test $test, Exception $e) {
$listener->addIncompleteTest ($test, $e);
$listener->addError ($test, $e);
// {{{ public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $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
public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) {
$listener->addIncompleteTest ($test, $e);
$listener->addFailure ($test, $e);
// {{{ public function startTestSuite(PHPUnit2_Framework_TestSuite $suite)
* Informs the result that a testsuite will be started.
* @param PHPUnit2_Framework_TestSuite $suite
$listener->startTestSuite ($suite);
// {{{ public function endTestSuite(PHPUnit2_Framework_TestSuite $suite)
* Informs the result that a testsuite was completed.
* @param PHPUnit2_Framework_TestSuite $suite
public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) {
$listener->endTestSuite ($suite);
// {{{ public function startTest(PHPUnit2_Framework_Test $test)
* Informs the result that a test will be started.
* @param PHPUnit2_Framework_Test $test
public function startTest(PHPUnit2_Framework_Test $test) {
$this->runTests += $test->countTestCases ();
$listener->startTest ($test);
// {{{ public function endTest(PHPUnit2_Framework_Test $test)
* Informs the result that a test was completed.
* @param PHPUnit2_Framework_Test
public function endTest(PHPUnit2_Framework_Test $test) {
$this->codeCoverageInformation[$test->getName ()] = $test->getCodeCoverageInformation ();
$listener->endTest ($test);
// {{{ public function allCompletlyImplemented()
* Returns TRUE if no incomplete test occured.
// {{{ public function notImplementedCount()
* Gets the number of incomplete tests.
// {{{ public function notImplemented)
* Returns an Enumeration for the incomplete tests.
// {{{ public function errorCount()
* Gets the number of detected errors.
// {{{ public function errors()
* Returns an Enumeration for the errors.
// {{{ public function failureCount()
* Gets the number of detected failures.
// {{{ public function failures()
* Returns an Enumeration for the failures.
// {{{ public function getCodeCoverageInformation()
* Returns Code Coverage data per test case.
* Format of the result array:
* "/tested/code.php" => array(
* linenumber => numberOfExecutions
return $this->codeCoverageInformation;
// {{{ public function run(PHPUnit2_Framework_Test $test)
* @param PHPUnit2_Framework_Test $test
public function run(PHPUnit2_Framework_Test $test) {
// {{{ public function runCount()
* Gets the number of run tests.
// {{{ public function shouldStop()
* Checks whether the test run should stop.
// {{{ public function stop()
* Marks that the test run should stop.
// {{{ public function wasSuccessful()
* Returns whether the entire test was successful or not.
// {{{ public function errorHandler($errno, $errstr, $errfile, $errline)
* @param integer $errline
public function errorHandler($errno, $errstr, $errfile, $errline) {
if ($errno == E_ERROR || $errno == E_USER_ERROR ) {
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 14:19:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|