Block8/PHPCI — pull request #213 by meadsteve (2013-11-20 09:30:13+00:00)
Title: Plugin construction change - plugin factory

Something that's been bugging me for a while is the lack of unit tests for the project. I've been fixing up the tests for the email plugin I wrote and one major blocker was the inability to easily mock out the swift mailer object.

One solution to this problem was to remove the constructor from the plugin interface (I was never keen on that to begin with) and then use constructor dependency injection. This allows the unit tests to easily inject mocks.

So that the plugins can still be built by PHPCI I've created a factory where dependencies can be registered by name and/or type when a plugin is constructed reflection is used to find out what arguments it expects to receive and these are retrieved from the factories store.

What does everyone think of this approach?