assertEmpty()

assertEmpty() assertEmpty(mixed $actual[, string $message = '']) Reports an error identified by $message if $actual is not empty. assertNotEmpty() is the inverse of this assertion and takes the same arguments. assertAttributeEmpty() and assertAttributeNotEmpty() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object. Example A.14: Usage of assertEmpty() <?php use PHPUnit\Framework\TestCase; class EmptyTest extends TestCase { publ

assertDirectoryIsReadable()

assertDirectoryIsReadable() assertDirectoryIsReadable(string $directory[, string $message = '']) Reports an error identified by $message if the directory specified by $directory is not a directory or is not readable. assertDirectoryNotIsReadable() is the inverse of this assertion and takes the same arguments. Example A.12: Usage of assertDirectoryIsReadable() <?php use PHPUnit\Framework\TestCase; class DirectoryIsReadableTest extends TestCase { public function testFailure() {

assertContainsOnlyInstancesOf()

assertContainsOnlyInstancesOf() assertContainsOnlyInstancesOf(string $classname, Traversable|array $haystack[, string $message = '']) Reports an error identified by $message if $haystack does not contain only instances of class $classname. Example A.9: Usage of assertContainsOnlyInstancesOf() <?php use PHPUnit\Framework\TestCase; class ContainsOnlyInstancesOfTest extends TestCase { public function testFailure() { $this->assertContainsOnlyInstancesOf( Foo::cl

assertContains()

assertContains() assertContains(mixed $needle, Iterator|array $haystack[, string $message = '']) Reports an error identified by $message if $needle is not an element of $haystack. assertNotContains() is the inverse of this assertion and takes the same arguments. assertAttributeContains() and assertAttributeNotContains() are convenience wrappers that use a public, protected, or private attribute of a class or object as the haystack. Example A.5: Usage of assertContains() <?php use PHPUnit\F

assertCount()

assertCount() assertCount($expectedCount, $haystack[, string $message = '']) Reports an error identified by $message if the number of elements in $haystack is not $expectedCount. assertNotCount() is the inverse of this assertion and takes the same arguments. Example A.10: Usage of assertCount() <?php use PHPUnit\Framework\TestCase; class CountTest extends TestCase { public function testFailure() { $this->assertCount(0, ['foo']); } } ?> phpunit CountTest PHPUnit 5

assertDirectoryExists()

assertDirectoryExists() assertDirectoryExists(string $directory[, string $message = '']) Reports an error identified by $message if the directory specified by $directory does not exist. assertDirectoryNotExists() is the inverse of this assertion and takes the same arguments. Example A.11: Usage of assertDirectoryExists() <?php use PHPUnit\Framework\TestCase; class DirectoryExistsTest extends TestCase { public function testFailure() { $this->assertDirectoryExists('/path/

assertContainsOnly()

assertContainsOnly() assertContainsOnly(string $type, Iterator|array $haystack[, boolean $isNativeType = null, string $message = '']) Reports an error identified by $message if $haystack does not contain only variables of type $type. $isNativeType is a flag used to indicate whether $type is a native PHP type or not. assertNotContainsOnly() is the inverse of this assertion and takes the same arguments. assertAttributeContainsOnly() and assertAttributeNotContainsOnly() are convenience wrappers th

assertArrayHasKey()

assertArrayHasKey() assertArrayHasKey(mixed $key, array $array[, string $message = '']) Reports an error identified by $message if $array does not have the $key. assertArrayNotHasKey() is the inverse of this assertion and takes the same arguments. Example A.1: Usage of assertArrayHasKey() <?php use PHPUnit\Framework\TestCase; class ArrayHasKeyTest extends TestCase { public function testFailure() { $this->assertArrayHasKey('foo', ['bar' => 'baz']); } } ?> phpun

assertClassHasStaticAttribute()

assertClassHasStaticAttribute() assertClassHasStaticAttribute(string $attributeName, string $className[, string $message = '']) Reports an error identified by $message if $className::attributeName does not exist. assertClassNotHasStaticAttribute() is the inverse of this assertion and takes the same arguments. Example A.4: Usage of assertClassHasStaticAttribute() <?php use PHPUnit\Framework\TestCase; class ClassHasStaticAttributeTest extends TestCase { public function testFailure()

assertClassHasAttribute()

assertClassHasAttribute() assertClassHasAttribute(string $attributeName, string $className[, string $message = '']) Reports an error identified by $message if $className::attributeName does not exist. assertClassNotHasAttribute() is the inverse of this assertion and takes the same arguments. Example A.2: Usage of assertClassHasAttribute() <?php use PHPUnit\Framework\TestCase; class ClassHasAttributeTest extends TestCase { public function testFailure() { $this->assertCla