PHP theorytheory 0/50 · 0%
Testing · medium

36. PHPUnit Testing

Automated testing in PHP.

PHPUnit is the de facto standard testing framework for PHP, where test classes extend TestCase and test methods (conventionally prefixed with 'test' or annotated with #[Test]) contain assertions like assertEquals() and assertTrue(). Tests are run with the phpunit CLI command.

Data providers let a single test method run against multiple input/output pairs, and mock objects (via createMock()) isolate the unit under test from its dependencies.

Check your understanding

  1. 1. What must a PHPUnit test class typically extend?

  2. 2. What technique lets one test method run with multiple sets of inputs?