From the course: PHP: Testing Legacy Applications
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Refactor your tests
- [Narrator] Okay, so when I was writing the previous tests that used doubles, when I was looking at the code in the roster model, I discovered I was not writing a test for a specific condition. I want to show you that condition in the code. As you can see in lines 30 to 40, I added a conditional statement that basically says if I get no information from the database, I want to return an empty array, and then later on in the application, I handle what happens when we get that empty array. When you're writing tests, you need to look at every single conditional statement, and every loop, to make sure that you have coverage for all possible behaviors. So while you were busy soaking in all the information that I taught you before, I went and wrote a test to cover this, so let's take a quick look at it. So we're doing the same sort of things that we did for the previous test, where we're creating a bunch of doubles for our select object, our db object, our pdo statement, and then down…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Why test a legacy application?1m 57s
-
(Locked)
Identifying dependencies3m 20s
-
(Locked)
Planning a scenario5m 32s
-
(Locked)
Building a scenario6m 6s
-
(Locked)
Planning real to doubles4m 19s
-
(Locked)
Building real to doubles7m 7s
-
(Locked)
Refactor your tests4m 11s
-
(Locked)
Add getters and setters3m 58s
-
-