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);
 }
 /**
  * Sends the activation email.
  *
  * @param User $persistentUser
  */
 private function sendActivationEmail(User $persistentUser)
 {
     $mailerEvent = new MailerEvent();
     $mailerEvent->setTemplateSource('AppBundle:Email/Activation:activation')->addUser($persistentUser)->addParameter('activation_key', $persistentUser->getActivationKey())->addParameter('username', $persistentUser->getUsername());
     $this->eventDispatcher->dispatch(MailerEvent::EVENT_NAME, $mailerEvent);
 }