function it_cannot_send_token_when_email_was_not_valid(ConfirmationSubjectInterface $subject, TokenProviderInterface $tokenProvider)
 {
     $tokenProvider->generateUniqueToken()->shouldBeCalled()->willReturn('foobar');
     $subject->setConfirmationType('email')->shouldBeCalled();
     $subject->confirmationRequest('foobar')->shouldBeCalled();
     $subject->getConfirmationChannel('customer.email')->shouldBeCalled()->willReturn('a_invalid_email');
     $this->shouldThrow('DoS\\UserBundle\\Confirmation\\Exception\\NotFoundChannelException')->duringSend($subject);
 }
 /**
  * {@inheritdoc}
  */
 protected function sendToken(ConfirmationSubjectInterface $subject, $token)
 {
     $email = $subject->getConfirmationChannel($this->options['channel_path']);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new NotFoundChannelException();
     }
     $this->sender->send($this->options['token_send_template'], array($email), array('subject' => $subject, 'token' => $token));
 }
 /**
  * @param ConfirmationSubjectInterface $subject
  *
  * @return \DoS\UserBundle\Model\OneTimePasswordInterface
  */
 protected function findOtp(ConfirmationSubjectInterface $subject)
 {
     $er = $this->manager->getRepository($this->options['otp_class']);
     return $er->findOneBy(array('subject' => $subject, 'token' => $subject->getConfirmationToken()));
 }
 /**
  * {@inheritdoc}
  */
 public function canResend(ConfirmationSubjectInterface $subject)
 {
     if ($subject->isConfirmationConfirmed()) {
         throw new ConfirmationException('ui.trans.user.confirmation.resend.confirmed');
     }
     if (null === ($timeAware = $this->options['token_resend_time_aware'])) {
         return true;
     }
     if (!($time = $subject->getConfirmationRequestedAt())) {
         return true;
     }
     $time->add(\DateInterval::createFromDateString($timeAware));
     $valid = $time->getTimestamp() <= (new \DateTime())->getTimestamp();
     if (false === $valid) {
         $exception = new InvalidTokenResendTimeException('ui.trans.user.confirmation.invalid_time');
         $exception->setTime($time);
         $exception->setTimeAware($timeAware);
         throw $exception;
     }
     return $valid;
 }