Properties

$data

$data : \StdClass

A public object for storing state and other variables across test cases and method calls.

Type

\StdClass

$tests

$tests : 

Type

$stack

$stack : 

Type

$fileCache

$fileCache : 

Type

$currentTestCase

$currentTestCase : 

Type

$suiteTitle

$suiteTitle : 

Type

$suiteResults

$suiteResults : 

Type

$before

$before : 

Type

$after

$after : 

Type

$beforeEach

$beforeEach : 

Type

$afterEach

$afterEach : 

Type

Methods

__construct()

__construct(string  $title) 

The constructor.

Parameters

string $title

The suite title

test()

test(string  $name, \function  $testCase = null) : $this

Add a test case.

Parameters

string $name

Title of the test case

\function $testCase

(optional) The test case as a callback

Returns

$this

before()

before(\function  $callback) 

Executed once before the test cases are run.

Parameters

\function $callback

An anonymous callback function

after()

after(\function  $callback) 

Executed once after the test cases are run.

Parameters

\function $callback

An anonymous callback function

beforeEach()

beforeEach(\function  $callback) 

Executed for every test case, before it is run.

Parameters

\function $callback

An anonymous callback function

afterEach()

afterEach(\function  $callback) 

Executed for every test case, after it is run.

Parameters

\function $callback

An anonymous callback function

run()

run() : $this

Run all the tests and before / after functions. Calls {@see report} to generate the HTML report page.

Returns

$this

assert()

assert(boolean  $arg, string  $message = '') : boolean

Alias for {@see assertTrue} method.

Parameters

boolean $arg

The result of a boolean expression

string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertTrue()

assertTrue(boolean  $arg, string  $message = '') : boolean

Passes if given a truthfull expression.

Parameters

boolean $arg

The result of a boolean expression

string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertFalse()

assertFalse(boolean  $arg, string  $message = '') : boolean

Passes if given a falsy expression.

Parameters

boolean $arg

The result of a boolean expression

string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertEquals()

assertEquals(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Passes if $arg1 == $arg2.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertNotEquals()

assertNotEquals(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Passes if $arg1 != $arg2.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertSame()

assertSame(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Passes if $arg1 === $arg2.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertNotSame()

assertNotSame(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Passes if $arg1 !== $arg2.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertInArray()

assertInArray(mixed  $arg, array  $arr, string  $message = '') : boolean

Passes if $arg is an element of $arr.

Parameters

mixed $arg
array $arr
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertNotInArray()

assertNotInArray(mixed  $arg, array  $arr, string  $message = '') : boolean

Passes if $arg is not an element of $arr.

Parameters

mixed $arg
array $arr
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

pass()

pass(string  $message = '') : boolean

Unconditional pass.

Parameters

string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

fail()

fail(string  $message = '') : boolean

Unconditional fail.

Parameters

string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

report()

report() : $this

Generates a pretty CLI or HTML5 report of the test suite status. Called implicitly by {@see run}.

Returns

$this

assertEqual()

assertEqual(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Alias for {@see assertEquals}.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

assertIdentical()

assertIdentical(mixed  $arg1, mixed  $arg2, string  $message = '') : boolean

Alias for {@see assertSame}.

Parameters

mixed $arg1
mixed $arg2
string $message

(optional) Custom message. SHOULD be specified for easier debugging

Returns

boolean

__invoke()

__invoke() : $this

Alias for {@see run} method.

Returns

$this

recordTest()

recordTest(boolean  $pass, string  $message = '') : boolean

A helper method for recording the results of the assertions in the internal stack.

Parameters

boolean $pass

If equals true, the test has passed, otherwise failed

string $message

(optional) Custom message

Returns

boolean

getFileLine()

getFileLine(string  $file, integer  $line) : string

Internal method for fetching a specific line of a text file. With caching.

Parameters

string $file

The file name

integer $line

The line number to return

Returns

string

affirmCallable()

affirmCallable(mixed  $callback, string  $name) 

Internal helper method for determine whether a variable is callable as a function.

Parameters

mixed $callback

The variable to check

string $name

Used for the error message text to indicate the name of the parent context

Throws

\Testify\TestifyException

if callback argument is not a function