Test
in package
implements
TestInterface, Descriptive
uses
AssertionCounter, CodeCoverage, ErrorLogger, MetadataCollector, IgnoreIfMetadataBlocked
The most simple testcase (with only one test in it) which can be executed by PHPUnit/Codeception.
It can be extended with included traits. Turning on/off a trait should not break class functionality.
Class has exactly one method to be executed for testing, wrapped with before/after callbacks delivered from included traits.
A trait providing before/after callback should contain corresponding protected methods: {traitName}Start
and {traitName}End
,
then this trait should be enabled in hooks
property.
Inherited class must implement test
method.
Table of Contents
Interfaces
Constants
- STATUS_ERROR = 'error'
- STATUS_FAIL = 'fail'
- STATUS_OK = 'ok'
- STATUS_PENDING = 'pending'
Properties
- $hooks : array<string|int, mixed>
- Enabled traits with methods to be called before and after the test.
- $numAssertions : mixed
- $ignored : mixed
- $metadata : Metadata
- $testResult : mixed
Methods
- addToAssertionCount() : mixed
- This method is not covered by the backward compatibility promise for PHPUnit, but is nice to have for extensions.
- codeCoverageEnd() : mixed
- codeCoverageStart() : mixed
- count() : mixed
- errorLoggerEnd() : mixed
- getFileName() : mixed
- getMetadata() : mixed
- getName() : mixed
- getNumAssertions() : mixed
- getTestResultObject() : mixed
- run() : TestResult
- Runs a test and collects its result in a TestResult instance.
- test() : mixed
- Everything inside this method is treated as a test.
- toString() : mixed
- Test representation
- assertionCounterEnd() : mixed
- assertionCounterStart() : mixed
- ignore() : mixed
- Should a test be skipped (can be set from hooks)
- ignoreIfMetadataBlockedStart() : mixed
- setMetadata() : mixed
Constants
STATUS_ERROR
public
mixed
STATUS_ERROR
= 'error'
STATUS_FAIL
public
mixed
STATUS_FAIL
= 'fail'
STATUS_OK
public
mixed
STATUS_OK
= 'ok'
STATUS_PENDING
public
mixed
STATUS_PENDING
= 'pending'
Properties
$hooks
Enabled traits with methods to be called before and after the test.
protected
array<string|int, mixed>
$hooks
= ['ignoreIfMetadataBlocked', 'codeCoverage', 'assertionCounter', 'errorLogger']
$numAssertions
protected
mixed
$numAssertions
= 0
$ignored
private
mixed
$ignored
= false
$metadata
private
Metadata
$metadata
$testResult
private
mixed
$testResult
Methods
addToAssertionCount()
This method is not covered by the backward compatibility promise for PHPUnit, but is nice to have for extensions.
public
addToAssertionCount(mixed $count) : mixed
Parameters
- $count : mixed
codeCoverageEnd()
public
codeCoverageEnd(mixed $status, mixed $time) : mixed
Parameters
- $status : mixed
- $time : mixed
codeCoverageStart()
public
codeCoverageStart() : mixed
count()
public
count() : mixed
Attributes
errorLoggerEnd()
public
errorLoggerEnd(mixed $status, mixed $time[, mixed $exception = null ]) : mixed
Parameters
- $status : mixed
- $time : mixed
- $exception : mixed = null
getFileName()
public
getFileName() : mixed
getMetadata()
public
getMetadata() : mixed
getName()
public
getName() : mixed
getNumAssertions()
public
getNumAssertions() : mixed
getTestResultObject()
public
getTestResultObject() : mixed
run()
Runs a test and collects its result in a TestResult instance.
public
final run([TestResult $result = null ]) : TestResult
Executes before/after hooks coming from traits.
Parameters
- $result : TestResult = null
Return values
TestResulttest()
Everything inside this method is treated as a test.
public
abstract test() : mixed
toString()
Test representation
public
abstract toString() : mixed
assertionCounterEnd()
protected
assertionCounterEnd() : mixed
assertionCounterStart()
protected
assertionCounterStart() : mixed
ignore()
Should a test be skipped (can be set from hooks)
protected
ignore(bool $ignored) : mixed
Parameters
- $ignored : bool
ignoreIfMetadataBlockedStart()
protected
ignoreIfMetadataBlockedStart() : mixed
setMetadata()
protected
setMetadata(Metadata $metadata) : mixed
Parameters
- $metadata : Metadata