From the course: PHP: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Apply mock objects

Solution: Apply mock objects - PHP Tutorial

From the course: PHP: Design Patterns

Start my 1-month free trial

Solution: Apply mock objects

(airy cymbal) - As I noted before, there aren't any changes to database.php. Our original class is untouched. All of our work is done in a new class called Mockuser which has a single method, delete, which simply returns true. Remember, we're not actually trying to perform an action here. We're just having the object act like it did. Then in index.php, we can modify our code to make use of this Mockuser object.

Contents