PHPUnit Manual
Edition for PHPUnit 9.6. Updated on Feb 23, 2023.
Sebastian Bergmann
This work is licensed under the Creative Commons Attribution 3.0 Unported License.
Contents:
- 1. Installing PHPUnit
- 2. Writing Tests for PHPUnit
- 3. The Command-Line Test Runner
- 4. Fixtures
- 5. Organizing Tests
- 6. Risky Tests
- 7. Incomplete and Skipped Tests
- 8. Test Doubles
- 9. Code Coverage Analysis
Appendix
- 1. Assertions
- Static vs. Non-Static Usage of Assertion Methods
- assertArrayHasKey()
- assertClassHasAttribute()
- assertClassHasStaticAttribute()
- assertContains()
- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertContainsOnly()
- assertContainsOnlyInstancesOf()
- assertCount()
- assertDirectoryExists()
- assertDirectoryIsReadable()
- assertDirectoryIsWritable()
- assertEmpty()
- assertEquals()
- assertEqualsCanonicalizing()
- assertEqualsIgnoringCase()
- assertEqualsWithDelta()
- assertObjectEquals()
- assertFalse()
- assertFileEquals()
- assertFileExists()
- assertFileIsReadable()
- assertFileIsWritable()
- assertGreaterThan()
- assertGreaterThanOrEqual()
- assertInfinite()
- assertInstanceOf()
- assertIsArray()
- assertIsBool()
- assertIsCallable()
- assertIsFloat()
- assertIsInt()
- assertIsIterable()
- assertIsNumeric()
- assertIsObject()
- assertIsResource()
- assertIsScalar()
- assertIsString()
- assertIsReadable()
- assertIsWritable()
- assertJsonFileEqualsJsonFile()
- assertJsonStringEqualsJsonFile()
- assertJsonStringEqualsJsonString()
- assertLessThan()
- assertLessThanOrEqual()
- assertNan()
- assertNull()
- assertObjectHasAttribute()
- assertMatchesRegularExpression()
- assertStringMatchesFormat()
- assertStringMatchesFormatFile()
- assertSame()
- assertSameSize()
- assertStringEndsWith()
- assertStringEqualsFile()
- assertStringStartsWith()
- assertThat()
- assertTrue()
- assertXmlFileEqualsXmlFile()
- assertXmlStringEqualsXmlFile()
- assertXmlStringEqualsXmlString()
- 2. 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
- 3. The XML Configuration File
- 4. Bibliography
- 5. Copyright