From the course: PHP: Testing Legacy Applications

Why test a legacy application?

From the course: PHP: Testing Legacy Applications

Start my 1-month free trial

Why test a legacy application?

- [Instructor] Okay, I know we've done a ton of theory and introduced a whole bunch of really high level concepts, and a few medium level concepts, I guess you can call them, about testing. Now it's time to take all that theory and concepts and let's talk about actually writing some tests. So we have a sample application here that is my oldest surviving page B application. It's about 12 years old. It is used by the simulation baseball league that I've been a member of for 21 years, which is a really long time to be doing a hobby, to maintain rosters and trade information, and anything to do with players moving around between teams. So recently I was asked to modify some existing behavior of this application. Now I want to emphasize we should be testing behavior not implementations of things. We're trying to make sure the application behaves the way that we expected. So I was recently asked to change this Git by nickname, not that that you see starting on line 24. What it does as a super quick summary, you pass at the three character short name for a franchise in the league, it talks to the database a few times to get a list of players and draft picks and sorts them in a specific way where we want batters first, organized by a major league baseball team, then pitchers organized by major league baseball team and then finally, draft picks organized by a custom sort that consists of what you would call natural sorting of numbers where, normally when you do comparisons of strings one and 10, sometimes end up coming before two. So you would have one, 10 and two. I used to do that. I didn't care. But the boss of this league said you need to change it. So we're changing the behavior. We're sorting things in a different way. So why do I want to go back and write a test for something that is working? Well this is about confidence level in the application. We're anticipating making a bunch of more changes to the registrar application, updating some user interfaces, adding some new functionality, so I want to make sure that now, when I change things, things aren't going to break.

Contents