public function testSendMail()
 {
     $defaultEmail = '*****@*****.**';
     $event = new MailerEvent();
     $event->addUser(User::create('Ma27', '123456', '*****@*****.**'));
     $event->addUser(User::create('benbieler', '123456', '*****@*****.**'));
     $event->setTemplateSource('AppBundle:emails:test');
     $mailer = $this->getMockWithoutInvokingTheOriginalConstructor(\Swift_Mailer::class);
     $templatingEngine = $this->getMockWithoutInvokingTheOriginalConstructor(TwigEngine::class);
     $templatingEngine->expects($this->at(0))->method('render')->with('AppBundle:emails:test.txt.twig', [])->willReturn('Notifications');
     $templatingEngine->expects($this->at(1))->method('render')->with('AppBundle:emails:test.html.twig', [])->willReturn('<b>Notifications</b>');
     $translator = $this->getMock(TranslatorInterface::class);
     $translator->expects($this->once())->method('trans')->with('NOTIFICATIONS_SUBJECT', [], 'notifications')->willReturn('Sententiaregum Notifications');
     $listener = new MailListener($mailer, $translator, $templatingEngine, $defaultEmail);
     $listener->onMailEvent($event);
 }
 /**
  * Dispatches the mailer event.
  *
  * @param User   $user
  * @param string $templateName
  * @param string $eventName
  */
 private function dispatchNotificationEvent(User $user, $templateName, $eventName)
 {
     $event = new MailerEvent();
     $event->addUser($user)->addParameter('notification_target', $user)->addParameter('tracing_data', $this->ipTracer->getIpLocationData($this->requestStack->getMasterRequest()->getClientIp(), $user->getLocale()))->setTemplateSource(sprintf('AppBundle:Email/AuthAttempt:%s', (string) $templateName));
     $this->eventDispatcher->dispatch($eventName, $event);
 }