Refactored tests to use phpUnit mocks instead of hand-written.