~/talk

Testing Legacy Code & Safe Refactoring

Talkat PHP Yorkshire 2019 · 2019-04-03..04-04· [testing, legacy-modernisation]
slides:none on file

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

  1. 0:00Testing Legacy Code & Safe Refactoring
  2. 14:30Hard-coded dependencies
  3. 26:08Ungraceful exits
  4. 33:18Tricky Test Scenario #4 The filesystem
  5. 36:29Spaghetti code
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.