PHP: Testing Legacy Applications
1h 44mIntermediate2018-04-18
Authors

Chris Hartjes
Building web applications since 1998
Course details
Working with a legacy code base can be tricky. Developers who need to add new features or fix bugs often feel the need to tread lightly when working with older code, fearing that one wrong move might cause them to break something important. The same apprehension can affect developers who want to test legacy PHP applications. In this course, instructor Chris Hartjes guides PHP developers through the challenges of testing legacy applications, and steps through how to write tests for legacy PHP code bases.
Chris begins by explaining the difference between test-driven development as a design pattern and writing tests after the code is already designed. Next, he shares some reasons why legacy code can be tough to test, including poor package management practices and hard-coded dependencies. He then covers how—and what—you should be testing, how to plan out testing scenarios, and how to refactor a test suite. Upon wrapping up this course, you'll have the skills you need to test your legacy PHP code with confidence.
Learning objectives
What changes when testing legacy code
Why legacy code can be difficult to test
Identifying hard-coded dependencies in code
Deciding what to test
Testing legacy code
Planning a scenario
Building a testing scenario from scratch
Refactoring a test suite
Chris begins by explaining the difference between test-driven development as a design pattern and writing tests after the code is already designed. Next, he shares some reasons why legacy code can be tough to test, including poor package management practices and hard-coded dependencies. He then covers how—and what—you should be testing, how to plan out testing scenarios, and how to refactor a test suite. Upon wrapping up this course, you'll have the skills you need to test your legacy PHP code with confidence.
Learning objectives
What changes when testing legacy code
Why legacy code can be difficult to test
Identifying hard-coded dependencies in code
Deciding what to test
Testing legacy code
Planning a scenario
Building a testing scenario from scratch
Refactoring a test suite
Skills covered
PHPUnitPHPProgramming LanguagesOpen SourceSoftware Development
Concepts
0. Introduction
- 01 - Welcome
- 02 - What you need you to know
- 03 - Exercise files
1. What Changes When Testing Legacy Code
- 04 - TDD vs. test after
- 05 - How the tools change
- 06 - Quick primer on test doubles
- 07 - Code coverage and confidence levels
- 08 - Difficult people
2. Why Legacy Code Can Be Hard to Test
- 09 - Bootstrap sequences, part 1
- 10 - Bootstrap sequences, part 2
- 11 - Hard-coded dependencies
- 12 - Difficult deployments
- 13 - Poor package management practices
3. Laying the Foundation
- 14 - Just how many tests do we need
- 15 - Tests as questions
- 16 - How we decide what to test
- 17 - Real vs. monkey patch vs. double
4. Testing Legacy Code
- 18 - Why test a legacy application
- 19 - Identifying dependencies
- 20 - Planning a scenario
- 21 - Building a scenario
- 22 - Planning real to doubles
- 23 - Building real to doubles
- 24 - Refactor your tests
- 25 - Add getters and setters
Conclusion
- 26 - Next steps