コード例 #1
0
 /**
  * @param User $user
  * @param bool $notifyUser
  * @return string
  */
 private function requestPasswordResetTokenByUser(User $user, $notifyUser = true)
 {
     $receiver = Receiver::fromUser($user);
     $token = $this->tokenManipulator->createResetPasswordToken($user);
     if ($notifyUser) {
         $url = $this->urlGenerator->generate('login_renew_password', ['token' => $token->getValue()], true);
         $mail = MailRequestPasswordUpdate::create($this->application, $receiver);
         $mail->setLogin($user->getLogin());
         $mail->setButtonUrl($url);
         $mail->setExpiration(new \DateTime('+1 day'));
         $this->mailer->deliver($mail);
     }
     return $token->getValue();
 }
コード例 #2
0
 /**
  * @covers Alchemy\Phrasea\Notification\Deliverer::deliver
  */
 public function testDeliverWithReplyToHeader()
 {
     $mail = $this->getMock('Alchemy\\Phrasea\\Notification\\Mail\\MailInterface');
     $name = 'replyto-name';
     $email = '*****@*****.**';
     $emitter = $this->getMock('Alchemy\\Phrasea\\Notification\\EmitterInterface');
     $emitter->expects($this->any())->method('getName')->will($this->returnValue($name));
     $emitter->expects($this->any())->method('getEmail')->will($this->returnValue($email));
     $mail->expects($this->any())->method('getEmitter')->will($this->returnValue($emitter));
     $mail->expects($this->any())->method('getReceiver')->will($this->returnValue($this->getReceiverMock()));
     $catchEmail = null;
     $mailer = $this->getMailerMock();
     $mailer->expects($this->once())->method('send')->will($this->returnCallback(function ($email) use(&$catchEmail) {
         $catchEmail = $email;
     }));
     $deliverer = new Deliverer($mailer, $this->getEventDispatcherMock(), $this->getEmitterMock());
     $deliverer->deliver($mail);
     /* @var $catchEmail \Swift_Message */
     $this->assertEquals([$email => $name], $catchEmail->getReplyTo());
 }