Testing Legacy Code & Safe Refactoring
summary
Explains concrete steps to make untestable legacy PHP code safe to change: install and run PHPUnit, use Mockery to mock static calls and constructed objects (alias/overload), capture output with output buffering, wrap exit/redirects and inject dependencies with default parameters so signatures stay compatible, and replace file IO with vfsStream for tests. Shows an upgrade path (PHP 5.6 → 7.1) and reports that avoiding per-test separate processes halved build time from ~20 to ~10 minutes.
AI-written summary · about
chapters (5)
- 0:00Testing Legacy Code & Safe Refactoring
- 14:30Hard-coded dependencies
- 26:08Ungraceful exits
- 33:18Tricky Test Scenario #4 The filesystem
- 36:29Spaghetti code
related talks
40mTesting Legacy Code: Safe Refactoring
45mTesting Legacy Code - What To Do When It Seems Untestable
50mBuilding Testable PHP Applications
46mLiving the best life on a legacy project
58mTesting Complex Applications for PHP7
58mObjects, Testing and Responsibility
40mBullet-proof projects
52mTest, Transform, Refactor
