PHP Class kahlan\Expectation

Exibir arquivo Open project: crysalead/kahlan Class Usage Examples

Protected Properties

Property Type Description
$_actual mixed The current value to test.
$_deferred array Deferred expectation.
$_logs array The result logs.
$_not boolean If true, the result of the test will be inverted.
$_passed boolean Stores the success value.
$_timeout integer The timeout value.

Public Methods

Method Description
__call ( string $matcherName, array $args ) : boolean Calls a registered matcher.
__construct ( array $config = [] ) Constructor.
__get ( $name ) Magic getter, if called with 'not' invert the _not attribute.
_matcher ( string $matcherName, mixed $actual ) : string Returns a compatible matcher class name according to a passed actual value.
actual ( ) : boolean Returns the actual value.
clear ( ) Clears the instance.
deferred ( ) : array Returns the deferred expectations.
logs ( ) Returns the logs.
not ( ) : boolean Returns the not value.
passed ( ) : boolean Checks if all test passed.
timeout ( ) Returns the timeout value.

Protected Methods

Method Description
_log ( boolean $boolean, array $data = [] ) : boolean Logs a result.
_resolve ( ) Resolves deferred matchers.
_run ( ) : mixed Processes the expectation.
_spin ( Closure $closure ) Runs the expectation.

Method Details

__call() public method

Calls a registered matcher.
public __call ( string $matcherName, array $args ) : boolean
$matcherName string The name of the matcher.
$args array The arguments to pass to the matcher.
return boolean

__construct() public method

Constructor.
public __construct ( array $config = [] )
$config array The config array. Options are: -`'actual'` _mixed_ : the actual value. -`'timeout'` _integer_ : the timeout value.

__get() public method

Magic getter, if called with 'not' invert the _not attribute.
public __get ( $name )

_log() protected method

Logs a result.
protected _log ( boolean $boolean, array $data = [] ) : boolean
$boolean boolean Set `true` for success and `false` for failure.
$data array Test details array.
return boolean

_matcher() public method

Returns a compatible matcher class name according to a passed actual value.
public _matcher ( string $matcherName, mixed $actual ) : string
$matcherName string The name of the matcher.
$actual mixed The actual value.
return string A matcher class name.

_resolve() protected method

Resolves deferred matchers.
protected _resolve ( )

_run() protected method

Processes the expectation.
protected _run ( ) : mixed
return mixed

_spin() protected method

Runs the expectation.
protected _spin ( Closure $closure )
$closure Closure The closure to run/spin.

actual() public method

Returns the actual value.
public actual ( ) : boolean
return boolean

clear() public method

Clears the instance.
public clear ( )

deferred() public method

Returns the deferred expectations.
public deferred ( ) : array
return array

logs() public method

Returns the logs.
public logs ( )

not() public method

Returns the not value.
public not ( ) : boolean
return boolean

passed() public method

Checks if all test passed.
public passed ( ) : boolean
return boolean Returns `true` if no error occurred, `false` otherwise.

timeout() public method

Returns the timeout value.
public timeout ( )

Property Details

$_actual protected_oe property

The current value to test.
protected mixed $_actual
return mixed

$_deferred protected_oe property

Deferred expectation.
protected array $_deferred
return array

$_logs protected_oe property

The result logs.
protected array $_logs
return array

$_not protected_oe property

If true, the result of the test will be inverted.
protected bool $_not
return boolean

$_passed protected_oe property

Stores the success value.
protected bool $_passed
return boolean

$_timeout protected_oe property

The timeout value.
protected int $_timeout
return integer