class SapphireTestReporter implements PHPUnit_Framework_TestListener (View source)

Gathers details about PHPUnit2 test suites as they are been executed. This does not actually format any output but simply gathers extended information about the overall results of all suites & their tests for use elsewhere.

Changelog: 0.6 First created [David Spurr] 0.7 Added fix to getTestException provided [Glen Ogilvie]

Properties

protected array $suiteResults

Holds array of suites and total number of tests run

protected array $currentSuite

Holds data of current suite that is been run

protected array $currentTest

Holds data of current test that is been run

protected bool $hasTimer

Whether PEAR Benchmark_Timer is available for timing

protected obj $timer

Holds the PEAR Benchmark_Timer object

protected $startTestTime
protected $testSpeeds

An array of all the test speeds

Methods

public
void
__construct()

Constructor, checks to see availability of PEAR Benchmark_Timer and sets up basic properties

public
array
getSuiteResults()

Returns the suite results

public
void
startTestSuite(PHPUnit_Framework_TestSuite $suite)

Sets up the container for result details of the current test suite when each suite is first run

public
void
startTest(PHPUnit_Framework_Test $test)

Sets up the container for result details of the current test when each test is first run

protected
addStatus(int $status, string $message, string $exception, array $trace)

Logs the specified status to the current test, or if no test is currently run, to the test suite.

public
void
addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)

Adds the failure detail to the current test and increases the failure count for the current suite

public
void
addError(PHPUnit_Framework_Test $test, Exception $e, $time)

Adds the error detail to the current test and increases the error count for the current suite

public
void
addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)

Adds the test incomplete detail to the current test and increases the incomplete count for the current suite

public
addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, unknown_type $time)

Not used

protected
endCurrentTest()

Cleanly end the current test

public
void
endTest(PHPUnit_Framework_Test $test, $time)

Upon completion of a test, records the execution time (if available) and adds the test to the tests performed in the current suite.

protected
endCurrentTestSuite()

Cleanly end the current test suite

public
void
endTestSuite(PHPUnit_Framework_TestSuite $suite)

Upon completion of a test suite adds the suite to the suties performed

public
addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, float $time)

Risky test.

protected
writeResultError(string $name, string $message, array $trace)

Writes a status message to the output stream in a user readable HTML format

public
writeResults()

Display error bar if it exists

protected
testNameToPhrase($name)

No description

Details

void __construct()

Constructor, checks to see availability of PEAR Benchmark_Timer and sets up basic properties

Return Value

void

array getSuiteResults()

Returns the suite results

Return Value

array

Suite results

void startTestSuite(PHPUnit_Framework_TestSuite $suite)

Sets up the container for result details of the current test suite when each suite is first run

Parameters

PHPUnit_Framework_TestSuite $suite

Return Value

void

void startTest(PHPUnit_Framework_Test $test)

Sets up the container for result details of the current test when each test is first run

Parameters

PHPUnit_Framework_Test $test

Return Value

void

protected addStatus(int $status, string $message, string $exception, array $trace)

Logs the specified status to the current test, or if no test is currently run, to the test suite.

Parameters

int $status

Status code

string $message

Message to log

string $exception

Exception body related to this message

array $trace Stacktrace

void addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)

Adds the failure detail to the current test and increases the failure count for the current suite

Parameters

PHPUnit_Framework_Test $test
PHPUnit_Framework_AssertionFailedError $e
$time

Return Value

void

void addError(PHPUnit_Framework_Test $test, Exception $e, $time)

Adds the error detail to the current test and increases the error count for the current suite

Parameters

PHPUnit_Framework_Test $test
Exception $e
$time

Return Value

void

void addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)

Adds the test incomplete detail to the current test and increases the incomplete count for the current suite

Parameters

PHPUnit_Framework_Test $test
Exception $e
$time

Return Value

void

addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, unknown_type $time)

Not used

Parameters

PHPUnit_Framework_Test $test
Exception $e
unknown_type $time

protected endCurrentTest()

Cleanly end the current test

void endTest(PHPUnit_Framework_Test $test, $time)

Upon completion of a test, records the execution time (if available) and adds the test to the tests performed in the current suite.

Parameters

PHPUnit_Framework_Test $test
$time

Return Value

void

protected endCurrentTestSuite()

Cleanly end the current test suite

void endTestSuite(PHPUnit_Framework_TestSuite $suite)

Upon completion of a test suite adds the suite to the suties performed

Parameters

PHPUnit_Framework_TestSuite $suite

Return Value

void

addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, float $time)

Since: Method available since Release 3.8.0

Risky test.

Parameters

PHPUnit_Framework_Test $test
Exception $e
float $time

protected writeResultError(string $name, string $message, array $trace)

Writes a status message to the output stream in a user readable HTML format

Parameters

string $name

Name of the object that generated the error

string $message

Message of the error

array $trace Stacktrace

writeResults()

Display error bar if it exists

protected testNameToPhrase($name)

No description

Parameters

$name