Principles of Unit Testing
summary
Defines a unit test as verifying a unit against a specification and walks through concrete PHPUnit examples using PHPUnit and Prophecy, demonstrating the five test doubles (dummy, fake, stub, spy, mock), when to use each, and how a spy makes Arrange‑Act‑Assert clearer than a mock. Uses Drupal code (BatchStorage load, maintenance mode subscriber) to show refactoring into single‑responsibility units, suggests PhpMetrics to find high cyclomatic complexity targets, and names Coveralls/CircleCI for coverage and automation.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 4:49Agenda
- 6:27Definition
- 11:24Levels of Testing
- 13:29Test Doubles
- 17:17Test Double Types
- 28:39Questions
- 31:14Example
- 36:18Responsibility
- 39:49Test smells
- 41:26Bridge analogy
- 44:59Rule of 3
- 48:01Socially Unit Testing
- 50:16The Lorax
- 51:46An easy example
- 52:24PHP metrics
- 54:41Symphony








