PHP Class kahlan\Suite

Inheritance: extends Scope
Datei anzeigen Open project: crysalead/kahlan Class Usage Examples

Public Properties

Property Type Description
$PHP

Protected Properties

Property Type Description
$_autoclear array Array of fully-namespaced class name to clear on each it().
$_callbacks array The each callbacks.
$_children Suite[] | Specification[] The children array.
$_ff integer Set the number of fails allowed before aborting. 0 mean no fast fail.
$_registered array Store all hashed references.
$_stats array Suite statistics.
$_status integer The return status value (0 for success).

Public Methods

Method Description
__construct ( array $config = [] ) The Constructor.
afterAll ( Closure $closure ) : self Executed after tests.
afterEach ( Closure $closure ) : self Executed after each tests.
autoclear ( ) Autoclears plugins.
beforeAll ( Closure $closure ) : self Executed before tests.
beforeEach ( Closure $closure ) : self Executed before each tests.
callbacks ( string $type ) : array Gets callbacks.
children ( ) : array Gets children.
context ( string $message, Closure $closure, null $timeout = null, string $type = 'normal' ) : Suite Adds a context related spec.
describe ( string $message, Closure $closure, $timeout = null, $type = 'normal' ) : Suite Adds a group/class related spec.
enabled ( ) : integer Gets number of enabled specs.
failfast ( ) : boolean; Returns true if the suite reach the number of allowed failure by the fail-fast parameter.
fcontext ( string $message, Closure $closure, $timeout = null ) : Suite Adds an focused context related spec.
fdescribe ( string $message, Closure $closure, $timeout = null ) : Suite Adds an focused group/class related spec.
fit ( string | Closur\Closure $message, Closur\Closure | null $closure = null, $timeout = null ) : Specification Adds an focused spec.
hash ( mixed $reference ) : string Generates a hash from an instance or a string.
it ( string | Closur\Closure $message, Closure $closure = null, $timeout = null, string $type = 'normal' ) : Specification Adds a spec.
passed ( ) : boolean Checks if all test passed.
register ( mixed $hash ) Registers a hash. [Mainly used for optimization]
registered ( string $hash = null ) : array | boolean Gets registered hashes. [Mainly used for optimizations]
reset ( ) Clears the registered hash.
run ( array $options = [] ) : boolean Runs all specs.
runCallbacks ( string $name, $recursive = true ) Runs a callback.
status ( integer $status = null ) : boolean Gets exit status code according passed results.
stop ( ) Triggers the stop event.
total ( ) : integer Gets number of total specs.
xcontext ( string $message, Closure $closure, $timeout = null ) Comments out a context related spec.
xdescribe ( string $message, Closure $closure, $timeout = null ) Comments out a group/class related spec.
xit ( string | Closur\Closure $message, Closur\Closure | null $closure = null, $timeout = null ) Comments out a spec.

Protected Methods

Method Description
_broadcastFocus ( ) Applies focus downward to the leaf.
_errorHandler ( boolean $enable, array $options = [] ) Overrides the default error handler
_process ( array $options = [] ) Suite processing.
_stats ( ) : array Builds the suite.
_suiteEnd ( ) Suite end helper.
_suiteStart ( ) Suite start helper.
stats ( ) : array Builds the suite.

Method Details

__construct() public method

The Constructor.
public __construct ( array $config = [] )
$config array The Suite config array. Options are: -`'closure'` _Closure_: the closure of the test. -`'name'` _string_ : the type of the suite.

_broadcastFocus() protected method

Applies focus downward to the leaf.
protected _broadcastFocus ( )

_errorHandler() protected method

Overrides the default error handler
protected _errorHandler ( boolean $enable, array $options = [] )
$enable boolean If `true` override the default error handler, if `false` restore the default handler.
$options array An options array. Available options are: - 'handler': An error handler closure.

_process() protected method

Suite processing.
protected _process ( array $options = [] )
$options array Process options.

_stats() protected method

Builds the suite.
protected _stats ( ) : array
return array The suite stats.

_suiteEnd() protected method

Suite end helper.
protected _suiteEnd ( )

_suiteStart() protected method

Suite start helper.
protected _suiteStart ( )

afterAll() public method

Executed after tests.
public afterAll ( Closure $closure ) : self
$closure Closure A closure
return self

afterEach() public method

Executed after each tests.
public afterEach ( Closure $closure ) : self
$closure Closure A closure
return self

autoclear() public method

Autoclears plugins.
public autoclear ( )

beforeAll() public method

Executed before tests.
public beforeAll ( Closure $closure ) : self
$closure Closure A closure
return self

beforeEach() public method

Executed before each tests.
public beforeEach ( Closure $closure ) : self
$closure Closure A closure
return self

callbacks() public method

Gets callbacks.
public callbacks ( string $type ) : array
$type string The type of callbacks to get.
return array The array callbacks instances.

children() public method

Gets children.
public children ( ) : array
return array The array of children instances.

context() public method

Adds a context related spec.
public context ( string $message, Closure $closure, null $timeout = null, string $type = 'normal' ) : Suite
$message string Description message.
$closure Closure A test case closure.
$timeout null
$type string
return Suite

describe() public method

Adds a group/class related spec.
public describe ( string $message, Closure $closure, $timeout = null, $type = 'normal' ) : Suite
$message string Description message.
$closure Closure A test case closure.
return Suite

enabled() public method

Gets number of enabled specs.
public enabled ( ) : integer
return integer

failfast() public method

Returns true if the suite reach the number of allowed failure by the fail-fast parameter.
public failfast ( ) : boolean;
return boolean;

fcontext() public method

Adds an focused context related spec.
public fcontext ( string $message, Closure $closure, $timeout = null ) : Suite
$message string Description message.
$closure Closure A test case closure.
return Suite

fdescribe() public method

Adds an focused group/class related spec.
public fdescribe ( string $message, Closure $closure, $timeout = null ) : Suite
$message string Description message.
$closure Closure A test case closure.
return Suite

fit() public method

Adds an focused spec.
public fit ( string | Closur\Closure $message, Closur\Closure | null $closure = null, $timeout = null ) : Specification
$message string | Closur\Closure Description message or a test closure.
$closure Closur\Closure | null A test case closure or `null`.
return Specification

hash() public static method

Generates a hash from an instance or a string.
public static hash ( mixed $reference ) : string
$reference mixed An instance or a fully namespaced class name.
return string A string hash.

it() public method

Adds a spec.
public it ( string | Closur\Closure $message, Closure $closure = null, $timeout = null, string $type = 'normal' ) : Specification
$message string | Closur\Closure Description message or a test closure.
$closure Closure A test case closure.
$type string The type.
return Specification

passed() public method

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

register() public static method

Registers a hash. [Mainly used for optimization]
public static register ( mixed $hash )
$hash mixed A hash to register.

registered() public static method

Gets registered hashes. [Mainly used for optimizations]
public static registered ( string $hash = null ) : array | boolean
$hash string The hash to look up. If none return all registered hashes.
return array | boolean

reset() public static method

Clears the registered hash.
public static reset ( )

run() public method

Runs all specs.
public run ( array $options = [] ) : boolean
$options array Run options.
return boolean The result array.

runCallbacks() public method

Runs a callback.
public runCallbacks ( string $name, $recursive = true )
$name string The name of the callback (i.e `'beforeEach'` or `'afterEach'`).

stats() protected method

Builds the suite.
protected stats ( ) : array
return array The suite stats.

status() public method

Gets exit status code according passed results.
public status ( integer $status = null ) : boolean
$status integer If set force a specific status to be retruned.
return boolean Returns `0` if no error occurred, `-1` otherwise.

stop() public method

Triggers the stop event.
public stop ( )

total() public method

Gets number of total specs.
public total ( ) : integer
return integer

xcontext() public method

Comments out a context related spec.
public xcontext ( string $message, Closure $closure, $timeout = null )
$message string Description message.
$closure Closure A test case closure.

xdescribe() public method

Comments out a group/class related spec.
public xdescribe ( string $message, Closure $closure, $timeout = null )
$message string Description message.
$closure Closure A test case closure.

xit() public method

Comments out a spec.
public xit ( string | Closur\Closure $message, Closur\Closure | null $closure = null, $timeout = null )
$message string | Closur\Closure Description message or a test closure.
$closure Closur\Closure | null A test case closure or `null`.

Property Details

$PHP public_oe static_oe property

public static $PHP

$_autoclear protected_oe property

Array of fully-namespaced class name to clear on each it().
protected array $_autoclear
return array

$_callbacks protected_oe property

The each callbacks.
protected array $_callbacks
return array

$_children protected_oe property

The children array.
protected Suite[],kahlan|Specification[],kahlan $_children
return Suite[] | Specification[]

$_ff protected_oe property

Set the number of fails allowed before aborting. 0 mean no fast fail.
See also: ::failfast()
protected int $_ff
return integer

$_registered protected_oe static_oe property

Store all hashed references.
protected static array $_registered
return array

$_stats protected_oe property

Suite statistics.
protected array $_stats
return array

$_status protected_oe property

The return status value (0 for success).
protected int $_status
return integer