Refactored tests to use PHPUnit mocks.