Hi, IMO, it's more consistent (and to avoid the confusion) if overloading is done with annotation-based configs too, but it's a matter of preference.
Am a Spring person, so, hope this page about annotation-based container configuration can be a good reference for whoever interested in other implementations: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-annotation-config Yuen-Chi Lian | www.yclian.com "I do not seek; I find." - Pablo Picasso On Thu, Sep 23, 2010 at 10:16 PM, Loïc Frering <[email protected]>wrote: > @Lukas, yes just for testing, it would be quite confusing otherwise. > > @Bulat, it is a good approach also. An other thing you can do with PHPUnit > is: > > $mockAuthService = $this->getMock('Application\Service\AuthService'); > // configure PHPUnit Mock > $mockAuthService->expect() > // ... > $container->set("auth.service", $mockAuthService); > or directly as you wrote: > $controller->setAuthService($mockAuthService); > > By the way, what I meant is that you can just overload your annotation > definition with something like that: > > services: > auth.service: > class: Test\*Mock*\Service\*Mock*AuthService > arguments: [...] > > Then nothing more to do in your tests: the controller is configured by the > DIC which inject his dependencies. But for tests purpose the implementation > is not the same: the mock service will be injected and the test code does > not have to worry or even know about that. That is the flexibility provided > by DI, from Wikipedia <http://en.wikipedia.org/wiki/Dependency_injection>: > "[DI] is useful in unit > testing<http://en.wikipedia.org/wiki/Unit_testing>because it is easy to > inject a fake > implementation <http://en.wikipedia.org/wiki/Mock_object> of a service > into the object being tested by changing the configuration file." > > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
