Skip to content

Course

PHP Testing with PHPUnit & Pest

Professional PHP testing: unit and integration boundaries, disciplined mocking, database isolation, mutation testing, and CI suites fast enough that people actually run them.

9 lessons

Course Q&A

Reviews

Enrolled members can rate this course.

No reviews yet.

Test Design Foundations

What to test, where the boundaries belong, and how PHPUnit expresses intent.

  1. 01Unit vs Integration: Draw the Boundary OnceThe testing pyramid in PHP terms, why 'mock everything' suites lie, and how to decide whether a test needs a unit or an integration seam.22mOpen
  2. 02PHPUnit Essentials That Prevent Bad HabitsModern PHPUnit attributes, precise assertions, data providers, exception testing, and configuration that keeps the suite honest.24mOpen
  3. 03Pest Without Losing RigorWhat Pest changes ergonomically, what it does not change architecturally, and how to use datasets, expectations, and plugins without writing fuzzy tests.19mOpen

Isolation and Data

Test doubles, fixtures, factories, and database tests that stay deterministic.

  1. 01Mocking Boundaries, Not Everything in ReachHow to use PHPUnit test doubles at ports and interfaces, when mocks make tests worse, and why interaction assertions are a last resort.25mOpen
  2. 02Fixtures and Factories That Stay ReadableBuild minimal test data close to the scenario, use factories for object graphs, and avoid fixture files that become a second production schema.21mOpen
  3. 03Database Testing with Transactions and Real ConstraintsRollback-per-test isolation, migration strategy, SQLite versus production engines, and the constraint tests teams forget until data corrupts.26mOpen

Professional Test Suites

External services, mutation testing, flaky-test control, and fast CI execution.

  1. 01Testing External Services Without Believing Your Own MocksAdapter tests, PSR-18 fakes, recorded contracts, consumer-driven expectations, and the thin slice of live smoke testing that catches drift.23mOpen
  2. 02Mutation Testing with InfectionWhat MSI really measures, how to interpret killed and escaped mutants, and how to use Infection without turning CI into a vanity metric.22mOpen
  3. 03Fast CI Suites and Flaky-Test ControlSplit suites by cost, parallelize safely, manage coverage overhead, and eliminate flaky tests before the team learns to ignore red builds.24mOpen