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() {

@runTestsInSeparateProcesses

@runTestsInSeparateProcesses Indicates that all tests in a test class should be run in a separate PHP process. use PHPUnit\Framework\TestCase; /** * @runTestsInSeparateProcesses */ class MyTest extends TestCase { // ... } Note: By default, PHPUnit will attempt to preserve the global state from the parent process by serializing all globals in the parent process and unserializing them in the child process. This can cause problems if the parent process contains globals that are not seri

assertFileEquals()

assertFileEquals() assertFileEquals(string $expected, string $actual[, string $message = '']) Reports an error identified by $message if the file specified by $expected does not have the same contents as the file specified by $actual. assertFileNotEquals() is the inverse of this assertion and takes the same arguments. Example A.22: Usage of assertFileEquals() <?php use PHPUnit\Framework\TestCase; class FileEqualsTest extends TestCase { public function testFailure() { $this

@testdox

@testdox

assertGreaterThanOrEqual()

assertGreaterThanOrEqual() assertGreaterThanOrEqual(mixed $expected, mixed $actual[, string $message = '']) Reports an error identified by $message if the value of $actual is not greater than or equal to the value of $expected. assertAttributeGreaterThanOrEqual() is a convenience wrapper that uses a public, protected, or private attribute of a class or object as the actual value. Example A.27: Usage of assertGreaterThanOrEqual() <?php use PHPUnit\Framework\TestCase; class GreatThanOrEqual

assertIsReadable()

assertIsReadable() assertIsReadable(string $filename[, string $message = '']) Reports an error identified by $message if the file or directory specified by $filename is not readable. assertNotIsReadable() is the inverse of this assertion and takes the same arguments. Example A.31: Usage of assertIsReadable() <?php use PHPUnit\Framework\TestCase; class IsReadableTest extends TestCase { public function testFailure() { $this->assertIsReadable('/path/to/unreadable'); }

assertStringMatchesFormatFile()

assertStringMatchesFormatFile() assertStringMatchesFormatFile(string $formatFile, string $string[, string $message = '']) Reports an error identified by $message if the $string does not match the contents of the $formatFile. assertStringNotMatchesFormatFile() is the inverse of this assertion and takes the same arguments. Example A.43: Usage of assertStringMatchesFormatFile() <?php use PHPUnit\Framework\TestCase; class StringMatchesFormatFileTest extends TestCase { public function test

@coversNothing

@coversNothing The @coversNothing annotation can be used in the test code to specify that no code coverage information will be recorded for the annotated test case. This can be used for integration testing. See Example 11.3 for an example. The annotation can be used on the class and the method level and will override any @covers tags.

Installing PHPUnit

Requirements PHPUnit 5.6 requires PHP 5.6; using the latest version of PHP is highly recommended. PHPUnit requires the dom and json extensions, which are normally enabled by default. PHPUnit also requires the pcre, reflection, and spl extensions. These standard extensions are enabled by default and cannot be disabled without patching PHP's build system and/or C sources. The code coverage report feature requires the Xdebug (2.2.1 or later) and tokenizer extensions. Generating XML reports

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