assertFileIsReadable()

assertFileIsReadable() assertFileIsReadable(string $filename[, string $message = '']) Reports an error identified by $message if the file specified by $filename is not a file or is not readable. assertFileNotIsReadable() is the inverse of this assertion and takes the same arguments. Example A.24: Usage of assertFileIsReadable() <?php use PHPUnit\Framework\TestCase; class FileIsReadableTest extends TestCase { public function testFailure() { $this->assertFileIsReadable('/

@afterClass

@afterClass The @afterClass annotation can be used to specify static methods that should be called after all test methods in a test class have been run to clean up shared fixtures. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @afterClass */ public static function tearDownSomeSharedFixtures() { // ... } /** * @afterClass */ public static function tearDownSomeOtherSharedFixtures() { // ... } }

@expectedExceptionMessage

@expectedExceptionMessage The @expectedExceptionMessage annotation works similar to @expectedExceptionCode as it lets you make an assertion on the error message of an exception. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @expectedException MyException * @expectedExceptionMessage Some Message */ public function testExceptionHasRightMessage() { throw new MyException('Some Message', 20); } } The expected message can be a

assertStringMatchesFormat()

assertStringMatchesFormat() assertStringMatchesFormat(string $format, string $string[, string $message = '']) Reports an error identified by $message if the $string does not match the $format string. assertStringNotMatchesFormat() is the inverse of this assertion and takes the same arguments. Example A.42: Usage of assertStringMatchesFormat() <?php use PHPUnit\Framework\TestCase; class StringMatchesFormatTest extends TestCase { public function testFailure() { $this->ass

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

assertFileIsWritable()

assertFileIsWritable() assertFileIsWritable(string $filename[, string $message = '']) Reports an error identified by $message if the file specified by $filename is not a file or is not writable. assertFileNotIsWritable() is the inverse of this assertion and takes the same arguments. Example A.25: Usage of assertFileIsWritable() <?php use PHPUnit\Framework\TestCase; class FileIsWritableTest extends TestCase { public function testFailure() { $this->assertFileIsWritable('/

assertStringEndsWith()

assertStringEndsWith() assertStringEndsWith(string $suffix, string $string[, string $message = '']) Reports an error identified by $message if the $string does not end with $suffix. assertStringEndsNotWith() is the inverse of this assertion and takes the same arguments. Example A.46: Usage of assertStringEndsWith() <?php use PHPUnit\Framework\TestCase; class StringEndsWithTest extends TestCase { public function testFailure() { $this->assertStringEndsWith('suffix', 'foo'

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

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

assertNull()

assertNull() assertNull(mixed $variable[, string $message = '']) Reports an error identified by $message if $variable is not null. assertNotNull() is the inverse of this assertion and takes the same arguments. Example A.39: Usage of assertNull() <?php use PHPUnit\Framework\TestCase; class NullTest extends TestCase { public function testFailure() { $this->assertNull('foo'); } } ?> phpunit NotNullTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: