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

@beforeClass

@beforeClass The @beforeClass annotation can be used to specify static methods that should be called before any test methods in a test class are run to set up shared fixtures. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @beforeClass */ public static function setUpSomeSharedFixtures() { // ... } /** * @beforeClass */ public static function setUpSomeOtherSharedFixtures() { // ... } }

@backupStaticAttributes

@backupStaticAttributes The @backupStaticAttributes annotation can be used to back up all static property values in all declared classes before each test and restore them afterwards. It may be used at the test case class or test method level: use PHPUnit\Framework\TestCase; /** * @backupStaticAttributes enabled */ class MyTest extends TestCase { /** * @backupStaticAttributes disabled */ public function testThatInteractsWithStaticAttributes() { // ... } }

@before

@before The @before annotation can be used to specify methods that should be called before each test method in a test case class. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @before */ public function setupSomeFixtures() { // ... } /** * @before */ public function setupSomeOtherFixtures() { // ... } }

@covers

@covers The @covers annotation can be used in the test code to specify which method(s) a test method wants to test: /** * @covers BankAccount::getBalance */ public function testBalanceIsInitiallyZero() { $this->assertEquals(0, $this->ba->getBalance()); } If provided, only the code coverage information for the specified method(s) will be considered. Table B.1 shows the syntax of the @covers annotation. Table B.1. Annotations for specifying which methods are covered by a t

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

@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() { // ... } }

@author

@author The @author annotation is an alias for the @group annotation (see the section called “@group”) and allows to filter tests based on their authors.

@after

@after The @after annotation can be used to specify methods that should be called after each test method in a test case class. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @after */ public function tearDownSomeFixtures() { // ... } /** * @after */ public function tearDownSomeOtherFixtures() { // ... } }

@backupGlobals

@backupGlobals The backup and restore operations for global variables can be completely disabled for all tests of a test case class like this use PHPUnit\Framework\TestCase; /** * @backupGlobals disabled */ class MyTest extends TestCase { // ... } The @backupGlobals annotation can also be used on the test method level. This allows for a fine-grained configuration of the backup and restore operations: use PHPUnit\Framework\TestCase; /** * @backupGlobals disabled */ class MyTest e