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

Add getters and setters

From the course: PHP: Testing Legacy Applications

Start my 1-month free trial

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…

Contents