public function sendPasswordResetMail(UserPasswordResetInterface $user)
 {
     $masterRequest = $this->requestStack->getMasterRequest();
     list($subject, $htmlBody) = $this->prepareMessage(array('user' => $user, 'ip' => $masterRequest->getClientIp(), 'user_agent' => $masterRequest->headers->get('User-Agent')));
     $message = \Swift_Message::newInstance()->setSubject($subject)->setTo($user->getEmail())->setFrom($this->fromEmail);
     if ($this->replayToEmail) {
         $message->setReplyTo($this->replayToEmail);
     }
     if (!empty($htmlBody)) {
         $message->setBody($htmlBody, 'text/html');
     }
     return $this->mailer->send($message);
 }
 /**
  * @param \FSi\Bundle\AdminSecurityBundle\Model\UserPasswordResetInterface $user
  * @param \Twig_Environment $twig
  * @param \Twig_Template $template
  * @param \Swift_Mailer $mailer
  * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
  */
 function it_should_render_template($user, $twig, $template, $mailer, $requestStack)
 {
     $request = new Request(array(), array(), array(), array(), array(), array('HTTP_USER_AGENT' => 'user agent', 'REMOTE_ADDR' => '192.168.99.99'));
     $requestStack->getMasterRequest()->willReturn($request);
     $templateParameters = array('user' => $user, 'ip' => '192.168.99.99', 'user_agent' => 'user agent');
     $twig->mergeGlobals($templateParameters)->willReturn($templateParameters);
     $twig->loadTemplate('mailer-template.html.twig')->willReturn($template);
     $template->renderBlock('subject', $templateParameters)->willReturn('subject string');
     $template->renderBlock('body_html', $templateParameters)->willReturn('body string');
     $user->getEmail()->willReturn('*****@*****.**');
     $mailer->send(Argument::allOf(Argument::type('\\Swift_Message'), Argument::which('getSubject', 'subject string'), Argument::which('getTo', array('*****@*****.**' => null)), Argument::which('getFrom', array('*****@*****.**' => null)), Argument::which('getReplyTo', array('*****@*****.**' => null)), Argument::which('getBody', 'body string')))->willReturn(1);
     $this->sendPasswordResetMail($user)->shouldReturn(1);
 }