PHP Class kahlan\Scope

Datei anzeigen Open project: crysalead/kahlan Class Usage Examples

Public Properties

Property Type Description
$blacklist array List of reserved keywords which can't be used as scope variable.

Protected Properties

Property Type Description
$_backtrace object The scope backtrace.
$_backtraceFocus string A regexp pattern used to removes useless traces to focus on the one related to a spec file.
$_closure Closur\Closure The spec closure.
$_data array The scope's data.
$_failures integer Count the number of failure or exception.
$_given array The lazy loaded scope's data.
$_instances Scope[] Instances stack.
$_locked Boolean lock which avoid process() to be called in tests
$_log object The report log of executed spec.
$_message string The spec message.
$_parent Scope The parent instance.
$_passed boolean Stores the success value.
$_reporters object The reporters container.
$_root object The root instance.
$_runned boolean Indicates whether the scope has been runned or not.
$_summary object The execution summary instance.
$_timeout integer The timeout value.
$_type object The scope type.

Public Methods

Method Description
__call ( string $name, array $args ) : mixed Allow closures assigned to the scope property to be inkovable.
__construct ( array $config = [] ) The Constructor.
__get ( string $key ) : mixed Getter.
__set ( string $key, mixed $value ) : mixed Setter.
backtrace ( ) : array Gets the backtrace array.
backtraceFocus ( string $pattern = null ) : string Gets/sets the regexp pattern used to removes useless traces to focus on the one related to a spec file.
current ( ) : Scope Get the active scope instance.
excluded ( ) : boolean Check for excluded mode.
focused ( ) : boolean Check for focused mode.
given ( string $name, Closur\Closure $closure ) : object Sets a lazy loaded data.
log ( $type = null, $data = [] ) Dispatches a report up to the root scope.
message ( ) : array Gets the spec's message.
messages ( ) : array Gets all messages upon the root.
parent ( ) : Scope Gets the parent instance.
report ( string $type, mixed $data, $byPassFocuses = false ) Send some data to reporters.
reporters ( ) : object Gets the reporters container.
skipIf ( boolean $condition ) Skips specs(s) if the condition is true.
summary ( ) : array Gets specs excecution results.
timeout ( $timeout = null ) : integer Gets/sets the timeout.
type ( $type = null ) : mixed Set/get the scope type.

Protected Methods

Method Description
_bind ( Closur\Closure $closure, string $name ) : Closur\Closure Binds the closure to the current context.
_emitFocus ( ) Applies focus up to the root.
_exception ( Exception $exception, boolean $inEachHook = false ) Manages catched exception.
_parents ( boolean $current = false ) : array. Gets all parent instances.
_skipChildren ( object $exception, boolean $emit = false ) Skips children specs(s).

Method Details

__call() public method

Allow closures assigned to the scope property to be inkovable.
public __call ( string $name, array $args ) : mixed
$name string Name of the method being called.
$args array Enumerated array containing the passed arguments.
return mixed

__construct() public method

The Constructor.
public __construct ( array $config = [] )
$config array The Suite config array. Options are: -`'type'` _string_ : supported type are `'normal'` & `'focus'`. -`'message'` _string_ : the description message. -`'parent'` _object_ : the parent scope. -`'root'` _object_ : the root scope. -`'log'` _object_ : the log instance. -`'timeout'` _integer_: the timeout.

__get() public method

Getter.
public __get ( string $key ) : mixed
$key string The name of the variable.
return mixed The value of the variable.

__set() public method

Setter.
public __set ( string $key, mixed $value ) : mixed
$key string The name of the variable.
$value mixed The value of the variable.
return mixed The value of the variable.

_bind() protected method

Binds the closure to the current context.
protected _bind ( Closur\Closure $closure, string $name ) : Closur\Closure
$closure Closur\Closure The variable to check
$name string Name of the parent type (TODO: to use somewhere).
return Closur\Closure

_emitFocus() protected method

Applies focus up to the root.
protected _emitFocus ( )

_exception() protected method

Manages catched exception.
protected _exception ( Exception $exception, boolean $inEachHook = false )
$exception Exception The catched exception.
$inEachHook boolean Indicates if the exception occurs in a beforeEach/afterEach hook.

_parents() protected method

Gets all parent instances.
protected _parents ( boolean $current = false ) : array.
$current boolean If `true` include `$this` to the list.
return array.

_skipChildren() protected method

Skips children specs(s).
protected _skipChildren ( object $exception, boolean $emit = false )
$exception object The exception at the origin of the skip.
$emit boolean Indicated if report events should be generated.

backtrace() public method

Gets the backtrace array.
public backtrace ( ) : array
return array

backtraceFocus() public method

Gets/sets the regexp pattern used to removes useless traces to focus on the one related to a spec file.
public backtraceFocus ( string $pattern = null ) : string
$pattern string A wildcard pattern (i.e. `fnmatch()` style).
return string The focus regexp.

current() public static method

Get the active scope instance.
public static current ( ) : Scope
return Scope The object instance or `null` if there's no active instance.

excluded() public method

Check for excluded mode.
public excluded ( ) : boolean
return boolean

focused() public method

Check for focused mode.
public focused ( ) : boolean
return boolean

given() public method

Sets a lazy loaded data.
public given ( string $name, Closur\Closure $closure ) : object
$name string The lazy loaded variable name.
$closure Closur\Closure The lazily executed closure.
return object

log() public method

It only logs expectations report.
public log ( $type = null, $data = [] )

message() public method

Gets the spec's message.
public message ( ) : array
return array

messages() public method

Gets all messages upon the root.
public messages ( ) : array
return array

parent() public method

Gets the parent instance.
public parent ( ) : Scope
return Scope

report() public method

Send some data to reporters.
public report ( string $type, mixed $data, $byPassFocuses = false )
$type string The message type.
$data mixed The message data.

reporters() public method

Gets the reporters container.
public reporters ( ) : object
return object

skipIf() public method

Skips specs(s) if the condition is true.
public skipIf ( boolean $condition )
$condition boolean

summary() public method

Gets specs excecution results.
public summary ( ) : array
return array

timeout() public method

Gets/sets the timeout.
public timeout ( $timeout = null ) : integer
return integer

type() public method

Set/get the scope type.
public type ( $type = null ) : mixed
return mixed

Property Details

$_backtrace protected_oe property

The scope backtrace.
protected object $_backtrace
return object

$_backtraceFocus protected_oe property

A regexp pattern used to removes useless traces to focus on the one related to a spec file.
protected string $_backtraceFocus
return string

$_closure protected_oe property

The spec closure.
protected Closure,Closur $_closure
return Closur\Closure

$_data protected_oe property

The scope's data.
protected array $_data
return array

$_failures protected_oe property

Count the number of failure or exception.
See also: ::failfast()
protected int $_failures
return integer

$_given protected_oe property

The lazy loaded scope's data.
protected array $_given
return array

$_instances protected_oe static_oe property

Instances stack.
protected static Scope[],kahlan $_instances
return Scope[]

$_locked protected_oe property

Boolean lock which avoid process() to be called in tests
protected $_locked

$_log protected_oe property

The report log of executed spec.
protected object $_log
return object

$_message protected_oe property

The spec message.
protected string $_message
return string

$_parent protected_oe property

The parent instance.
protected Scope,kahlan $_parent
return Scope

$_passed protected_oe property

Stores the success value.
protected bool $_passed
return boolean

$_reporters protected_oe property

The reporters container.
protected object $_reporters
return object

$_root protected_oe property

The root instance.
protected object $_root
return object

$_runned protected_oe property

Indicates whether the scope has been runned or not.
protected bool $_runned
return boolean

$_summary protected_oe property

The execution summary instance.
protected object $_summary
return object

$_timeout protected_oe property

The timeout value.
protected int $_timeout
return integer

$_type protected_oe property

The scope type.
protected object $_type
return object

$blacklist public_oe static_oe property

List of reserved keywords which can't be used as scope variable.
public static array $blacklist
return array