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

@test

@test As an alternative to prefixing your test method names with test, you can use the @test annotation in a method's DocBlock to mark it as a test method. /** * @test */ public function initialBalanceShouldBe0() { $this->assertEquals(0, $this->ba->getBalance()); }

@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

@ticket

@ticket

@testdox

@testdox

@small

@small The @small annotation is an alias for @group small. A small test must not depend on a test marked as @medium or @large. If the PHP_Invoker package is installed and strict mode is enabled, a small test will fail if it takes longer than 1 second to execute. This timeout is configurable via the timeoutForSmallTests attribute in the XML configuration file. Tests need to be explicitly annotated by either @small, @medium, or @large to enable run time limits.

@uses

@uses The @uses annotation specifies code which will be executed by a test, but is not intended to be covered by the test. A good example is a value object which is necessary for testing a unit of code. /** * @covers BankAccount::deposit * @uses Money */ public function testMoneyCanBeDepositedInAccount() { // ... } This annotation is especially useful in strict coverage mode where unintentionally covered code will cause a test to fail. See the section called “Unintentionally Covere

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

@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

@requires

@requires The @requires annotation can be used to skip tests when common preconditions, like the PHP Version or installed extensions, are not met. A complete list of possibilities and examples can be found at Table 7.3