Staying OO and Testable while working with a database
- by Adam Backstrom
What are some OOP strategies for working with a database but keeping thing testable? Say I have a User class and my production environment works against MySQL. I see a couple possible approaches, shown here using PHP:
Pass in a $data_source with interfaces for load() and save(), to abstract the backend source of data. When testing, pass a…