@preserveGlobalState

@preserveGlobalState When a test is run in a separate process, 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 serializable. To fix this, you can prevent PHPUnit from preserving global state with the @preserveGlobalState annotation. use PHPUnit\Framework\TestCase; class MyTest extends TestCase {

@runInSeparateProcess

@runInSeparateProcess Indicates that a test should be run in a separate PHP process. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @runInSeparateProcess */ public function testInSeparateProcess() { // ... } } 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 pro

@medium

@medium The @medium annotation is an alias for @group medium. A medium test must not depend on a test marked as @large. If the PHP_Invoker package is installed and strict mode is enabled, a medium test will fail if it takes longer than 10 seconds to execute. This timeout is configurable via the timeoutForMediumTests attribute in the XML configuration file.

@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

@expectedExceptionCode

@expectedExceptionCode The @expectedExceptionCode annotation, in conjunction with the @expectedException allows making assertions on the error code of a thrown exception thus being able to narrow down a specific exception. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @expectedException MyException * @expectedExceptionCode 20 */ public function testExceptionHasErrorcode20() { throw new MyException('Some Message', 20); } } T

@expectedException

@expectedException Example 2.10 shows how to use the @expectedException annotation to test whether an exception is thrown inside the tested code. See the section called “Testing Exceptions” for more details.

@dataProvider

@dataProvider A test method can accept arbitrary arguments. These arguments are to be provided by a data provider method (provider() in Example 2.5). The data provider method to be used is specified using the @dataProvider annotation. See the section called “Data Providers” for more details.

@expectedExceptionMessageRegExp

@expectedExceptionMessageRegExp The expected message can also be specified as a regular expression using the @expectedExceptionMessageRegExp annotation. This is helpful for situations where a substring is not adequate for matching a given message. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @expectedException MyException * @expectedExceptionMessageRegExp /Argument \d+ can not be an? \w+/ */ public function testExceptionHasRi

@depends

@depends PHPUnit supports the declaration of explicit dependencies between test methods. Such dependencies do not define the order in which the test methods are to be executed but they allow the returning of an instance of the test fixture by a producer and passing it to the dependent consumers. Example 2.2 shows how to use the @depends annotation to express dependencies between test methods. See the section called “Test Dependencies” for more details.

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