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, $description = null)

Checks assertion. Values must be exactly the same.

static void
notSame($expected, $actual, $description = null)

Checks assertion. Values must not be exactly the same.

static void
equal($expected, $actual, $description = null)

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

static void
notEqual($expected, $actual, $description = null)

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

static void
contains($needle, $actual, $description = null)

Checks assertion. Values must contains expected needle.

static void
notContains($needle, $actual, $description = null)

Checks assertion. Values must not contains expected needle.

static void
true($actual, $description = null)

Checks TRUE assertion.

static void
false($actual, $description = null)

Checks FALSE assertion.

static void
null($actual, $description = null)

Checks NULL assertion.

static void
nan($actual, $description = null)

Checks Not a Number assertion.

static void
truthy($actual, $description = null)

Checks truthy assertion.

static void
falsey($actual, $description = null)

Checks falsey (empty) assertion.

static void
count($count, $value, $description = null)

Checks if subject has expected count.

static void
type($type, $value, $description = null)

Checks assertion.

exception(callable $function, $class, $message = null, $code = null)

Checks if the function throws exception.

throws(callable $function, $class, $message = null, $code = null)

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

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

Checks if the function generates PHP error or throws exception.

static void
noError($function)

Checks that the function does not generate PHP error and does not throw exception.

static void
match($pattern, $actual, $description = null)

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, $description = null)

Compares results using mask sorted in file.

static void
fail($message, $actual = null, $expected = null, $previous = null)

Failed assertion

static 
with($obj, Closure $closure)

No description

static bool
isMatching($pattern, $actual, $strict = false)

Compares using mask.

static array
expandMatchingPatterns($pattern, $actual)

No description

Details

at line 52
static void same($expected, $actual, $description = null)

Checks assertion. Values must be exactly the same.

Parameters

$expected
$actual
$description

Return Value

void

at line 65
static void notSame($expected, $actual, $description = null)

Checks assertion. Values must not be exactly the same.

Parameters

$expected
$actual
$description

Return Value

void

at line 78
static void equal($expected, $actual, $description = null)

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

Parameters

$expected
$actual
$description

Return Value

void

at line 91
static void notEqual($expected, $actual, $description = null)

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

Parameters

$expected
$actual
$description

Return Value

void

at line 104
static void contains($needle, $actual, $description = null)

Checks assertion. Values must contains expected needle.

Parameters

$needle
$actual
$description

Return Value

void

at line 125
static void notContains($needle, $actual, $description = null)

Checks assertion. Values must not contains expected needle.

Parameters

$needle
$actual
$description

Return Value

void

at line 148
static void true($actual, $description = null)

Checks TRUE assertion.

Parameters

$actual
$description

Return Value

void

at line 163
static void false($actual, $description = null)

Checks FALSE assertion.

Parameters

$actual
$description

Return Value

void

at line 178
static void null($actual, $description = null)

Checks NULL assertion.

Parameters

$actual
$description

Return Value

void

at line 193
static void nan($actual, $description = null)

Checks Not a Number assertion.

Parameters

$actual
$description

Return Value

void

at line 208
static void truthy($actual, $description = null)

Checks truthy assertion.

Parameters

$actual
$description

Return Value

void

at line 223
static void falsey($actual, $description = null)

Checks falsey (empty) assertion.

Parameters

$actual
$description

Return Value

void

at line 239
static void count($count, $value, $description = null)

Checks if subject has expected count.

Parameters

$count
$value
$description

Return Value

void

at line 255
static void type($type, $value, $description = null)

Checks assertion.

Parameters

$type
$value
$description

Return Value

void

at line 288
static Exception|Throwable exception(callable $function, $class, $message = null, $code = null)

Checks if the function throws exception.

Parameters

callable $function
$class
$message
$code

Return Value

Exception|Throwable

at line 317
static Exception|Throwable throws(callable $function, $class, $message = null, $code = null)

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

Parameters

callable $function
$class
$message
$code

Return Value

Exception|Throwable

at line 330
static null|Exception|Throwable error(callable $function, $expectedType, $expectedMessage = null)

Checks if the function generates PHP error or throws exception.

Parameters

callable $function
$expectedType
$expectedMessage

Return Value

null|Exception|Throwable

at line 388
static void noError($function)

Checks that the function does not generate PHP error and does not throw exception.

Parameters

$function

Return Value

void

at line 415
static void match($pattern, $actual, $description = null)

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
$description

Return Value

void

at line 435
static void matchFile($file, $actual, $description = null)

Compares results using mask sorted in file.

Parameters

$file
$actual
$description

Return Value

void

at line 456
static void fail($message, $actual = null, $expected = null, $previous = null)

Failed assertion

Parameters

$message
$actual
$expected
$previous

Return Value

void

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

No description

Parameters

$obj
Closure $closure

at line 487
static bool isMatching($pattern, $actual, $strict = false)

internal  
 

Compares using mask.

Parameters

$pattern
$actual
$strict

Return Value

bool

at line 526
static array expandMatchingPatterns($pattern, $actual)

internal  
 

No description

Parameters

$pattern
$actual

Return Value

array