class Assert

Assertion test helpers.

Constants

EPSILON

used by equal() for comparing floats

Properties

static $patterns

used by match(); in values, each $ followed by number is backreference

static callable $onFailure
static int $counter

Methods

static void
same($expected, $actual)

Checks assertion. Values must be exactly the same.

static void
notSame($expected, $actual)

Checks assertion. Values must not be exactly the same.

static void
equal($expected, $actual)

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.

static void
notEqual($expected, $actual)

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.

static void
contains($needle, $actual)

Checks assertion. Values must contains expected needle.

static void
notContains($needle, $actual)

Checks assertion. Values must not contains expected needle.

static void
true($actual)

Checks TRUE assertion.

static void
false($actual)

Checks FALSE assertion.

static void
null($actual)

Checks NULL assertion.

static void
nan($actual)

Checks Not a Number assertion.

static void
truthy($actual)

Checks truthy assertion.

static void
falsey($actual)

Checks falsey (empty) assertion.

static void
count($count, $value)

Checks if subject has expected count.

static void
type($type, $value)

Checks assertion.

static Exception
exception($function, $class, $message = NULL, $code = NULL)

Checks if the function throws exception.

static Exception
throws($function, $class, $message = NULL, $code = NULL)

Checks if the function throws exception, alias for exception().

static null|Exception
error($function, $expectedType, $expectedMessage = NULL)

Checks if the function generates PHP error or throws exception.

static void
match($pattern, $actual)

Compares result using regular expression or mask: %a% one or more of anything except the end of line characters %a?% zero or more of anything except the end of line characters %A% one or more of anything including the end of line characters %A?% zero or more of anything including the end of line characters %s% one or more white space characters except the end of line characters %s?% zero or more white space characters except the end of line characters %S% one or more of characters except the white space %S?% zero or more of characters except the white space %c% a single character of any sort (except the end of line) %d% one or more digits %d?% zero or more digits %i% signed integer value %f% floating point number %h% one or more HEX digits

static void
matchFile($file, $actual)

Compares results using mask sorted in file.

static void
fail($message, $actual = NULL, $expected = NULL)

Failed assertion

static 
with($obj, Closure $closure)

No description

static bool
isMatching($pattern, $actual)

Compares using mask.

static bool
isEqual($expected, $actual, $level = 0, $objects = NULL)

Compares two structures. Ignores the identity of objects and the order of keys in the arrays.

Details

at line 50
static void same($expected, $actual)

Checks assertion. Values must be exactly the same.

Parameters

$expected
$actual

Return Value

void

at line 63
static void notSame($expected, $actual)

Checks assertion. Values must not be exactly the same.

Parameters

$expected
$actual

Return Value

void

at line 76
static void equal($expected, $actual)

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.

Parameters

$expected
$actual

Return Value

void

at line 89
static void notEqual($expected, $actual)

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.

Parameters

$expected
$actual

Return Value

void

at line 102
static void contains($needle, $actual)

Checks assertion. Values must contains expected needle.

Parameters

$needle
$actual

Return Value

void

at line 123
static void notContains($needle, $actual)

Checks assertion. Values must not contains expected needle.

Parameters

$needle
$actual

Return Value

void

at line 145
static void true($actual)

Checks TRUE assertion.

Parameters

$actual

Return Value

void

at line 159
static void false($actual)

Checks FALSE assertion.

Parameters

$actual

Return Value

void

at line 173
static void null($actual)

Checks NULL assertion.

Parameters

$actual

Return Value

void

at line 187
static void nan($actual)

Checks Not a Number assertion.

Parameters

$actual

Return Value

void

at line 201
static void truthy($actual)

Checks truthy assertion.

Parameters

$actual

Return Value

void

at line 215
static void falsey($actual)

Checks falsey (empty) assertion.

Parameters

$actual

Return Value

void

at line 230
static void count($count, $value)

Checks if subject has expected count.

Parameters

$count
$value

Return Value

void

at line 246
static void type($type, $value)

Checks assertion.

Parameters

$type
$value

Return Value

void

at line 279
static Exception exception($function, $class, $message = NULL, $code = NULL)

Checks if the function throws exception.

Parameters

$function
$class
$message
$code

Return Value

Exception

at line 308
static Exception throws($function, $class, $message = NULL, $code = NULL)

Checks if the function throws exception, alias for exception().

Parameters

$function
$class
$message
$code

Return Value

Exception

at line 321
static null|Exception error($function, $expectedType, $expectedMessage = NULL)

Checks if the function generates PHP error or throws exception.

Parameters

$function
$expectedType
$expectedMessage

Return Value

null|Exception

at line 391
static void match($pattern, $actual)

Compares result using regular expression or mask: %a% one or more of anything except the end of line characters %a?% zero or more of anything except the end of line characters %A% one or more of anything including the end of line characters %A?% zero or more of anything including the end of line characters %s% one or more white space characters except the end of line characters %s?% zero or more white space characters except the end of line characters %S% one or more of characters except the white space %S?% zero or more of characters except the white space %c% a single character of any sort (except the end of line) %d% one or more digits %d?% zero or more digits %i% signed integer value %f% floating point number %h% one or more HEX digits

Parameters

$pattern
$actual

Return Value

void

at line 407
static void matchFile($file, $actual)

Compares results using mask sorted in file.

Parameters

$file
$actual

Return Value

void

at line 424
static void fail($message, $actual = NULL, $expected = NULL)

Failed assertion

Parameters

$message
$actual
$expected

Return Value

void

at line 435
static with($obj, Closure $closure)

No description

Parameters

$obj
Closure $closure

at line 449
static bool isMatching($pattern, $actual)

internal  
 

Compares using mask.

Parameters

$pattern
$actual

Return Value

bool

at line 488
static bool isEqual($expected, $actual, $level = 0, $objects = NULL)

internal  
 

Compares two structures. Ignores the identity of objects and the order of keys in the arrays.

Parameters

$expected
$actual
$level
$objects

Return Value

bool