Assert

A set of assertion methods.

Known subclasses

PHPUnit\Framework\TestCase, Sunrise\Collection\Tests\CollectionTest, Sunrise\Slugger\Tests\SluggerTest, Sunrise\Stream\Tests\StreamTest, Sunrise\Uri\Tests\UriTest, Sunrise\Vin\Tests\VinTest
Abstract
Open source code
Methods Summary
public static
# assertArrayHasKey( int|string $key , array|\ArrayAccess $array , string $message = '' )
Asserts that an array has a specified key.
public static
# assertArraySubset( array|\ArrayAccess $subset , array|\ArrayAccess $array , bool $checkForObjectIdentity = false, string $message = '' )
Asserts that an array has a specified subset.
public static
# assertArrayNotHasKey( int|string $key , array|\ArrayAccess $array , string $message = '' )
Asserts that an array does not have a specified key.
public static
# assertContains( $needle , $haystack , string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false )
Asserts that a haystack contains a needle.
public static
# assertAttributeContains( object|string $needle , string $haystackAttributeName , $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.

Deprecated


public static
# assertNotContains( $needle , $haystack , string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false )
Asserts that a haystack does not contain a needle.
public static
# assertAttributeNotContains( object|string $needle , string $haystackAttributeName , $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.

Deprecated


public static
# assertContainsOnly( string $type , iterable $haystack , bool $isNativeType = NULL, string $message = '' )
Asserts that a haystack contains only values of a given type.
public static
# assertContainsOnlyInstancesOf( string $className , iterable $haystack , string $message = '' )
Asserts that a haystack contains only instances of a given class name.
public static
# assertAttributeContainsOnly( string $type , string $haystackAttributeName , $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.

Deprecated


public static
# assertNotContainsOnly( string $type , iterable $haystack , bool $isNativeType = NULL, string $message = '' )
Asserts that a haystack does not contain only values of a given type.
public static
# assertAttributeNotContainsOnly( string $type , string $haystackAttributeName , $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.

Deprecated


public static
# assertCount( int $expectedCount , $haystack , string $message = '' )
Asserts the number of elements of an array, Countable or Traversable.
public static
# assertAttributeCount( int $expectedCount , string $haystackAttributeName , $haystackClassOrObject , string $message = '' )
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

Deprecated


public static
# assertNotCount( int $expectedCount , $haystack , string $message = '' )
Asserts the number of elements of an array, Countable or Traversable.
public static
# assertAttributeNotCount( int $expectedCount , string $haystackAttributeName , $haystackClassOrObject , string $message = '' )
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.

Deprecated


public static
# assertEquals( $expected , $actual , string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false )
Asserts that two variables are equal.
public static
# assertEqualsCanonicalizing( $expected , $actual , string $message = '' )
Asserts that two variables are equal (canonicalizing).
public static
# assertEqualsIgnoringCase( $expected , $actual , string $message = '' )
Asserts that two variables are equal (ignoring case).
public static
# assertEqualsWithDelta( $expected , $actual , float $delta , string $message = '' )
Asserts that two variables are equal (with delta).
public static
# assertAttributeEquals( object|string $expected , string $actualAttributeName , $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.

Deprecated


public static
# assertNotEquals( float $expected , int $actual , string $message = '', bool $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false )
Asserts that two variables are not equal.
public static
# assertNotEqualsCanonicalizing( $expected , $actual , string $message = '' )
Asserts that two variables are not equal (canonicalizing).
public static
# assertNotEqualsIgnoringCase( $expected , $actual , string $message = '' )
Asserts that two variables are not equal (ignoring case).
public static
# assertNotEqualsWithDelta( $expected , $actual , float $delta , string $message = '' )
Asserts that two variables are not equal (with delta).
public static
# assertAttributeNotEquals( object|string $expected , string $actualAttributeName , $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.

Deprecated


public static
# assertEmpty( $actual , string $message = '' )
Asserts that a variable is empty.
public static
# assertAttributeEmpty( string $haystackAttributeName , $haystackClassOrObject , string $message = '' )
Asserts that a static attribute of a class or an attribute of an object is empty.

Deprecated


public static
# assertNotEmpty( $actual , string $message = '' )
Asserts that a variable is not empty.
public static
# assertAttributeNotEmpty( string $haystackAttributeName , $haystackClassOrObject , string $message = '' )
Asserts that a static attribute of a class or an attribute of an object is not empty.

Deprecated


public static
# assertGreaterThan( $expected , $actual , string $message = '' )
Asserts that a value is greater than another value.
public static
# assertAttributeGreaterThan( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that an attribute is greater than another value.

Deprecated


public static
# assertGreaterThanOrEqual( $expected , $actual , string $message = '' )
Asserts that a value is greater than or equal to another value.
public static
# assertAttributeGreaterThanOrEqual( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that an attribute is greater than or equal to another value.

Deprecated


public static
# assertLessThan( $expected , $actual , string $message = '' )
Asserts that a value is smaller than another value.
public static
# assertAttributeLessThan( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that an attribute is smaller than another value.

Deprecated


public static
# assertLessThanOrEqual( $expected , $actual , string $message = '' )
Asserts that a value is smaller than or equal to another value.
public static
# assertAttributeLessThanOrEqual( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that an attribute is smaller than or equal to another value.

Deprecated


public 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.
public 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.
public 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.
public 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.
public static
# assertIsReadable( string $filename , string $message = '' )
Asserts that a file/dir is readable.
public static
# assertNotIsReadable( string $filename , string $message = '' )
Asserts that a file/dir exists and is not readable.
public static
# assertIsWritable( string $filename , string $message = '' )
Asserts that a file/dir exists and is writable.
public static
# assertNotIsWritable( string $filename , string $message = '' )
Asserts that a file/dir exists and is not writable.
public static
# assertDirectoryExists( string $directory , string $message = '' )
Asserts that a directory exists.
public static
# assertDirectoryNotExists( string $directory , string $message = '' )
Asserts that a directory does not exist.
public static
# assertDirectoryIsReadable( string $directory , string $message = '' )
Asserts that a directory exists and is readable.
public static
# assertDirectoryNotIsReadable( string $directory , string $message = '' )
Asserts that a directory exists and is not readable.
public static
# assertDirectoryIsWritable( string $directory , string $message = '' )
Asserts that a directory exists and is writable.
public static
# assertDirectoryNotIsWritable( string $directory , string $message = '' )
Asserts that a directory exists and is not writable.
public static
# assertFileExists( string $filename , string $message = '' )
Asserts that a file exists.
public static
# assertFileNotExists( string $filename , string $message = '' )
Asserts that a file does not exist.
public static
# assertFileIsReadable( string $file , string $message = '' )
Asserts that a file exists and is readable.
public static
# assertFileNotIsReadable( string $file , string $message = '' )
Asserts that a file exists and is not readable.
public static
# assertFileIsWritable( string $file , string $message = '' )
Asserts that a file exists and is writable.
public static
# assertFileNotIsWritable( string $file , string $message = '' )
Asserts that a file exists and is not writable.
public static
# assertTrue( $condition , string $message = '' )
Asserts that a condition is true.
public static
# assertNotTrue( $condition , string $message = '' )
Asserts that a condition is not true.
public static
# assertFalse( $condition , string $message = '' )
Asserts that a condition is false.
public static
# assertNotFalse( $condition , string $message = '' )
Asserts that a condition is not false.
public static
# assertNull( $actual , string $message = '' )
Asserts that a variable is null.
public static
# assertNotNull( $actual , string $message = '' )
Asserts that a variable is not null.
public static
# assertFinite( $actual , string $message = '' )
Asserts that a variable is finite.
public static
# assertInfinite( $actual , string $message = '' )
Asserts that a variable is infinite.
public static
# assertNan( $actual , string $message = '' )
Asserts that a variable is nan.
public static
# assertClassHasAttribute( string $attributeName , string $className , string $message = '' )
Asserts that a class has a specified attribute.
public static
# assertClassNotHasAttribute( string $attributeName , string $className , string $message = '' )
Asserts that a class does not have a specified attribute.
public static
# assertClassHasStaticAttribute( string $attributeName , string $className , string $message = '' )
Asserts that a class has a specified static attribute.
public static
# assertClassNotHasStaticAttribute( string $attributeName , string $className , string $message = '' )
Asserts that a class does not have a specified static attribute.
public static
# assertObjectHasAttribute( string $attributeName , $object , string $message = '' )
Asserts that an object has a specified attribute.
public static
# assertObjectNotHasAttribute( string $attributeName , $object , string $message = '' )
Asserts that an object does not have a specified attribute.
public static
# assertSame( $expected , $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.
public static
# assertAttributeSame( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that a variable and an attribute of an object have the same type and value.

Deprecated


public static
# assertNotSame( $expected , $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.
public static
# assertAttributeNotSame( object|string $expected , string $actualAttributeName , $actualClassOrObject , string $message = '' )
Asserts that a variable and an attribute of an object do not have the same type and value.

Deprecated


public static
# assertInstanceOf( string $expected , $actual , string $message = '' )
Asserts that a variable is of a given type.
public static
# assertAttributeInstanceOf( string $expected , string $attributeName , $classOrObject , string $message = '' )
Asserts that an attribute is of a given type.

Deprecated


public static
# assertNotInstanceOf( string $expected , $actual , string $message = '' )
Asserts that a variable is not of a given type.
public static
# assertAttributeNotInstanceOf( string $expected , string $attributeName , $classOrObject , string $message = '' )
Asserts that an attribute is of a given type.

Deprecated


public static
# assertInternalType( string $expected , $actual , string $message = '' )
Asserts that a variable is of a given type.
public static
# assertAttributeInternalType( string $expected , string $attributeName , $classOrObject , string $message = '' )
Asserts that an attribute is of a given type.

Deprecated


public static
# assertNotInternalType( string $expected , $actual , string $message = '' )
Asserts that a variable is not of a given type.
public static
# assertAttributeNotInternalType( string $expected , string $attributeName , $classOrObject , string $message = '' )
Asserts that an attribute is of a given type.

Deprecated


public static
# assertRegExp( string $pattern , string $string , string $message = '' )
Asserts that a string matches a given regular expression.
public static
# assertNotRegExp( string $pattern , string $string , string $message = '' )
Asserts that a string does not match a given regular expression.
public static
# assertSameSize( \Countable|iterable $expected , \Countable|iterable $actual , string $message = '' )
Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
public static
# assertNotSameSize( \Countable|iterable $expected , \Countable|iterable $actual , string $message = '' )
Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
public static
# assertStringMatchesFormat( string $format , string $string , string $message = '' )
Asserts that a string matches a given format string.
public static
# assertStringNotMatchesFormat( string $format , string $string , string $message = '' )
Asserts that a string does not match a given format string.
public static
# assertStringMatchesFormatFile( string $formatFile , string $string , string $message = '' )
Asserts that a string matches a given format file.
public static
# assertStringNotMatchesFormatFile( string $formatFile , string $string , string $message = '' )
Asserts that a string does not match a given format string.
public static
# assertStringStartsWith( string $prefix , string $string , string $message = '' )
Asserts that a string starts with a given prefix.
public static
# assertStringStartsNotWith( string $prefix , string $string , string $message = '' )
Asserts that a string starts not with a given prefix.
public static
# assertStringEndsWith( string $suffix , string $string , string $message = '' )
Asserts that a string ends with a given suffix.
public static
# assertStringEndsNotWith( string $suffix , string $string , string $message = '' )
Asserts that a string ends not with a given suffix.
public static
# assertXmlFileEqualsXmlFile( string $expectedFile , string $actualFile , string $message = '' )
Asserts that two XML files are equal.
public static
# assertXmlFileNotEqualsXmlFile( string $expectedFile , string $actualFile , string $message = '' )
Asserts that two XML files are not equal.
public static
# assertXmlStringEqualsXmlFile( string $expectedFile , $actualXml , string $message = '' )
Asserts that two XML documents are equal.
public static
# assertXmlStringNotEqualsXmlFile( string $expectedFile , $actualXml , string $message = '' )
Asserts that two XML documents are not equal.
public static
# assertXmlStringEqualsXmlString( \DOMDocument|string $expectedXml , \DOMDocument|string $actualXml , string $message = '' )
Asserts that two XML documents are equal.
public static
# assertXmlStringNotEqualsXmlString( \DOMDocument|string $expectedXml , \DOMDocument|string $actualXml , string $message = '' )
Asserts that two XML documents are not equal.
public static
# assertEqualXMLStructure( DOMElement $expectedElement , DOMElement $actualElement , bool $checkAttributes = false, string $message = '' )
Asserts that a hierarchy of DOMElements matches.
public static
# assertThat( $value , PHPUnit\Framework\Constraint\Constraint $constraint , string $message = '' )
Evaluates a PHPUnit\Framework\Constraint matcher object.
public static
# assertJson( string $actualJson , string $message = '' )
Asserts that a string is a valid JSON string.
public static
# assertJsonStringEqualsJsonString( string $expectedJson , string $actualJson , string $message = '' )
Asserts that two given JSON encoded objects or arrays are equal.
public static
# assertJsonStringNotEqualsJsonString( string $expectedJson , string $actualJson , string $message = '' )
Asserts that two given JSON encoded objects or arrays are not equal.
public static
# assertJsonStringEqualsJsonFile( string $expectedFile , string $actualJson , string $message = '' )
Asserts that the generated JSON encoded object and the content of the given file are equal.
public 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.
public static
# assertJsonFileEqualsJsonFile( string $expectedFile , string $actualFile , string $message = '' )
Asserts that two JSON files are equal.
public static
# assertJsonFileNotEqualsJsonFile( string $expectedFile , string $actualFile , string $message = '' )
Asserts that two JSON files are not equal.
public static
public static
public static
# logicalNot( PHPUnit\Framework\Constraint\Constraint $constraint )
public static
public static
# anything( )
public static
# isTrue( )
public static
# callback( callable $callback )
public static
# isFalse( )
public static
# isJson( )
public static
# isNull( )
public static
# isFinite( )
public static
public static
# isNan( )
public static
# attribute( PHPUnit\Framework\Constraint\Constraint $constraint , string $attributeName )

Deprecated


public static
# contains( $value , bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false )
public static
# containsOnly( string $type )
public static
# containsOnlyInstancesOf( string $className )
public static
# arrayHasKey( int|string $key )
public static
# equalTo( $value , float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false )
public static
# attributeEqualTo( string $attributeName , $value , float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false )

Deprecated


public static
# isEmpty( )
public static
public static
public static
public static
public static
# greaterThan( $value )
public static
# greaterThanOrEqual( $value )
public static
# classHasAttribute( string $attributeName )
public static
# classHasStaticAttribute( string $attributeName )
public static
# objectHasAttribute( $attributeName )
public static
# identicalTo( $value )
public static
# isInstanceOf( string $className )
public static
# isType( string $type )
public static
# lessThan( $value )
public static
# lessThanOrEqual( $value )
public static
# matchesRegularExpression( string $pattern )
public static
# matches( string $string )
public static
# stringStartsWith( $prefix )
public static
# stringContains( string $string , bool $case = true )
public static
# stringEndsWith( string $suffix )
public static
# countOf( int $count )
public static
# fail( string $message = '' )
Fails a test with the given message.
public static
# readAttribute( object|string $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.

Deprecated


public static
# getStaticAttribute( string $className , string $attributeName )
Returns the value of a static attribute. This also works for attributes that are declared protected or private.

Deprecated


public static
# getObjectAttribute( object $object , string $attributeName )
Returns the value of an object's attribute. This also works for attributes that are declared protected or private.

Deprecated


public static
# markTestIncomplete( string $message = '' )
Mark the test as incomplete.
public static
# markTestSkipped( string $message = '' )
Mark the test as skipped.
public static
# getCount( )
Return the current assertion count.
public static
# resetCount( )
Reset the assertion counter.