Talk in English - US at Longhorn PHP Conference 2022
View Slides: https://speakerdeck.com/maccath/legacy-code-longhorn-php-2022
Short URL: https://joind.in/talk/e0655 (QR-Code (opens in new window))
I can't test this code because it's legacy. I need to update the code to make it testable. How can I manage that, without breaking existing functionality? I'll need to write some tests, but... argh!
Comments are closed.
So helpful and well explained. I really appreciated the insight into a topic that I am actively working on growing into.
Lots of great examples of tricky testing scenarios. I loved the way you handled the exit problem, as we have that issue in our current legacy application. We will probably end up using your idea from that.
While the bolognese example while being funny when talking about spaghetti code, it was a little convoluted and hard to follow.
Also wanted to share there's another way to handle static calls as well with Dependency Injection which is kind of your theme in the presentation.
We call them wrappers. I think I have your example right from me recollection. Example:
* @method getPowerLevel(): int
public function __call($name, $arguments)
GokuWrapper can now be injected and mocked.
Good code examples that illustrated the problems, and good to see how to refactor code to make it testable. Loved the humor and movie references, good flow, easy to follow along with, and overall a great talk!
Really good examples and grail increase in difficulty level. i'm not sure i agree with adding function parameters specifically used by tests, but i can definitely understand that some legacy situations will demand it, and it DOES introduce a path to refactoring into testable code.
Really good examples and gradual increase in difficulty level. i'm not sure i agree with adding function parameters specifically used by tests, but i can definitely understand that some legacy situations will demand it, and it DOES introduce a path to refactoring into testable code.