class TestResult implements Countable (View source)

A TestResult collects the results of executing a test case.

Properties

protected array $passed
protected array $errors
protected array $failures
protected array $warnings
protected array $notImplemented
protected array $risky
protected array $skipped
protected array $listeners
protected int $runTests
protected float $time
protected TestSuite $topTestSuite
protected CodeCoverage $codeCoverage Code Coverage information.
protected bool $convertErrorsToExceptions
protected bool $stop
protected bool $stopOnError
protected bool $stopOnFailure
protected bool $stopOnWarning
protected bool $beStrictAboutTestsThatDoNotTestAnything
protected bool $beStrictAboutOutputDuringTests
protected bool $beStrictAboutTodoAnnotatedTests
protected bool $beStrictAboutResourceUsageDuringSmallTests
protected bool $enforceTimeLimit
protected int $timeoutForSmallTests
protected int $timeoutForMediumTests
protected int $timeoutForLargeTests
protected bool $stopOnRisky
protected bool $stopOnIncomplete
protected bool $stopOnSkipped
protected bool $lastTestFailed

Methods

addListener(TestListener $listener)

Registers a TestListener.

removeListener(TestListener $listener)

Unregisters a TestListener.

flushListeners()

Flushes all flushable TestListeners.

addError(Test $test, Throwable $t, float $time)

Adds an error to the list of errors.

addWarning(Test $test, Warning $e, float $time)

Adds a warning to the list of warnings.

addFailure(Test $test, AssertionFailedError $e, float $time)

Adds a failure to the list of failures.

startTestSuite(TestSuite $suite)

Informs the result that a testsuite will be started.

endTestSuite(TestSuite $suite)

Informs the result that a testsuite was completed.

startTest(Test $test)

Informs the result that a test will be started.

endTest(Test $test, float $time)

Informs the result that a test was completed.

bool
allHarmless()

Returns true if no risky test occurred.

int
riskyCount()

Gets the number of risky tests.

bool
allCompletelyImplemented()

Returns true if no incomplete test occurred.

int
notImplementedCount()

Gets the number of incomplete tests.

array
risky()

Returns an Enumeration for the risky tests.

array
notImplemented()

Returns an Enumeration for the incomplete tests.

bool
noneSkipped()

Returns true if no test has been skipped.

int
skippedCount()

Gets the number of skipped tests.

array
skipped()

Returns an Enumeration for the skipped tests.

int
errorCount()

Gets the number of detected errors.

array
errors()

Returns an Enumeration for the errors.

int
failureCount()

Gets the number of detected failures.

array
failures()

Returns an Enumeration for the failures.

int
warningCount()

Gets the number of detected warnings.

array
warnings()

Returns an Enumeration for the warnings.

array
passed()

Returns the names of the tests that have passed.

topTestSuite()

Returns the (top) test suite.

bool
getCollectCodeCoverageInformation()

Returns whether code coverage information should be collected.

run(Test $test)

Runs a TestCase.

int
count()

Gets the number of run tests.

bool
shouldStop()

Checks whether the test run should stop.

stop()

Marks that the test run should stop.

CodeCoverage
getCodeCoverage()

Returns the code coverage object.

setCodeCoverage(CodeCoverage $codeCoverage)

Sets the code coverage object.

convertErrorsToExceptions(bool $flag)

Enables or disables the error-to-exception conversion.

bool
getConvertErrorsToExceptions()

Returns the error-to-exception conversion setting.

stopOnError(bool $flag)

Enables or disables the stopping when an error occurs.

stopOnFailure(bool $flag)

Enables or disables the stopping when a failure occurs.

stopOnWarning(bool $flag)

Enables or disables the stopping when a warning occurs.

beStrictAboutTestsThatDoNotTestAnything(bool $flag)

No description

beStrictAboutOutputDuringTests(bool $flag)

No description

bool
beStrictAboutResourceUsageDuringSmallTests(bool $flag)

No description

enforceTimeLimit(bool $flag)

No description

bool
enforcesTimeLimit()

No description

beStrictAboutTodoAnnotatedTests(bool $flag)

No description

bool
stopOnRisky(bool $flag)

Enables or disables the stopping for risky tests.

stopOnIncomplete(bool $flag)

Enables or disables the stopping for incomplete tests.

stopOnSkipped(bool $flag)

Enables or disables the stopping for skipped tests.

float
time()

Returns the time spent running the tests.

bool
wasSuccessful()

Returns whether the entire test was successful or not.

setTimeoutForSmallTests(int $timeout)

Sets the timeout for small tests.

setTimeoutForMediumTests(int $timeout)

Sets the timeout for medium tests.

setTimeoutForLargeTests(int $timeout)

Sets the timeout for large tests.

int
getTimeoutForLargeTests()

Returns the set timeout for large tests.

array
getHierarchy(string $className, bool $asReflectionObjects = false)

Returns the class hierarchy for a given class.

Details

addListener(TestListener $listener)

Registers a TestListener.

Parameters

TestListener $listener

removeListener(TestListener $listener)

Unregisters a TestListener.

Parameters

TestListener $listener

flushListeners()

Flushes all flushable TestListeners.

addError(Test $test, Throwable $t, float $time)

Adds an error to the list of errors.

Parameters

Test $test
Throwable $t
float $time

addWarning(Test $test, Warning $e, float $time)

Adds a warning to the list of warnings.

The passed in exception caused the warning.

Parameters

Test $test
Warning $e
float $time

addFailure(Test $test, AssertionFailedError $e, float $time)

Adds a failure to the list of failures.

The passed in exception caused the failure.

Parameters

Test $test
AssertionFailedError $e
float $time

startTestSuite(TestSuite $suite)

Informs the result that a testsuite will be started.

Parameters

TestSuite $suite

endTestSuite(TestSuite $suite)

Informs the result that a testsuite was completed.

Parameters

TestSuite $suite

startTest(Test $test)

Informs the result that a test will be started.

Parameters

Test $test

endTest(Test $test, float $time)

Informs the result that a test was completed.

Parameters

Test $test
float $time

bool allHarmless()

Returns true if no risky test occurred.

Return Value

bool

int riskyCount()

Gets the number of risky tests.

Return Value

int

bool allCompletelyImplemented()

Returns true if no incomplete test occurred.

Return Value

bool

int notImplementedCount()

Gets the number of incomplete tests.

Return Value

int

array risky()

Returns an Enumeration for the risky tests.

Return Value

array

array notImplemented()

Returns an Enumeration for the incomplete tests.

Return Value

array

bool noneSkipped()

Returns true if no test has been skipped.

Return Value

bool

int skippedCount()

Gets the number of skipped tests.

Return Value

int

array skipped()

Returns an Enumeration for the skipped tests.

Return Value

array

int errorCount()

Gets the number of detected errors.

Return Value

int

array errors()

Returns an Enumeration for the errors.

Return Value

array

int failureCount()

Gets the number of detected failures.

Return Value

int

array failures()

Returns an Enumeration for the failures.

Return Value

array

int warningCount()

Gets the number of detected warnings.

Return Value

int

array warnings()

Returns an Enumeration for the warnings.

Return Value

array

array passed()

Returns the names of the tests that have passed.

Return Value

array

TestSuite topTestSuite()

Returns the (top) test suite.

Return Value

TestSuite

bool getCollectCodeCoverageInformation()

Returns whether code coverage information should be collected.

Return Value

bool If code coverage should be collected

run(Test $test)

Runs a TestCase.

Parameters

Test $test

int count()

Gets the number of run tests.

Return Value

int

bool shouldStop()

Checks whether the test run should stop.

Return Value

bool

stop()

Marks that the test run should stop.

CodeCoverage getCodeCoverage()

Returns the code coverage object.

Return Value

CodeCoverage

setCodeCoverage(CodeCoverage $codeCoverage)

Sets the code coverage object.

Parameters

CodeCoverage $codeCoverage

convertErrorsToExceptions(bool $flag)

Enables or disables the error-to-exception conversion.

Parameters

bool $flag

Exceptions

Exception

bool getConvertErrorsToExceptions()

Returns the error-to-exception conversion setting.

Return Value

bool

stopOnError(bool $flag)

Enables or disables the stopping when an error occurs.

Parameters

bool $flag

Exceptions

Exception

stopOnFailure(bool $flag)

Enables or disables the stopping when a failure occurs.

Parameters

bool $flag

Exceptions

Exception

stopOnWarning(bool $flag)

Enables or disables the stopping when a warning occurs.

Parameters

bool $flag

Exceptions

Exception

beStrictAboutTestsThatDoNotTestAnything(bool $flag)

Parameters

bool $flag

Exceptions

Exception

bool isStrictAboutTestsThatDoNotTestAnything()

Return Value

bool

beStrictAboutOutputDuringTests(bool $flag)

Parameters

bool $flag

Exceptions

Exception

bool isStrictAboutOutputDuringTests()

Return Value

bool

beStrictAboutResourceUsageDuringSmallTests(bool $flag)

Parameters

bool $flag

Exceptions

Exception

bool isStrictAboutResourceUsageDuringSmallTests()

Return Value

bool

enforceTimeLimit(bool $flag)

Parameters

bool $flag

Exceptions

Exception

bool enforcesTimeLimit()

Return Value

bool

beStrictAboutTodoAnnotatedTests(bool $flag)

Parameters

bool $flag

Exceptions

Exception

bool isStrictAboutTodoAnnotatedTests()

Return Value

bool

stopOnRisky(bool $flag)

Enables or disables the stopping for risky tests.

Parameters

bool $flag

Exceptions

Exception

stopOnIncomplete(bool $flag)

Enables or disables the stopping for incomplete tests.

Parameters

bool $flag

Exceptions

Exception

stopOnSkipped(bool $flag)

Enables or disables the stopping for skipped tests.

Parameters

bool $flag

Exceptions

Exception

float time()

Returns the time spent running the tests.

Return Value

float

bool wasSuccessful()

Returns whether the entire test was successful or not.

Return Value

bool

setTimeoutForSmallTests(int $timeout)

Sets the timeout for small tests.

Parameters

int $timeout

Exceptions

Exception

setTimeoutForMediumTests(int $timeout)

Sets the timeout for medium tests.

Parameters

int $timeout

Exceptions

Exception

setTimeoutForLargeTests(int $timeout)

Sets the timeout for large tests.

Parameters

int $timeout

Exceptions

Exception

int getTimeoutForLargeTests()

Returns the set timeout for large tests.

Return Value

int

setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag)

Parameters

bool $flag

protected array getHierarchy(string $className, bool $asReflectionObjects = false)

Returns the class hierarchy for a given class.

Parameters

string $className
bool $asReflectionObjects

Return Value

array