Ejemplo n.º 1
0
 public function testFindEmailLinkThrowsWhenExpired()
 {
     $this->setExpectedException('Del\\Exception\\EmailLinkException', EmailLinkException::LINK_EXPIRED);
     $user = $this->svc->createFromArray($this->getUserArray('testFindEmailLinkThrowsWhenExpired'));
     $this->user = $this->svc->saveUser($user);
     $this->link = $this->svc->generateEmailLink($this->user, -8);
     $token = $this->link->getToken();
     $this->svc->findEmailLink($user->getEmail(), $token);
 }
Ejemplo n.º 2
0
 /**
  * @param User $user
  * @param int $expiry_days
  * @return EmailLink
  */
 public function generateEmailLink(User $user, $expiry_days = 7)
 {
     $date = new DateTime();
     $date->modify('+' . $expiry_days . ' days');
     $token = md5(uniqid(rand(), true));
     $link = new EmailLink();
     $link->setUser($user);
     $link->setToken($token);
     $link->setExpiryDate($date);
     return $this->getEmailLinkRepository()->save($link);
 }
Ejemplo n.º 3
0
 public function testGetSetUser()
 {
     $dave = new User();
     $this->link->setUser($dave);
     $this->assertInstanceOf('Del\\Entity\\User', $this->link->getUser());
 }