PHPUnit
  • 1. Installation
    • PHP on the Command-Line
      • Installing the PHP Command-Line Interpreter
        • Fedora
        • Debian
        • Ubuntu
        • macOS
        • Windows
      • Using the PHP Command-Line Interpreter
      • Configuring PHP for Development
    • Installing PHPUnit
      • PHP Archive (PHAR)
        • Manual Download of PHAR
        • Installing PHPUnit with Phive
        • Updating PHPUnit with Phive
        • What is inside the PHAR?
      • Composer
        • Installing PHPUnit with Composer
        • Updating PHPUnit with Composer
      • PHAR or Composer?
      • Global Installation
      • Web Server
  • 2. Writing Tests for PHPUnit
    • Asserting Return Values
    • Expecting Exceptions
    • Data Providers
    • Testing Output
    • Incomplete Tests
    • Skipping Tests
      • Skipping Tests using Attributes
    • Test Dependencies
    • Failure Output
      • Edge Cases
  • 3. The Command-Line Test Runner
    • Outcome and Issues
    • Command-Line Options
      • Configuration
      • Selection
      • Execution
        • Isolation
        • Risky Tests
        • Automatically stop when …
        • Exit with error code when …
        • Test Result Cache
        • Test Order
      • Reporting
        • Console
        • Progress and Result Printing
        • Details about Issues
        • Alternative Output
      • Logging
        • Code Coverage
        • Miscellaneous
  • 4. Organizing Tests
    • Composing a Test Suite Using the Filesystem
    • Composing a Test Suite Using XML Configuration
  • 5. Fixtures
    • More setUp() than tearDown()
    • Sharing Fixture
    • Global State
  • 6. Test Doubles
    • Test Stubs
      • Creating Test Stubs
        • createStub()
        • createStubForIntersectionOfInterfaces()
        • createConfiguredStub()
      • Configuring Test Stubs
        • willReturn()
        • willThrowException()
        • willReturnArgument()
        • willReturnCallback()
        • willReturnSelf()
        • willReturnMap()
    • Mock Objects
      • Creating Mock Objects
        • createMock()
        • createMockForIntersectionOfInterfaces()
        • createConfiguredMock()
        • getMockForAbstractClass()
        • getMockForTrait()
        • getMockFromWsdl()
      • Configuring Mock Objects
    • MockBuilder API
      • setMockClassName()
      • setConstructorArgs()
      • disableOriginalConstructor()
      • disableOriginalClone()
      • enableArgumentCloning()
      • disableAutoReturnValueGeneration()
      • disallowMockingUnknownTypes()
      • disableAutoload()
      • enableProxyingToOriginalMethods()
      • onlyMethods()
      • addMethods()
      • getMock()
      • getMockForAbstractClass()
      • getMockForTrait()
  • 7. Code Coverage
    • Software Metrics for Code Coverage
    • Including Files
    • Targeting Units of Code
    • Ignoring Code Blocks
  • 8. Risky Tests
    • Useless Tests
    • Unintentionally Covered Code
    • Output During Test Execution
    • Test Execution Timeout
    • Global State Manipulation
  • 9. Error Handling
    • Limiting issues to “your code”
    • Ignoring issue suppression
    • Ignoring previously reported issues
    • Expecting Deprecations (E_USER_DEPRECATED)
    • Disabling PHPUnit’s error handler
  • 10. Extending PHPUnit
    • Enhancing concrete test cases
    • Extracting abstract test cases
    • Extracting traits
    • Extending the Test Runner
      • Implementing an extension
        • Implementing an event subscriber
        • Implementing an event tracer
        • Understanding events
      • Sharing an extension
        • Sharing an extension as a PHAR
        • Sharing an extension as a Composer package
      • Registering an extension
        • Registering an extension from a PHAR
        • Registering an extension from a Composer package
      • Debugging PHPUnit
    • Wrapping the Test Runner

Appendix

  • 1. Assertions
    • Static vs. Non-Static Usage of Assertion Methods
    • Boolean
      • assertTrue()
      • assertFalse()
    • Identity
      • assertSame()
      • assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys()
      • assertArrayIsIdenticalToArrayIgnoringListOfKeys()
    • Equality
      • assertEquals()
      • assertEqualsCanonicalizing()
      • assertEqualsIgnoringCase()
      • assertEqualsWithDelta()
      • assertObjectEquals()
      • assertFileEquals()
      • assertArrayIsEqualToArrayOnlyConsideringListOfKeys()
      • assertArrayIsEqualToArrayIgnoringListOfKeys()
    • Iterable
      • assertArrayHasKey()
      • assertContains()
      • assertContainsOnly()
      • assertContainsOnlyInstancesOf()
    • Objects
      • assertObjectHasProperty()
    • Cardinality
      • assertCount()
      • assertSameSize()
      • assertEmpty()
      • assertGreaterThan()
      • assertGreaterThanOrEqual()
      • assertLessThan()
      • assertLessThanOrEqual()
    • Types
      • assertInstanceOf()
      • assertIsArray()
      • assertIsList()
      • assertIsBool()
      • assertIsCallable()
      • assertIsFloat()
      • assertIsInt()
      • assertIsIterable()
      • assertIsNumeric()
      • assertIsObject()
      • assertIsResource()
      • assertIsScalar()
      • assertIsString()
      • assertNull()
    • Strings
      • assertStringStartsWith()
      • assertStringEndsWith()
      • assertStringContainsString()
      • assertStringContainsStringIgnoringCase()