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

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore safe refactoring techniques for legacy PHP code in this 40-minute conference talk from PHP UK 2020. Learn how to make untestable code testable without breaking existing functionality. Dive into unit testing concepts, PHPUnit installation, and test anatomy. Discover mocking strategies using Mockery, and tackle common challenges like hard-coded dependencies, redirections, and exiting. Master techniques for refactoring spaghetti code and private methods. Gain practical insights to confidently update and maintain legacy PHP projects while ensuring code integrity and reliability.

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.