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.
Add getters and setters
From the course: PHP: Testing Legacy Applications
Add getters and setters
- [Instructor] I know that in some other videos we've talked about how often you will need to refactor or rewrite your code in order for it to be more testable. And so far we've been pretty lucky with this roster model that we haven't had to change anything. But let's consider another scenario. Let's say we have a coding standard in place for this application where we say that all these attributes of classes like what we see on lines four and five on the screen, they have to be private, they can't be public. Meaning that you cannot modify them at runtime after we've created an instance of this class. If we had to rewrite our test to comply with this coding standard, what change would we have to make? Well, we would have to turn those attributes into private ones and then we would add a getter and setter combination so that we could override the PDO attribute at runtime. So let me show you how I would particularly handle this. So right below our constructor, I'm just going to add…
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
-
-