@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.

Database Testing

Many beginner and intermediate unit testing examples in any programming language suggest that it is perfectly easy to test your application's logic with simple tests. For database-centric applications this is far away from the reality. Start using Wordpress, TYPO3 or Symfony with Doctrine or Propel, for example, and you will easily experience considerable problems with PHPUnit: just because the database is so tightly coupled to these libraries. Make sure you have the PHP extension pdo and da

@codeCoverageIgnore*

@codeCoverageIgnore* The @codeCoverageIgnore, @codeCoverageIgnoreStart and @codeCoverageIgnoreEnd annotations can be used to exclude lines of code from the coverage analysis. For usage see the section called “Ignoring Code Blocks”.

@ticket

@ticket

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'); }

@coversDefaultClass

@coversDefaultClass The @coversDefaultClass annotation can be used to specify a default namespace or class name. That way long names don't need to be repeated for every @covers annotation. See Example B.1. Example B.1: Using @coversDefaultClass to shorten annotations <?php use PHPUnit\Framework\TestCase; /** * @coversDefaultClass \Foo\CoveredClass */ class CoversDefaultClassTest extends TestCase { /** * @covers ::publicMethod */ public function testSomething() {

assertInternalType()

assertInternalType() assertInternalType($expected, $actual[, $message = '']) Reports an error identified by $message if $actual is not of the $expected type. assertNotInternalType() is the inverse of this assertion and takes the same arguments. assertAttributeInternalType() and assertAttributeNotInternalType() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object. Example A.30: Usage of assertInternalType() <?php use PHPUnit\Framewor

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

assertInstanceOf()

assertInstanceOf() assertInstanceOf($expected, $actual[, $message = '']) Reports an error identified by $message if $actual is not an instance of $expected. assertNotInstanceOf() is the inverse of this assertion and takes the same arguments. assertAttributeInstanceOf() and assertAttributeNotInstanceOf() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object. Example A.29: Usage of assertInstanceOf() <?php use PHPUnit\Framework\TestCas

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