PHPUnit Manual
Edition for PHPUnit 10.2. Updated on Jul 05, 2023.
Sebastian Bergmann
This work is licensed under the Creative Commons Attribution 3.0 Unported License.
Contents:
- 1. Installation
- 2. Writing Tests for PHPUnit
- 3. The Command-Line Test Runner
- 4. Organizing Tests
- 5. Fixtures
- 6. Test Doubles
- Test Stubs
- Mock Objects
- MockBuilder API
setMockClassName()setConstructorArgs()disableOriginalConstructor()disableOriginalClone()enableArgumentCloning()disableAutoReturnValueGeneration()disallowMockingUnknownTypes()disableAutoload()enableProxyingToOriginalMethods()onlyMethods()addMethods()getMock()getMockForAbstractClass()getMockForTrait
- 7. Code Coverage
- 8. Risky Tests
- 9. Extending PHPUnit
Appendix
- 1. Assertions
- 2. Attributes
- 3. Annotations
- @author
- @after
- @afterClass
- @backupGlobals
- @backupStaticAttributes
- @before
- @beforeClass
- @codeCoverageIgnore*
- @covers
- @coversDefaultClass
- @coversNothing
- @dataProvider
- @depends
- @doesNotPerformAssertions
- @group
- @large
- @medium
- @preserveGlobalState
- @requires
- @runTestsInSeparateProcesses
- @runInSeparateProcess
- @small
- @test
- @testdox
- @testWith
- @ticket
- @uses
- 4. Events
- 5. The XML Configuration File
- The
<phpunit>Element- The
backupGlobalsAttribute - The
backupStaticPropertiesAttribute - The
bootstrapAttribute - The
cacheDirectoryAttribute - The
cacheResultAttribute - The
colorsAttribute - The
columnsAttribute - The
requireCoverageMetadataAttribute - The
processIsolationAttribute - The
stopOnDefectAttribute - The
stopOnErrorAttribute - The
stopOnFailureAttribute - The
stopOnWarningAttribute - The
stopOnRiskyAttribute - The
stopOnDeprecationAttribute - The
stopOnNoticeAttribute - The
stopOnSkippedAttribute - The
stopOnIncompleteAttribute - The
failOnEmptyTestSuiteAttribute - The
failOnWarningAttribute - The
failOnRiskyAttribute - The
failOnDeprecationAttribute - The
failOnNoticeAttribute - The
failOnSkippedAttribute - The
failOnIncompleteAttribute - The
beStrictAboutChangesToGlobalStateAttribute - The
beStrictAboutOutputDuringTestsAttribute - The
beStrictAboutTestsThatDoNotTestAnythingAttribute - The
beStrictAboutCoverageMetadataAttribute - The
enforceTimeLimitAttribute - The
defaultTimeLimitAttribute - The
timeoutForSmallTestsAttribute - The
timeoutForMediumTestsAttribute - The
timeoutForLargeTestsAttribute - The
defaultTestSuiteAttribute - The
stderrAttribute - The
reverseDefectListAttribute - The
registerMockObjectsFromTestArgumentsRecursivelyAttribute - The
extensionsDirectoryAttribute - The
executionOrderAttribute - The
resolveDependenciesAttribute - The
testdoxAttribute - The
displayDetailsOnIncompleteTestsAttribute - The
displayDetailsOnSkippedTestsAttribute - The
displayDetailsOnTestsThatTriggerDeprecationsAttribute - The
displayDetailsOnTestsThatTriggerErrorsAttribute - The
displayDetailsOnTestsThatTriggerNoticesAttribute - The
displayDetailsOnTestsThatTriggerWarningsAttribute
- The
- The
<testsuites>Element - The
<source>Element- The
<include>Element - The
<exclude>Element - The
<directory>Element - The
<file>Element - The
<restrictDeprecations>Attribute - The
<restrictNotices>Attribute - The
<restrictWarnings>Attribute - The
<ignoreSuppressionOfDeprecations>Attribute - The
<ignoreSuppressionOfPhpDeprecations>Attribute - The
<ignoreSuppressionOfErrors>Attribute - The
<ignoreSuppressionOfNotices>Attribute - The
<ignoreSuppressionOfPhpNotices>Attribute - The
<ignoreSuppressionOfWarnings>Attribute - The
<ignoreSuppressionOfPhpWarnings>Attribute
- The
- The
<coverage>Element - The
<logging>Element - The
<groups>Element - The
<extensions>Element - The
<php>Element
- The
- 6. Copyright