Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Testing Legacy Code - Safe Refactoring

PHP UK Conference via YouTube

Overview

Google, IBM & Meta Certificates – 40% Off
One Coursera Plus subscription covers most Professional Certificates on Coursera.
Unlock All Certificates
This talk shows how to make legacy PHP code testable and refactor it while preserving existing behavior. It covers unit testing, mocking, and ways to handle hard-coded dependencies and other difficult code patterns.

Syllabus

Intro
What is legacy code?
What is refactoring?
What is unit testing?
Why would I unit test?
A solution
A better solution
PHPUnit - installation
Anatomy of a unit test
Running the tests
Mocking - Caution!
Mockery - Installation
Mockery - Usage
A method that echoes
A static method call
Testing: hard-coded dependencies
Refactoring hard-coded dependencies
A hard-coded dependency
Refactoring Redirections
Refactoring Exiting
Refactoring: Updating a file
Fake filesystem
Testing: Spaghetti Code
Private methods
Time for a recap...

Taught by

PHP UK Conference

Reviews

Start your review of Testing Legacy Code - Safe Refactoring

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.