PHP Class Tester\Assert

ファイルを表示 Open project: nette/tester Class Usage Examples

Public Properties

Property Type Description
$counter the count of assertions
$onFailure function (AssertException $exception)
$patterns used by match(); in values, each $ followed by number is backreference

Public Methods

Method Description
contains ( $needle, $actual, $description = NULL ) : void Checks assertion. Values must contains expected needle.
count ( $count, $value, $description = NULL ) : void Checks if subject has expected count.
equal ( $expected, $actual, $description = NULL ) : void Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
error ( callable $function, $expectedType, $expectedMessage = NULL ) : null | Exception Checks if the function generates PHP error or throws exception.
exception ( callable $function, $class, $message = NULL, $code = NULL ) : Exception Checks if the function throws exception.
expandMatchingPatterns ( $pattern, $actual ) : array
fail ( $message, $actual = NULL, $expected = NULL ) : void Failed assertion
false ( $actual, $description = NULL ) : void Checks FALSE assertion.
falsey ( $actual, $description = NULL ) : void Checks falsey (empty) assertion.
isMatching ( $pattern, $actual, $strict = FALSE ) : boolean Compares using mask.
match ( $pattern, $actual, $description = NULL ) : void 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
matchFile ( $file, $actual, $description = NULL ) : void Compares results using mask sorted in file.
nan ( $actual, $description = NULL ) : void Checks Not a Number assertion.
noError ( $function ) : void Checks that the function does not generate PHP error and does not throw exception.
notContains ( $needle, $actual, $description = NULL ) : void Checks assertion. Values must not contains expected needle.
notEqual ( $expected, $actual, $description = NULL ) : void Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
notSame ( $expected, $actual, $description = NULL ) : void Checks assertion. Values must not be exactly the same.
null ( $actual, $description = NULL ) : void Checks NULL assertion.
same ( $expected, $actual, $description = NULL ) : void Checks assertion. Values must be exactly the same.
throws ( callable $function, $class, $message = NULL, $code = NULL ) : Exception Checks if the function throws exception, alias for exception().
true ( $actual, $description = NULL ) : void Checks TRUE assertion.
truthy ( $actual, $description = NULL ) : void Checks truthy assertion.
type ( $type, $value, $description = NULL ) : void Checks assertion.
with ( $obj, Closure $closure )

Private Methods

Method Description
describe ( $reason, $description )
isEqual ( $expected, $actual, $level, $objects = NULL ) : boolean Compares two structures. Ignores the identity of objects and the order of keys in the arrays.
isPcre ( $pattern ) : boolean

Method Details

contains() public static method

Checks assertion. Values must contains expected needle.
public static contains ( $needle, $actual, $description = NULL ) : void
return void

count() public static method

Checks if subject has expected count.
public static count ( $count, $value, $description = NULL ) : void
return void

equal() public static method

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
public static equal ( $expected, $actual, $description = NULL ) : void
return void

error() public static method

Checks if the function generates PHP error or throws exception.
public static error ( callable $function, $expectedType, $expectedMessage = NULL ) : null | Exception
$function callable
return null | Exception

exception() public static method

Checks if the function throws exception.
public static exception ( callable $function, $class, $message = NULL, $code = NULL ) : Exception
$function callable
return Exception

expandMatchingPatterns() public static method

public static expandMatchingPatterns ( $pattern, $actual ) : array
return array

fail() public static method

Failed assertion
public static fail ( $message, $actual = NULL, $expected = NULL ) : void
return void

false() public static method

Checks FALSE assertion.
public static false ( $actual, $description = NULL ) : void
return void

falsey() public static method

Checks falsey (empty) assertion.
public static falsey ( $actual, $description = NULL ) : void
return void

isMatching() public static method

Compares using mask.
public static isMatching ( $pattern, $actual, $strict = FALSE ) : boolean
return boolean

match() public static method

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
public static match ( $pattern, $actual, $description = NULL ) : void
return void

matchFile() public static method

Compares results using mask sorted in file.
public static matchFile ( $file, $actual, $description = NULL ) : void
return void

nan() public static method

Checks Not a Number assertion.
public static nan ( $actual, $description = NULL ) : void
return void

noError() public static method

Checks that the function does not generate PHP error and does not throw exception.
public static noError ( $function ) : void
return void

notContains() public static method

Checks assertion. Values must not contains expected needle.
public static notContains ( $needle, $actual, $description = NULL ) : void
return void

notEqual() public static method

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
public static notEqual ( $expected, $actual, $description = NULL ) : void
return void

notSame() public static method

Checks assertion. Values must not be exactly the same.
public static notSame ( $expected, $actual, $description = NULL ) : void
return void

null() public static method

Checks NULL assertion.
public static null ( $actual, $description = NULL ) : void
return void

same() public static method

Checks assertion. Values must be exactly the same.
public static same ( $expected, $actual, $description = NULL ) : void
return void

throws() public static method

Checks if the function throws exception, alias for exception().
public static throws ( callable $function, $class, $message = NULL, $code = NULL ) : Exception
$function callable
return Exception

true() public static method

Checks TRUE assertion.
public static true ( $actual, $description = NULL ) : void
return void

truthy() public static method

Checks truthy assertion.
public static truthy ( $actual, $description = NULL ) : void
return void

type() public static method

Checks assertion.
public static type ( $type, $value, $description = NULL ) : void
return void

with() public static method

public static with ( $obj, Closure $closure )
$closure Closure

Property Details

$counter public_oe static_oe property

the count of assertions
public static $counter

$onFailure public_oe static_oe property

function (AssertException $exception)
public static $onFailure

$patterns public_oe static_oe property

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