Assertion
in package
Uses
ChainableTrait
Represents a test assertion.
Table of Contents
- $a : Assertion
- $an : Assertion
- $and : Assertion
- $at : Assertion
- $be : Assertion
- $been : Assertion
- $but : Assertion
- $directory : Assertion
- $does : Assertion
- $empty : Assertion
- $exist : Assertion
- $false : Assertion
- $file : Assertion
- $has : Assertion
- $have : Assertion
- $infinite : Assertion
- $is : Assertion
- $json : Assertion
- $length : Assertion
- $lengthOf : Assertion
- $NaN : Assertion
- $not : Assertion
- $null : Assertion
- $of : Assertion
- $readable : Assertion
- $same : Assertion
- $still : Assertion
- $that : Assertion
- $throw : Assertion
- $to : Assertion
- $true : Assertion
- $which : Assertion
- $with : Assertion
- $writable : Assertion
- $xml : Assertion
- __construct() : mixed
- Assertion constructor.
- __get() : mixed
- Invokes the instance method with the specified name.
- a() : $this
- Reports an error if the target is not of the specified type.
- above() : $this
- Reports an error if the target is not greater than the specified value.
- an() : $this
- Reports an error if the target is not of the specified type.
- and() : $this
- Chainable method to improve the readability of an assertion.
- approximately() : $this
- Reports an error if the target is not equal to the specified value, within a given delta range.
- at() : $this
- Chainable method to improve the readability of an assertion.
- be() : $this
- Chainable method to improve the readability of an assertion.
- been() : $this
- Chainable method to improve the readability of an assertion.
- below() : $this
- Reports an error if the target is not less than the specified value.
- but() : $this
- Chainable method to improve the readability of an assertion.
- closeTo() : $this
- Reports an error if the target is not equal to the specified value, within a given delta range.
- contain() : $this
- Reports an error if the target does not contain an element or a substring.
- containOnly() : $this
- Reports an error if the target does not contain only variables of a given type.
- containOnlyInstancesOf() : $this
- Reports an error if the target does not contain only instances of a given class.
- contains() : $this
- Reports an error if the target does not contain an element or a substring.
- directory() : $this
- Indicates that the assertion following in the chain targets a directory.
- does() : $this
- Chainable method to improve the readability of an assertion.
- empty() : $this
- Reports an error if the target is not empty.
- endWith() : $this
- Reports an error if the target does not end with the specified suffix.
- equal() : $this
- Reports an error if the target and the specified value are not equal.
- equals() : $this
- Reports an error if the target and the specified value are not equal.
- exist() : $this
- Reports an error if the file or directory specified by the target does not exist.
- false() : $this
- Reports an error if the target is `true`.
- file() : $this
- Indicates that the assertion following in the chain targets a file.
- has() : $this
- Chainable method to improve the readability of an assertion.
- have() : $this
- Chainable method to improve the readability of an assertion.
- identicalTo() : $this
- Reports an error if the target and the specified variable do not have the same type and value.
- include() : $this
- Reports an error if the target does not contain an element or a substring.
- includes() : $this
- Reports an error if the target does not contain an element or a substring.
- infinite() : $this
- Reports an error if the target is not `INF`.
- instanceOf() : $this
- Reports an error if the target is not an instance of the specified class.
- is() : $this
- Chainable method to improve the readability of an assertion.
- json() : $this
- Indicates that the assertion following in the chain targets JSON data.
- least() : $this
- Reports an error if the target is not greater than or equal to the specified value.
- length() : $this
- Reports an error if the length of the target is not the expected one.
- lengthOf() : $this
- Reports an error if the length of the target is not the expected one.
- match() : $this
- Reports an error if the target does not match the specified regular expression.
- matchFormat() : $this
- Reports an error if the target does not match the specified format string.
- most() : $this
- Reports an error if the target is not less than or equal to the specified value.
- NaN() : $this
- Reports an error if the target is not `NAN`.
- not() : $this
- Negates any of assertions following in the chain.
- null() : $this
- Reports an error if the target is not `null`.
- of() : $this
- Chainable method to improve the readability of an assertion.
- oneOf() : $this
- Reports an error if the target is not contained in the specified list or string.
- ordered() : $this
- Indicates that the assertion following in the chain targets a file.
- property() : $this
- Reports an error if the target has not a given property or key.
- readable() : $this
- Reports an error if the file or directory specified by the target is not readable.
- same() : $this
- Chainable method to improve the readability of an assertion.
- satisfy() : $this
- Reports an error if the target does not pass a given truth test.
- startWith() : $this
- Reports an error if the target does not start with the specified prefix.
- still() : $this
- Chainable method to improve the readability of an assertion.
- that() : $this
- Chainable method to improve the readability of an assertion.
- throw() : $this
- Reports an error if the function target does not throw a given exception.
- to() : $this
- Chainable method to improve the readability of an assertion.
- true() : $this
- Reports an error if the target is `false`.
- which() : $this
- Chainable method to improve the readability of an assertion.
- with() : $this
- Chainable method to improve the readability of an assertion.
- within() : $this
- Reports an error if the target is greater than or less than the specified bounds.
- writable() : $this
- Reports an error if the file or directory specified by the target is not writable.
- xml() : $this
- Indicates that the assertion following in the chain targets XML data.
Properties
$a
public
Assertion
$a
Chainable property to improve the readability of an assertion.
$an
public
Assertion
$an
Chainable property to improve the readability of an assertion.
$and
public
Assertion
$and
Chainable property to improve the readability of an assertion.
$at
public
Assertion
$at
Chainable property to improve the readability of an assertion.
$be
public
Assertion
$be
Chainable property to improve the readability of an assertion.
$been
public
Assertion
$been
Chainable property to improve the readability of an assertion.
$but
public
Assertion
$but
Chainable property to improve the readability of an assertion.
$directory
public
Assertion
$directory
Indicates that the assertion following in the chain targets a directory.
$does
public
Assertion
$does
Chainable property to improve the readability of an assertion.
$empty
public
Assertion
$empty
Reports an error if the target is not empty.
$exist
public
Assertion
$exist
Reports an error if the file or directory specified by the target does not exist.
$false
public
Assertion
$false
Reports an error if the target is true.
$file
public
Assertion
$file
Indicates that the assertion following in the chain targets a file.
$has
public
Assertion
$has
Chainable property to improve the readability of an assertion.
$have
public
Assertion
$have
Chainable property to improve the readability of an assertion.
$infinite
public
Assertion
$infinite
Reports an error if the target is not INF.
$is
public
Assertion
$is
Chainable property to improve the readability of an assertion.
$json
public
Assertion
$json
Indicates that the assertion following in the chain targets JSON data.
$length
public
Assertion
$length
Indicates that the assertion following in the chain targets a length.
$lengthOf
public
Assertion
$lengthOf
Indicates that the assertion following in the chain targets a length.
$NaN
public
Assertion
$NaN
Reports an error if the target is not NAN.
$not
public
Assertion
$not
Negates any of assertions following in the chain.
$null
public
Assertion
$null
Reports an error if the target is not null.
$of
public
Assertion
$of
Chainable property to improve the readability of an assertion.
$readable
public
Assertion
$readable
Reports an error if the file or directory specified by the target is not readable.
$same
public
Assertion
$same
Chainable property to improve the readability of an assertion.
$still
public
Assertion
$still
Chainable property to improve the readability of an assertion.
$that
public
Assertion
$that
Chainable property to improve the readability of an assertion.
$throw
public
Assertion
$throw
Reports an error if the function target does not throw an exception.
$to
public
Assertion
$to
Chainable property to improve the readability of an assertion.
$true
public
Assertion
$true
Reports an error if the target is false.
$which
public
Assertion
$which
Chainable property to improve the readability of an assertion.
$with
public
Assertion
$with
Chainable property to improve the readability of an assertion.
$writable
public
Assertion
$writable
Reports an error if the file or directory specified by the target is not writable.
$xml
public
Assertion
$xml
Indicates that the assertion following in the chain targets XML data.
Methods
__construct()
Assertion constructor.
public
__construct(mixed $target[, string $message = "" ]) : mixed
Parameters
- $target : mixed
-
The target of the assertion.
- $message : string = ""
-
A message identifying the error generated by the assertion when it fails.
Return values
mixed —__get()
Invokes the instance method with the specified name.
public
__get(string $name) : mixed
Parameters
- $name : string
-
The name of the method to invoke.
Tags
Return values
mixed —The return value of the invoked method.
a()
Reports an error if the target is not of the specified type.
public
a([string $type = "" ]) : $this
This method can also be used as language chain.
Parameters
- $type : string = ""
-
The type to check. Specify an empty string to use as language chain.
Return values
$this —This instance.
above()
Reports an error if the target is not greater than the specified value.
public
above(int|float $value) : $this
Parameters
- $value : int|float
-
The value to compare.
Return values
$this —This instance.
an()
Reports an error if the target is not of the specified type.
public
an([string $type = "" ]) : $this
This method can also be used as language chain.
Parameters
- $type : string = ""
-
The type to check. Specify an empty string to use as language chain.
Tags
Return values
$this —This instance.
and()
Chainable method to improve the readability of an assertion.
public
and() : $this
Return values
$this —This instance.
approximately()
Reports an error if the target is not equal to the specified value, within a given delta range.
public
approximately(int|float $value, float $delta) : $this
Parameters
- $value : int|float
-
The value to compare.
- $delta : float
-
The allowed distance between two values to consider them equal.
Tags
Return values
$this —This instance.
at()
Chainable method to improve the readability of an assertion.
public
at() : $this
Return values
$this —This instance.
be()
Chainable method to improve the readability of an assertion.
public
be() : $this
Return values
$this —This instance.
been()
Chainable method to improve the readability of an assertion.
public
been() : $this
Return values
$this —This instance.
below()
Reports an error if the target is not less than the specified value.
public
below(int|float $value) : $this
Parameters
- $value : int|float
-
The value to compare.
Return values
$this —This instance.
but()
Chainable method to improve the readability of an assertion.
public
but() : $this
Return values
$this —This instance.
closeTo()
Reports an error if the target is not equal to the specified value, within a given delta range.
public
closeTo(int|float $value, float $delta) : $this
Parameters
- $value : int|float
-
The value to compare.
- $delta : float
-
The allowed distance between two values to consider them equal.
Return values
$this —This instance.
contain()
Reports an error if the target does not contain an element or a substring.
public
contain([mixed $value = null ]) : $this
Parameters
- $value : mixed = null
-
The value to find.
Return values
$this —This instance.
containOnly()
Reports an error if the target does not contain only variables of a given type.
public
containOnly(string $type) : $this
Parameters
- $type : string
-
The type to check.
Return values
$this —This instance.
containOnlyInstancesOf()
Reports an error if the target does not contain only instances of a given class.
public
containOnlyInstancesOf(string $className) : $this
Parameters
- $className : string
-
The name of the class to check.
Return values
$this —This instance.
contains()
Reports an error if the target does not contain an element or a substring.
public
contains([mixed $value = null ]) : $this
Parameters
- $value : mixed = null
-
The value to find.
Tags
Return values
$this —This instance.
directory()
Indicates that the assertion following in the chain targets a directory.
public
directory() : $this
Return values
$this —This instance.
does()
Chainable method to improve the readability of an assertion.
public
does() : $this
Return values
$this —This instance.
empty()
Reports an error if the target is not empty.
public
empty() : $this
For arrays, strings, and Countable instances, it checks the length. For objects, it gets the count of accessible properties according to scope.
Return values
$this —This instance.
endWith()
Reports an error if the target does not end with the specified suffix.
public
endWith(string $value) : $this
Parameters
- $value : string
-
The suffix to check.
Return values
$this —This instance.
equal()
Reports an error if the target and the specified value are not equal.
public
equal(mixed $value) : $this
Parameters
- $value : mixed
-
The value to compare.
Return values
$this —This instance.
equals()
Reports an error if the target and the specified value are not equal.
public
equals(mixed $value) : $this
Parameters
- $value : mixed
-
The value to compare.
Tags
Return values
$this —This instance.
exist()
Reports an error if the file or directory specified by the target does not exist.
public
exist() : $this
Tags
Return values
$this —This instance.
false()
Reports an error if the target is `true`.
public
false() : $this
Return values
$this —This instance.
file()
Indicates that the assertion following in the chain targets a file.
public
file() : $this
Return values
$this —This instance.
has()
Chainable method to improve the readability of an assertion.
public
has() : $this
Return values
$this —This instance.
have()
Chainable method to improve the readability of an assertion.
public
have() : $this
Return values
$this —This instance.
identicalTo()
Reports an error if the target and the specified variable do not have the same type and value.
public
identicalTo(mixed $value) : $this
Parameters
- $value : mixed
-
The variable to compare.
Return values
$this —This instance.
include()
Reports an error if the target does not contain an element or a substring.
public
include([mixed $value = null ]) : $this
Parameters
- $value : mixed = null
-
The value to find.
Tags
Return values
$this —This instance.
includes()
Reports an error if the target does not contain an element or a substring.
public
includes([mixed $value = null ]) : $this
Parameters
- $value : mixed = null
-
The value to find.
Tags
Return values
$this —This instance.
infinite()
Reports an error if the target is not `INF`.
public
infinite() : $this
Return values
$this —This instance.
instanceOf()
Reports an error if the target is not an instance of the specified class.
public
instanceOf(string $className) : $this
Parameters
- $className : string
-
The name of the class to test.
Return values
$this —This instance.
is()
Chainable method to improve the readability of an assertion.
public
is() : $this
Return values
$this —This instance.
json()
Indicates that the assertion following in the chain targets JSON data.
public
json() : $this
Return values
$this —This instance.
least()
Reports an error if the target is not greater than or equal to the specified value.
public
least(int|float $value) : $this
Parameters
- $value : int|float
-
The value to compare.
Return values
$this —This instance.
length()
Reports an error if the length of the target is not the expected one.
public
length([int|null $value = null ]) : $this
Parameters
- $value : int|null = null
-
The expected length.
Tags
Return values
$this —This instance.
lengthOf()
Reports an error if the length of the target is not the expected one.
public
lengthOf([int|null $value = null ]) : $this
Parameters
- $value : int|null = null
-
The expected length.
Return values
$this —This instance.
match()
Reports an error if the target does not match the specified regular expression.
public
match(string $pattern) : $this
Parameters
- $pattern : string
-
The regular expression to test.
Return values
$this —This instance.
matchFormat()
Reports an error if the target does not match the specified format string.
public
matchFormat(string $format) : $this
Parameters
- $format : string
-
The format string to test.
Return values
$this —This instance.
most()
Reports an error if the target is not less than or equal to the specified value.
public
most(int|float $value) : $this
Parameters
- $value : int|float
-
The value to compare.
Return values
$this —This instance.
NaN()
Reports an error if the target is not `NAN`.
public
NaN() : $this
Return values
$this —This instance.
not()
Negates any of assertions following in the chain.
public
not() : $this
Return values
$this —This instance.
null()
Reports an error if the target is not `null`.
public
null() : $this
Return values
$this —This instance.
of()
Chainable method to improve the readability of an assertion.
public
of() : $this
Return values
$this —This instance.
oneOf()
Reports an error if the target is not contained in the specified list or string.
public
oneOf(iteratable<string|int, mixed> $value) : $this
Parameters
- $value : iteratable<string|int, mixed>
-
The value provider.
Return values
$this —This instance.
ordered()
Indicates that the assertion following in the chain targets a file.
public
ordered() : $this
Return values
$this —This instance.
property()
Reports an error if the target has not a given property or key.
public
property(string $name[, mixed $value = null ]) : $this
Optionally asserts that the value of that property or key is equal to the specified value. Changes the subject of the assertion to be the value of that property from the original object.
Parameters
- $name : string
-
The property name.
- $value : mixed = null
-
The property value.
Return values
$this —This instance.
readable()
Reports an error if the file or directory specified by the target is not readable.
public
readable() : $this
Tags
Return values
$this —This instance.
same()
Chainable method to improve the readability of an assertion.
public
same() : $this
Return values
$this —This instance.
satisfy()
Reports an error if the target does not pass a given truth test.
public
satisfy(callable $predicate) : $this
Parameters
- $predicate : callable
-
The predicate to invoke.
Return values
$this —This instance.
startWith()
Reports an error if the target does not start with the specified prefix.
public
startWith(string $value) : $this
Parameters
- $value : string
-
The prefix to check.
Return values
$this —This instance.
still()
Chainable method to improve the readability of an assertion.
public
still() : $this
Return values
$this —This instance.
that()
Chainable method to improve the readability of an assertion.
public
that() : $this
Return values
$this —This instance.
throw()
Reports an error if the function target does not throw a given exception.
public
throw([string $className = "" ]) : $this
Parameters
- $className : string = ""
-
The class name of the exception.
Tags
Return values
$this —This instance.
to()
Chainable method to improve the readability of an assertion.
public
to() : $this
Return values
$this —This instance.
true()
Reports an error if the target is `false`.
public
true() : $this
Return values
$this —This instance.
which()
Chainable method to improve the readability of an assertion.
public
which() : $this
Return values
$this —This instance.
with()
Chainable method to improve the readability of an assertion.
public
with() : $this
Return values
$this —This instance.
within()
Reports an error if the target is greater than or less than the specified bounds.
public
within(int|float $start, int|float $finish) : $this
Parameters
- $start : int|float
-
The lowerbound inclusive.
- $finish : int|float
-
The upperbound inclusive.
Return values
$this —This instance.
writable()
Reports an error if the file or directory specified by the target is not writable.
public
writable() : $this
Tags
Return values
$this —This instance.
xml()
Indicates that the assertion following in the chain targets XML data.
public
xml() : $this
Return values
$this —This instance.