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 - PHP Tutorial
From the course: PHP: Design Patterns
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.
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.