You're right about the DIC, but what about the unit test part? How am
I supposed to test my controller with the hardcoded dependency to
Swift_Message?

Maybe I'm just not aware of how testing works in Symfony2, just trying
to clarify things :)

On Feb 22, 1:03 am, Christophe COEVOET <[email protected]> wrote:
> Le 21/02/2011 14:28, Geoffrey Bachelet a crit :
>
>
>
>
>
>
>
> > Hi everyone,
>
> > I'm not sure if this issue (if it is at all an issue, still not sure
> > about that) as been raised already, in which case sorry for the noise,
> > but reading the email cookbook
> > (http://docs.symfony-reloaded.org/master/cookbook/email.html), I saw
> > that snippet of code:
>
> >      $mailer = $this->get('mailer');
> >      $message = \Swift_Message::newInstance()
>
> > Now, isn't (one of) the point of the DIC to eliminate component
> > coupling? If so, it seems totally defeated by the hard-coding of the
> > Swift_Message::newInstance() call.
>
> > Even if we admit that most people won't use anything else than
> > SwiftMailer, how do you handle this case in a unit test?
>
> > Regards,
>
> > Geoffrey
>
> If you don't use swiftmailer you cannot use the code mailer service
> anyway (as it is provided by SwiftmailerBundle).
> You cannot provide a code working for both Swiftmailer and PHPmailer in
> an agnostic way as they don't have the same API. So why is it bad to
> write it there ?
>
> Thus it is not about decoupling component. If your controller uses
> Swiftmailer to send a mail it will have a dependency to Swiftmailer. the
> DIC is about injecting the dependencies, not removing them.
>
> --
> Christophe | Stof

-- 
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

Reply via email to