public function testCreateInstitutionInvitation()
 {
     $invitation = new InstitutionInvitation();
     $invitation->setEmail('*****@*****.**');
     $invitation->setName('alnie jacobe');
     $institutionInvitation = $this->service->sendInstitutionInvitation($invitation);
     $this->assertNotEmpty($institutionInvitation);
     return $institutionInvitation;
 }
 public function sendInstitutionInvitation(InstitutionInvitation $invitation)
 {
     //generate token
     $token = $this->createInvitationToken(0);
     //create message
     $messageBody = $this->twig->render('InstitutionBundle:Email:institutionInvitation.html.twig', array('name' => $invitation->getName(), 'expirationDate' => $token->getExpirationDate(), 'email' => $invitation->getEmail(), 'token' => $token->getToken()));
     $message = \Swift_Message::newInstance()->setSubject('Activate your account with HealthCareAbroad')->setFrom('*****@*****.**')->setTo($invitation->getEmail())->setBody($messageBody);
     $sendResult = $this->mailer->send($message);
     $invitation->setMessage($message);
     $invitation->setInvitationToken($token);
     $invitation->setStatus(1);
     $em = $this->doctrine->getEntityManager();
     $em->persist($invitation);
     $em->flush();
     return $sendResult;
 }