Assert
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
Checks assertion. Values must be exactly the same.
Checks assertion. Values must not be exactly the same.
Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
Checks assertion. Values must contains expected needle.
Checks assertion. Values must not contains expected needle.
Checks TRUE assertion.
Checks FALSE assertion.
Checks NULL assertion.
Checks Not a Number assertion.
Checks truthy assertion.
Checks falsey (empty) assertion.
Checks if subject has expected count.
Checks assertion.
Checks if the function throws exception.
Checks if the function throws exception, alias for exception().
Checks if the function generates PHP error or throws exception.
Checks that the function does not generate PHP error and does not throw exception.
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
Compares results using mask sorted in file.
Failed assertion
Compares using mask.
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, $description = NULL)
Checks assertion. Values must be exactly the same.
at line 63
static void
notSame($expected, $actual, $description = NULL)
Checks assertion. Values must not be exactly the same.
at line 76
static void
equal($expected, $actual, $description = NULL)
Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
at line 89
static void
notEqual($expected, $actual, $description = NULL)
Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
at line 102
static void
contains($needle, $actual, $description = NULL)
Checks assertion. Values must contains expected needle.
at line 123
static void
notContains($needle, $actual, $description = NULL)
Checks assertion. Values must not contains expected needle.
at line 146
static void
true($actual, $description = NULL)
Checks TRUE assertion.
at line 161
static void
false($actual, $description = NULL)
Checks FALSE assertion.
at line 176
static void
null($actual, $description = NULL)
Checks NULL assertion.
at line 191
static void
nan($actual, $description = NULL)
Checks Not a Number assertion.
at line 206
static void
truthy($actual, $description = NULL)
Checks truthy assertion.
at line 221
static void
falsey($actual, $description = NULL)
Checks falsey (empty) assertion.
at line 237
static void
count($count, $value, $description = NULL)
Checks if subject has expected count.
at line 253
static void
type($type, $value, $description = NULL)
Checks assertion.
at line 286
static Exception
exception($function, $class, $message = NULL, $code = NULL)
Checks if the function throws exception.
at line 315
static Exception
throws($function, $class, $message = NULL, $code = NULL)
Checks if the function throws exception, alias for exception().
at line 328
static null|Exception
error($function, $expectedType, $expectedMessage = NULL)
Checks if the function generates PHP error or throws exception.
at line 385
static void
noError($function)
Checks that the function does not generate PHP error and does not throw exception.
at line 412
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
at line 428
static void
matchFile($file, $actual, $description = NULL)
Compares results using mask sorted in file.
at line 445
static void
fail($message, $actual = NULL, $expected = NULL)
Failed assertion
at line 462
static
with($obj, Closure $closure)
No description
at line 476
static bool
isMatching($pattern, $actual)
internal |
Compares using mask.
at line 515
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.