Noting Tim Otten's answer here which pointed to his blog post, I'd like to know the best pattern to allow injection of CiviCRM services into extension classes and other things (ie to support unit testing).

The kind of services that it would be most useful to inject are those that have external impacts or a generally slow:

  • database access layer
  • email system
  • logging
  • API3
  • API4
  • payment processing

I'm stuck on 4.6 for a month or two, and I'm guessing the answer will be different in 4.7, but happy for a "In 4.7..." answer.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.