Building Testable PHP Applications
summary
Claims a few immediate rules let messy PHP become testable now: replace "new" with constructor injection, isolate business logic from the framework, write test doubles for DB and APIs instead of using a real database, prefer Mockery over PHPUnit mocks for spies, and measure coverage with xdebug. Demonstrations show mock setups, wrapper APIs, and Vagrant-backed dev environments; a large suite example hits hundreds of thousands of PHP tests and runs in about 15 minutes.
AI-written summary · about
chapters (10)
- 0:00Start
- 7:18It's About Tools
- 7:49It's About Strategies
- 8:07WHAT DOES TESTABLE CODE
- 18:00The Law of Demeter
- 19:51Dependency Injection
- 22:56Test Doubles
- 32:55Databases In Unit Tests
- 38:44API Calls
- 41:58Environmental Concerns
related talks
58mObjects, Testing and Responsibility
41mTesting Legacy Code & Safe Refactoring
47mRight Approaches to Testing in PHP: Or How Quantity Can Break Quality
01h 00mPrinciples of Unit Testing
56mUnit Testing by Example
29mEffective tests and testing effectively
01h 00mStop mocking everything
45mTesting Legacy Code - What To Do When It Seems Untestable
