PHP Класс Tester\Assert

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$counter the count of assertions
$onFailure function (AssertException $exception)
$patterns used by match(); in values, each $ followed by number is backreference

Открытые методы

Метод Описание
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 )

Приватные методы

Метод Описание
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

Описание методов

contains() публичный статический Метод

Checks assertion. Values must contains expected needle.
public static contains ( $needle, $actual, $description = NULL ) : void
Результат void

count() публичный статический Метод

Checks if subject has expected count.
public static count ( $count, $value, $description = NULL ) : void
Результат void

equal() публичный статический Метод

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
public static equal ( $expected, $actual, $description = NULL ) : void
Результат void

error() публичный статический Метод

Checks if the function generates PHP error or throws exception.
public static error ( callable $function, $expectedType, $expectedMessage = NULL ) : null | Exception
$function callable
Результат null | Exception

exception() публичный статический Метод

Checks if the function throws exception.
public static exception ( callable $function, $class, $message = NULL, $code = NULL ) : Exception
$function callable
Результат Exception

expandMatchingPatterns() публичный статический Метод

public static expandMatchingPatterns ( $pattern, $actual ) : array
Результат array

fail() публичный статический Метод

Failed assertion
public static fail ( $message, $actual = NULL, $expected = NULL ) : void
Результат void

false() публичный статический Метод

Checks FALSE assertion.
public static false ( $actual, $description = NULL ) : void
Результат void

falsey() публичный статический Метод

Checks falsey (empty) assertion.
public static falsey ( $actual, $description = NULL ) : void
Результат void

isMatching() публичный статический Метод

Compares using mask.
public static isMatching ( $pattern, $actual, $strict = FALSE ) : boolean
Результат boolean

match() публичный статический Метод

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
Результат void

matchFile() публичный статический Метод

Compares results using mask sorted in file.
public static matchFile ( $file, $actual, $description = NULL ) : void
Результат void

nan() публичный статический Метод

Checks Not a Number assertion.
public static nan ( $actual, $description = NULL ) : void
Результат void

noError() публичный статический Метод

Checks that the function does not generate PHP error and does not throw exception.
public static noError ( $function ) : void
Результат void

notContains() публичный статический Метод

Checks assertion. Values must not contains expected needle.
public static notContains ( $needle, $actual, $description = NULL ) : void
Результат void

notEqual() публичный статический Метод

Checks assertion. The identity of objects and the order of keys in the arrays are ignored.
public static notEqual ( $expected, $actual, $description = NULL ) : void
Результат void

notSame() публичный статический Метод

Checks assertion. Values must not be exactly the same.
public static notSame ( $expected, $actual, $description = NULL ) : void
Результат void

null() публичный статический Метод

Checks NULL assertion.
public static null ( $actual, $description = NULL ) : void
Результат void

same() публичный статический Метод

Checks assertion. Values must be exactly the same.
public static same ( $expected, $actual, $description = NULL ) : void
Результат void

throws() публичный статический Метод

Checks if the function throws exception, alias for exception().
public static throws ( callable $function, $class, $message = NULL, $code = NULL ) : Exception
$function callable
Результат Exception

true() публичный статический Метод

Checks TRUE assertion.
public static true ( $actual, $description = NULL ) : void
Результат void

truthy() публичный статический Метод

Checks truthy assertion.
public static truthy ( $actual, $description = NULL ) : void
Результат void

type() публичный статический Метод

Checks assertion.
public static type ( $type, $value, $description = NULL ) : void
Результат void

with() публичный статический Метод

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

Описание свойств

$counter публичное статическое свойство

the count of assertions
public static $counter

$onFailure публичное статическое свойство

function (AssertException $exception)
public static $onFailure

$patterns публичное статическое свойство

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