class Assert (View source)

A set of assertion methods.

Methods

static 
assertArrayHasKey(mixed $key, array|ArrayAccess $array, string $message = '')

Asserts that an array has a specified key.

static 
assertArraySubset(array|ArrayAccess $subset, array|ArrayAccess $array, bool $strict = false, string $message = '')

Asserts that an array has a specified subset.

static 
assertArrayNotHasKey(mixed $key, array|ArrayAccess $array, string $message = '')

Asserts that an array does not have a specified key.

static 
assertContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack contains a needle.

static 
assertAttributeContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.

static 
assertNotContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack does not contain a needle.

static 
assertAttributeNotContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.

static 
assertContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')

Asserts that a haystack contains only values of a given type.

static 
assertContainsOnlyInstancesOf(string $classname, array|Traversable $haystack, string $message = '')

Asserts that a haystack contains only instances of a given classname

static 
assertAttributeContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.

static 
assertNotContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')

Asserts that a haystack does not contain only values of a given type.

static 
assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.

static 
assertCount(int $expectedCount, mixed $haystack, string $message = '')

Asserts the number of elements of an array, Countable or Traversable.

static 
assertAttributeCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

static 
assertNotCount(int $expectedCount, mixed $haystack, string $message = '')

Asserts the number of elements of an array, Countable or Traversable.

static 
assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

static 
assertEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that two variables are equal.

static 
assertAttributeEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that a variable is equal to an attribute of an object.

static 
assertNotEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that two variables are not equal.

static 
assertAttributeNotEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that a variable is not equal to an attribute of an object.

static 
assertEmpty(mixed $actual, string $message = '')

Asserts that a variable is empty.

static 
assertAttributeEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts that a static attribute of a class or an attribute of an object is empty.

static 
assertNotEmpty(mixed $actual, string $message = '')

Asserts that a variable is not empty.

static 
assertAttributeNotEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts that a static attribute of a class or an attribute of an object is not empty.

static 
assertGreaterThan(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is greater than another value.

static 
assertAttributeGreaterThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is greater than another value.

static 
assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is greater than or equal to another value.

static 
assertAttributeGreaterThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is greater than or equal to another value.

static 
assertLessThan(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is smaller than another value.

static 
assertAttributeLessThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is smaller than another value.

static 
assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is smaller than or equal to another value.

static 
assertAttributeLessThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is smaller than or equal to another value.

static 
assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of one file is equal to the contents of another file.

static 
assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of one file is not equal to the contents of another file.

static 
assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of a string is equal to the contents of a file.

static 
assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of a string is not equal to the contents of a file.

static 
assertIsReadable(string $filename, string $message = '')

Asserts that a file/dir is readable.

static 
assertNotIsReadable(string $filename, string $message = '')

Asserts that a file/dir exists and is not readable.

static 
assertIsWritable(string $filename, string $message = '')

Asserts that a file/dir exists and is writable.

static 
assertNotIsWritable(string $filename, string $message = '')

Asserts that a file/dir exists and is not writable.

static 
assertDirectoryExists(string $directory, string $message = '')

Asserts that a directory exists.

static 
assertDirectoryNotExists(string $directory, string $message = '')

Asserts that a directory does not exist.

static 
assertDirectoryIsReadable(string $directory, string $message = '')

Asserts that a directory exists and is readable.

static 
assertDirectoryNotIsReadable(string $directory, string $message = '')

Asserts that a directory exists and is not readable.

static 
assertDirectoryIsWritable(string $directory, string $message = '')

Asserts that a directory exists and is writable.

static 
assertDirectoryNotIsWritable(string $directory, string $message = '')

Asserts that a directory exists and is not writable.

static 
assertFileExists(string $filename, string $message = '')

Asserts that a file exists.

static 
assertFileNotExists(string $filename, string $message = '')

Asserts that a file does not exist.

static 
assertFileIsReadable(string $file, string $message = '')

Asserts that a file exists and is readable.

static 
assertFileNotIsReadable(string $file, string $message = '')

Asserts that a file exists and is not readable.

static 
assertFileIsWritable(string $file, string $message = '')

Asserts that a file exists and is writable.

static 
assertFileNotIsWritable(string $file, string $message = '')

Asserts that a file exists and is not writable.

static 
assertTrue(bool $condition, string $message = '')

Asserts that a condition is true.

static 
assertNotTrue(bool $condition, string $message = '')

Asserts that a condition is not true.

static 
assertFalse(bool $condition, string $message = '')

Asserts that a condition is false.

static 
assertNotFalse(bool $condition, string $message = '')

Asserts that a condition is not false.

static 
assertNull(mixed $actual, string $message = '')

Asserts that a variable is null.

static 
assertNotNull(mixed $actual, string $message = '')

Asserts that a variable is not null.

static 
assertFinite(mixed $actual, string $message = '')

Asserts that a variable is finite.

static 
assertInfinite(mixed $actual, string $message = '')

Asserts that a variable is infinite.

static 
assertNan(mixed $actual, string $message = '')

Asserts that a variable is nan.

static 
assertClassHasAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class has a specified attribute.

static 
assertClassNotHasAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class does not have a specified attribute.

static 
assertClassHasStaticAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class has a specified static attribute.

static 
assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class does not have a specified static attribute.

static 
assertObjectHasAttribute(string $attributeName, object $object, string $message = '')

Asserts that an object has a specified attribute.

static 
assertObjectNotHasAttribute(string $attributeName, object $object, string $message = '')

Asserts that an object does not have a specified attribute.

static 
assertSame(mixed $expected, mixed $actual, string $message = '')

Asserts that two variables have the same type and value.

static 
assertAttributeSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that a variable and an attribute of an object have the same type and value.

static 
assertNotSame(mixed $expected, mixed $actual, string $message = '')

Asserts that two variables do not have the same type and value.

static 
assertAttributeNotSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that a variable and an attribute of an object do not have the same type and value.

static 
assertInstanceOf(string $expected, mixed $actual, string $message = '')

Asserts that a variable is of a given type.

static 
assertAttributeInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

static 
assertNotInstanceOf(string $expected, mixed $actual, string $message = '')

Asserts that a variable is not of a given type.

static 
assertAttributeNotInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

static 
assertInternalType(string $expected, mixed $actual, string $message = '')

Asserts that a variable is of a given type.

static 
assertAttributeInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

static 
assertNotInternalType(string $expected, mixed $actual, string $message = '')

Asserts that a variable is not of a given type.

static 
assertAttributeNotInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

static 
assertRegExp(string $pattern, string $string, string $message = '')

Asserts that a string matches a given regular expression.

static 
assertNotRegExp(string $pattern, string $string, string $message = '')

Asserts that a string does not match a given regular expression.

static 
assertSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')

Assert that the size of two arrays (or Countable or Traversable objects) is the same.

static 
assertNotSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')

Assert that the size of two arrays (or Countable or Traversable objects) is not the same.

static 
assertStringMatchesFormat(string $format, string $string, string $message = '')

Asserts that a string matches a given format string.

static 
assertStringNotMatchesFormat(string $format, string $string, string $message = '')

Asserts that a string does not match a given format string.

static 
assertStringMatchesFormatFile(string $formatFile, string $string, string $message = '')

Asserts that a string matches a given format file.

static 
assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = '')

Asserts that a string does not match a given format string.

static 
assertStringStartsWith(string $prefix, string $string, string $message = '')

Asserts that a string starts with a given prefix.

static 
assertStringStartsNotWith(string $prefix, string $string, string $message = '')

Asserts that a string starts not with a given prefix.

static 
assertStringEndsWith(string $suffix, string $string, string $message = '')

Asserts that a string ends with a given suffix.

static 
assertStringEndsNotWith(string $suffix, string $string, string $message = '')

Asserts that a string ends not with a given suffix.

static 
assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two XML files are equal.

static 
assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two XML files are not equal.

static 
assertXmlStringEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are equal.

static 
assertXmlStringNotEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are not equal.

static 
assertXmlStringEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are equal.

static 
assertXmlStringNotEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are not equal.

static 
assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = '')

Asserts that a hierarchy of DOMElements matches.

static 
assertThat(mixed $value, Constraint $constraint, string $message = '')

Evaluates a PHPUnit\Framework\Constraint matcher object.

static 
assertJson(string $actualJson, string $message = '')

Asserts that a string is a valid JSON string.

static 
assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')

Asserts that two given JSON encoded objects or arrays are equal.

static 
assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')

Asserts that two given JSON encoded objects or arrays are not equal.

static 
assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')

Asserts that the generated JSON encoded object and the content of the given file are equal.

static 
assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')

Asserts that the generated JSON encoded object and the content of the given file are not equal.

static 
assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two JSON files are equal.

static 
assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two JSON files are not equal.

static LogicalAnd
logicalAnd()

No description

static LogicalOr
logicalOr()

No description

static LogicalNot
logicalNot(Constraint $constraint)

No description

static LogicalXor
logicalXor()

No description

static IsAnything
anything()

No description

static IsTrue
isTrue()

No description

static Callback
callback(callable $callback)

No description

static IsFalse
isFalse()

No description

static IsJson
isJson()

No description

static IsNull
isNull()

No description

static IsFinite
isFinite()

No description

static IsInfinite
isInfinite()

No description

static IsNan
isNan()

No description

static Attribute
attribute(Constraint $constraint, string $attributeName)

No description

contains(mixed $value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

No description

containsOnly(string $type)

No description

containsOnlyInstancesOf(string $classname)

No description

static ArrayHasKey
arrayHasKey(mixed $key)

No description

static IsEqual
equalTo(mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

No description

static Attribute
attributeEqualTo(string $attributeName, mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

No description

static IsEmpty
isEmpty()

No description

static IsWritable
isWritable()

No description

static IsReadable
isReadable()

No description

static DirectoryExists
directoryExists()

No description

static FileExists
fileExists()

No description

static GreaterThan
greaterThan(mixed $value)

No description

static LogicalOr
greaterThanOrEqual(mixed $value)

No description

classHasAttribute(string $attributeName)

No description

classHasStaticAttribute(string $attributeName)

No description

objectHasAttribute(string $attributeName)

No description

static IsIdentical
identicalTo(mixed $value)

No description

static IsInstanceOf
isInstanceOf(string $className)

No description

static IsType
isType(string $type)

No description

static LessThan
lessThan(mixed $value)

No description

static LogicalOr
lessThanOrEqual(mixed $value)

No description

matchesRegularExpression(string $pattern)

No description

matches(string $string)

No description

stringStartsWith(mixed $prefix)

No description

static StringContains
stringContains(string $string, bool $case = true)

No description

static StringEndsWith
stringEndsWith(mixed $suffix)

No description

static Count
countOf(int $count)

No description

static 
fail(string $message = '')

Fails a test with the given message.

static mixed
readAttribute(string|object $classOrObject, string $attributeName)

Returns the value of an attribute of a class or an object.

static mixed
getStaticAttribute(string $className, string $attributeName)

Returns the value of a static attribute.

static mixed
getObjectAttribute(object $object, string $attributeName)

Returns the value of an object's attribute.

static 
markTestIncomplete(string $message = '')

Mark the test as incomplete.

static 
markTestSkipped(string $message = '')

Mark the test as skipped.

static int
getCount()

Return the current assertion count.

static 
resetCount()

Reset the assertion counter.

Details

static assertArrayHasKey(mixed $key, array|ArrayAccess $array, string $message = '')

Asserts that an array has a specified key.

Parameters

mixed $key
array|ArrayAccess $array
string $message

static assertArraySubset(array|ArrayAccess $subset, array|ArrayAccess $array, bool $strict = false, string $message = '')

Asserts that an array has a specified subset.

Parameters

array|ArrayAccess $subset
array|ArrayAccess $array
bool $strict Check for object identity
string $message

static assertArrayNotHasKey(mixed $key, array|ArrayAccess $array, string $message = '')

Asserts that an array does not have a specified key.

Parameters

mixed $key
array|ArrayAccess $array
string $message

static assertContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack contains a needle.

Parameters

mixed $needle
mixed $haystack
string $message
bool $ignoreCase
bool $checkForObjectIdentity
bool $checkForNonObjectIdentity

static assertAttributeContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.

Parameters

mixed $needle
string $haystackAttributeName
string|object $haystackClassOrObject
string $message
bool $ignoreCase
bool $checkForObjectIdentity
bool $checkForNonObjectIdentity

static assertNotContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack does not contain a needle.

Parameters

mixed $needle
mixed $haystack
string $message
bool $ignoreCase
bool $checkForObjectIdentity
bool $checkForNonObjectIdentity

static assertAttributeNotContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.

Parameters

mixed $needle
string $haystackAttributeName
string|object $haystackClassOrObject
string $message
bool $ignoreCase
bool $checkForObjectIdentity
bool $checkForNonObjectIdentity

static assertContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')

Asserts that a haystack contains only values of a given type.

Parameters

string $type
mixed $haystack
bool $isNativeType
string $message

static assertContainsOnlyInstancesOf(string $classname, array|Traversable $haystack, string $message = '')

Asserts that a haystack contains only instances of a given classname

Parameters

string $classname
array|Traversable $haystack
string $message

static assertAttributeContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.

Parameters

string $type
string $haystackAttributeName
string|object $haystackClassOrObject
bool $isNativeType
string $message

static assertNotContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')

Asserts that a haystack does not contain only values of a given type.

Parameters

string $type
mixed $haystack
bool $isNativeType
string $message

static assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')

Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.

Parameters

string $type
string $haystackAttributeName
string|object $haystackClassOrObject
bool $isNativeType
string $message

static assertCount(int $expectedCount, mixed $haystack, string $message = '')

Asserts the number of elements of an array, Countable or Traversable.

Parameters

int $expectedCount
mixed $haystack
string $message

static assertAttributeCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

Parameters

int $expectedCount
string $haystackAttributeName
string|object $haystackClassOrObject
string $message

static assertNotCount(int $expectedCount, mixed $haystack, string $message = '')

Asserts the number of elements of an array, Countable or Traversable.

Parameters

int $expectedCount
mixed $haystack
string $message

static assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

Parameters

int $expectedCount
string $haystackAttributeName
string|object $haystackClassOrObject
string $message

static assertEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that two variables are equal.

Parameters

mixed $expected
mixed $actual
string $message
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

static assertAttributeEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that a variable is equal to an attribute of an object.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

static assertNotEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that two variables are not equal.

Parameters

mixed $expected
mixed $actual
string $message
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

static assertAttributeNotEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Asserts that a variable is not equal to an attribute of an object.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

static assertEmpty(mixed $actual, string $message = '')

Asserts that a variable is empty.

Parameters

mixed $actual
string $message

Exceptions

AssertionFailedError

static assertAttributeEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts that a static attribute of a class or an attribute of an object is empty.

Parameters

string $haystackAttributeName
string|object $haystackClassOrObject
string $message

static assertNotEmpty(mixed $actual, string $message = '')

Asserts that a variable is not empty.

Parameters

mixed $actual
string $message

Exceptions

AssertionFailedError

static assertAttributeNotEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')

Asserts that a static attribute of a class or an attribute of an object is not empty.

Parameters

string $haystackAttributeName
string|object $haystackClassOrObject
string $message

static assertGreaterThan(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is greater than another value.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeGreaterThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is greater than another value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is greater than or equal to another value.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeGreaterThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is greater than or equal to another value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertLessThan(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is smaller than another value.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeLessThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is smaller than another value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = '')

Asserts that a value is smaller than or equal to another value.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeLessThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that an attribute is smaller than or equal to another value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of one file is equal to the contents of another file.

Parameters

string $expected
string $actual
string $message
bool $canonicalize
bool $ignoreCase

static assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of one file is not equal to the contents of another file.

Parameters

string $expected
string $actual
string $message
bool $canonicalize
bool $ignoreCase

static assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of a string is equal to the contents of a file.

Parameters

string $expectedFile
string $actualString
string $message
bool $canonicalize
bool $ignoreCase

static assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)

Asserts that the contents of a string is not equal to the contents of a file.

Parameters

string $expectedFile
string $actualString
string $message
bool $canonicalize
bool $ignoreCase

static assertIsReadable(string $filename, string $message = '')

Asserts that a file/dir is readable.

Parameters

string $filename
string $message

static assertNotIsReadable(string $filename, string $message = '')

Asserts that a file/dir exists and is not readable.

Parameters

string $filename
string $message

static assertIsWritable(string $filename, string $message = '')

Asserts that a file/dir exists and is writable.

Parameters

string $filename
string $message

static assertNotIsWritable(string $filename, string $message = '')

Asserts that a file/dir exists and is not writable.

Parameters

string $filename
string $message

static assertDirectoryExists(string $directory, string $message = '')

Asserts that a directory exists.

Parameters

string $directory
string $message

static assertDirectoryNotExists(string $directory, string $message = '')

Asserts that a directory does not exist.

Parameters

string $directory
string $message

static assertDirectoryIsReadable(string $directory, string $message = '')

Asserts that a directory exists and is readable.

Parameters

string $directory
string $message

static assertDirectoryNotIsReadable(string $directory, string $message = '')

Asserts that a directory exists and is not readable.

Parameters

string $directory
string $message

static assertDirectoryIsWritable(string $directory, string $message = '')

Asserts that a directory exists and is writable.

Parameters

string $directory
string $message

static assertDirectoryNotIsWritable(string $directory, string $message = '')

Asserts that a directory exists and is not writable.

Parameters

string $directory
string $message

static assertFileExists(string $filename, string $message = '')

Asserts that a file exists.

Parameters

string $filename
string $message

static assertFileNotExists(string $filename, string $message = '')

Asserts that a file does not exist.

Parameters

string $filename
string $message

static assertFileIsReadable(string $file, string $message = '')

Asserts that a file exists and is readable.

Parameters

string $file
string $message

static assertFileNotIsReadable(string $file, string $message = '')

Asserts that a file exists and is not readable.

Parameters

string $file
string $message

static assertFileIsWritable(string $file, string $message = '')

Asserts that a file exists and is writable.

Parameters

string $file
string $message

static assertFileNotIsWritable(string $file, string $message = '')

Asserts that a file exists and is not writable.

Parameters

string $file
string $message

static assertTrue(bool $condition, string $message = '')

Asserts that a condition is true.

Parameters

bool $condition
string $message

Exceptions

AssertionFailedError

static assertNotTrue(bool $condition, string $message = '')

Asserts that a condition is not true.

Parameters

bool $condition
string $message

Exceptions

AssertionFailedError

static assertFalse(bool $condition, string $message = '')

Asserts that a condition is false.

Parameters

bool $condition
string $message

Exceptions

AssertionFailedError

static assertNotFalse(bool $condition, string $message = '')

Asserts that a condition is not false.

Parameters

bool $condition
string $message

Exceptions

AssertionFailedError

static assertNull(mixed $actual, string $message = '')

Asserts that a variable is null.

Parameters

mixed $actual
string $message

static assertNotNull(mixed $actual, string $message = '')

Asserts that a variable is not null.

Parameters

mixed $actual
string $message

static assertFinite(mixed $actual, string $message = '')

Asserts that a variable is finite.

Parameters

mixed $actual
string $message

static assertInfinite(mixed $actual, string $message = '')

Asserts that a variable is infinite.

Parameters

mixed $actual
string $message

static assertNan(mixed $actual, string $message = '')

Asserts that a variable is nan.

Parameters

mixed $actual
string $message

static assertClassHasAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class has a specified attribute.

Parameters

string $attributeName
string $className
string $message

static assertClassNotHasAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class does not have a specified attribute.

Parameters

string $attributeName
string $className
string $message

static assertClassHasStaticAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class has a specified static attribute.

Parameters

string $attributeName
string $className
string $message

static assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = '')

Asserts that a class does not have a specified static attribute.

Parameters

string $attributeName
string $className
string $message

static assertObjectHasAttribute(string $attributeName, object $object, string $message = '')

Asserts that an object has a specified attribute.

Parameters

string $attributeName
object $object
string $message

static assertObjectNotHasAttribute(string $attributeName, object $object, string $message = '')

Asserts that an object does not have a specified attribute.

Parameters

string $attributeName
object $object
string $message

static assertSame(mixed $expected, mixed $actual, string $message = '')

Asserts that two variables have the same type and value.

Used on objects, it asserts that two variables reference the same object.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that a variable and an attribute of an object have the same type and value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertNotSame(mixed $expected, mixed $actual, string $message = '')

Asserts that two variables do not have the same type and value.

Used on objects, it asserts that two variables do not reference the same object.

Parameters

mixed $expected
mixed $actual
string $message

static assertAttributeNotSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')

Asserts that a variable and an attribute of an object do not have the same type and value.

Parameters

mixed $expected
string $actualAttributeName
string|object $actualClassOrObject
string $message

static assertInstanceOf(string $expected, mixed $actual, string $message = '')

Asserts that a variable is of a given type.

Parameters

string $expected
mixed $actual
string $message

static assertAttributeInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

Parameters

string $expected
string $attributeName
string|object $classOrObject
string $message

static assertNotInstanceOf(string $expected, mixed $actual, string $message = '')

Asserts that a variable is not of a given type.

Parameters

string $expected
mixed $actual
string $message

static assertAttributeNotInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

Parameters

string $expected
string $attributeName
string|object $classOrObject
string $message

static assertInternalType(string $expected, mixed $actual, string $message = '')

Asserts that a variable is of a given type.

Parameters

string $expected
mixed $actual
string $message

static assertAttributeInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

Parameters

string $expected
string $attributeName
string|object $classOrObject
string $message

static assertNotInternalType(string $expected, mixed $actual, string $message = '')

Asserts that a variable is not of a given type.

Parameters

string $expected
mixed $actual
string $message

static assertAttributeNotInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')

Asserts that an attribute is of a given type.

Parameters

string $expected
string $attributeName
string|object $classOrObject
string $message

static assertRegExp(string $pattern, string $string, string $message = '')

Asserts that a string matches a given regular expression.

Parameters

string $pattern
string $string
string $message

static assertNotRegExp(string $pattern, string $string, string $message = '')

Asserts that a string does not match a given regular expression.

Parameters

string $pattern
string $string
string $message

static assertSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')

Assert that the size of two arrays (or Countable or Traversable objects) is the same.

Parameters

array|Countable|Traversable $expected
array|Countable|Traversable $actual
string $message

static assertNotSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')

Assert that the size of two arrays (or Countable or Traversable objects) is not the same.

Parameters

array|Countable|Traversable $expected
array|Countable|Traversable $actual
string $message

static assertStringMatchesFormat(string $format, string $string, string $message = '')

Asserts that a string matches a given format string.

Parameters

string $format
string $string
string $message

static assertStringNotMatchesFormat(string $format, string $string, string $message = '')

Asserts that a string does not match a given format string.

Parameters

string $format
string $string
string $message

static assertStringMatchesFormatFile(string $formatFile, string $string, string $message = '')

Asserts that a string matches a given format file.

Parameters

string $formatFile
string $string
string $message

static assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = '')

Asserts that a string does not match a given format string.

Parameters

string $formatFile
string $string
string $message

static assertStringStartsWith(string $prefix, string $string, string $message = '')

Asserts that a string starts with a given prefix.

Parameters

string $prefix
string $string
string $message

static assertStringStartsNotWith(string $prefix, string $string, string $message = '')

Asserts that a string starts not with a given prefix.

Parameters

string $prefix
string $string
string $message

static assertStringEndsWith(string $suffix, string $string, string $message = '')

Asserts that a string ends with a given suffix.

Parameters

string $suffix
string $string
string $message

static assertStringEndsNotWith(string $suffix, string $string, string $message = '')

Asserts that a string ends not with a given suffix.

Parameters

string $suffix
string $string
string $message

static assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two XML files are equal.

Parameters

string $expectedFile
string $actualFile
string $message

static assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two XML files are not equal.

Parameters

string $expectedFile
string $actualFile
string $message

static assertXmlStringEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are equal.

Parameters

string $expectedFile
string|DOMDocument $actualXml
string $message

static assertXmlStringNotEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are not equal.

Parameters

string $expectedFile
string|DOMDocument $actualXml
string $message

static assertXmlStringEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are equal.

Parameters

string|DOMDocument $expectedXml
string|DOMDocument $actualXml
string $message

static assertXmlStringNotEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')

Asserts that two XML documents are not equal.

Parameters

string|DOMDocument $expectedXml
string|DOMDocument $actualXml
string $message

static assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = '')

Asserts that a hierarchy of DOMElements matches.

Parameters

DOMElement $expectedElement
DOMElement $actualElement
bool $checkAttributes
string $message

static assertThat(mixed $value, Constraint $constraint, string $message = '')

Evaluates a PHPUnit\Framework\Constraint matcher object.

Parameters

mixed $value
Constraint $constraint
string $message

static assertJson(string $actualJson, string $message = '')

Asserts that a string is a valid JSON string.

Parameters

string $actualJson
string $message

static assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')

Asserts that two given JSON encoded objects or arrays are equal.

Parameters

string $expectedJson
string $actualJson
string $message

static assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')

Asserts that two given JSON encoded objects or arrays are not equal.

Parameters

string $expectedJson
string $actualJson
string $message

static assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')

Asserts that the generated JSON encoded object and the content of the given file are equal.

Parameters

string $expectedFile
string $actualJson
string $message

static assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')

Asserts that the generated JSON encoded object and the content of the given file are not equal.

Parameters

string $expectedFile
string $actualJson
string $message

static assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two JSON files are equal.

Parameters

string $expectedFile
string $actualFile
string $message

static assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')

Asserts that two JSON files are not equal.

Parameters

string $expectedFile
string $actualFile
string $message

static LogicalAnd logicalAnd()

Return Value

LogicalAnd

static LogicalOr logicalOr()

Return Value

LogicalOr

static LogicalNot logicalNot(Constraint $constraint)

Parameters

Constraint $constraint

Return Value

LogicalNot

static LogicalXor logicalXor()

Return Value

LogicalXor

static IsAnything anything()

Return Value

IsAnything

static IsTrue isTrue()

Return Value

IsTrue

static Callback callback(callable $callback)

Parameters

callable $callback

Return Value

Callback

static IsFalse isFalse()

Return Value

IsFalse

static IsJson isJson()

Return Value

IsJson

static IsNull isNull()

Return Value

IsNull

static IsFinite isFinite()

Return Value

IsFinite

static IsInfinite isInfinite()

Return Value

IsInfinite

static IsNan isNan()

Return Value

IsNan

static Attribute attribute(Constraint $constraint, string $attributeName)

Parameters

Constraint $constraint
string $attributeName

Return Value

Attribute

static TraversableContains contains(mixed $value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)

Parameters

mixed $value
bool $checkForObjectIdentity
bool $checkForNonObjectIdentity

Return Value

TraversableContains

static TraversableContainsOnly containsOnly(string $type)

Parameters

string $type

Return Value

TraversableContainsOnly

static TraversableContainsOnly containsOnlyInstancesOf(string $classname)

Parameters

string $classname

Return Value

TraversableContainsOnly

static ArrayHasKey arrayHasKey(mixed $key)

Parameters

mixed $key

Return Value

ArrayHasKey

static IsEqual equalTo(mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Parameters

mixed $value
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

Return Value

IsEqual

static Attribute attributeEqualTo(string $attributeName, mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)

Parameters

string $attributeName
mixed $value
float $delta
int $maxDepth
bool $canonicalize
bool $ignoreCase

Return Value

Attribute

static IsEmpty isEmpty()

Return Value

IsEmpty

static IsWritable isWritable()

Return Value

IsWritable

static IsReadable isReadable()

Return Value

IsReadable

static DirectoryExists directoryExists()

Return Value

DirectoryExists

static FileExists fileExists()

Return Value

FileExists

static GreaterThan greaterThan(mixed $value)

Parameters

mixed $value

Return Value

GreaterThan

static LogicalOr greaterThanOrEqual(mixed $value)

Parameters

mixed $value

Return Value

LogicalOr

static ClassHasAttribute classHasAttribute(string $attributeName)

Parameters

string $attributeName

Return Value

ClassHasAttribute

static ClassHasStaticAttribute classHasStaticAttribute(string $attributeName)

Parameters

string $attributeName

Return Value

ClassHasStaticAttribute

static ObjectHasAttribute objectHasAttribute(string $attributeName)

Parameters

string $attributeName

Return Value

ObjectHasAttribute

static IsIdentical identicalTo(mixed $value)

Parameters

mixed $value

Return Value

IsIdentical

static IsInstanceOf isInstanceOf(string $className)

Parameters

string $className

Return Value

IsInstanceOf

static IsType isType(string $type)

Parameters

string $type

Return Value

IsType

static LessThan lessThan(mixed $value)

Parameters

mixed $value

Return Value

LessThan

static LogicalOr lessThanOrEqual(mixed $value)

Parameters

mixed $value

Return Value

LogicalOr

static RegularExpression matchesRegularExpression(string $pattern)

Parameters

string $pattern

Return Value

RegularExpression

static StringMatchesFormatDescription matches(string $string)

Parameters

string $string

Return Value

StringMatchesFormatDescription

static StringStartsWith stringStartsWith(mixed $prefix)

Parameters

mixed $prefix

Return Value

StringStartsWith

static StringContains stringContains(string $string, bool $case = true)

Parameters

string $string
bool $case

Return Value

StringContains

static StringEndsWith stringEndsWith(mixed $suffix)

Parameters

mixed $suffix

Return Value

StringEndsWith

static Count countOf(int $count)

Parameters

int $count

Return Value

Count

static fail(string $message = '')

Fails a test with the given message.

Parameters

string $message

Exceptions

AssertionFailedError

static mixed readAttribute(string|object $classOrObject, string $attributeName)

Returns the value of an attribute of a class or an object.

This also works for attributes that are declared protected or private.

Parameters

string|object $classOrObject
string $attributeName

Return Value

mixed

Exceptions

Exception

static mixed getStaticAttribute(string $className, string $attributeName)

Returns the value of a static attribute.

This also works for attributes that are declared protected or private.

Parameters

string $className
string $attributeName

Return Value

mixed

Exceptions

Exception

static mixed getObjectAttribute(object $object, string $attributeName)

Returns the value of an object's attribute.

This also works for attributes that are declared protected or private.

Parameters

object $object
string $attributeName

Return Value

mixed

Exceptions

Exception

static markTestIncomplete(string $message = '')

Mark the test as incomplete.

Parameters

string $message

Exceptions

IncompleteTestError

static markTestSkipped(string $message = '')

Mark the test as skipped.

Parameters

string $message

Exceptions

SkippedTestError

static int getCount()

Return the current assertion count.

Return Value

int

static resetCount()

Reset the assertion counter.