/**
  * @Given there's an activation key stored in redis
  */
 public function thereSAnActivationKeyStoredInRedis()
 {
     /** @var \AppBundle\Model\User\Registration\Generator\ActivationKeyCodeGeneratorInterface $key */
     $key = $this->getContainer()->get('app.user.registration.activation_key_generator')->generate();
     $activation = new PendingActivation();
     $activation->setActivationDate(new \DateTime());
     $user = User::create('Ma27-2', '123456', '*****@*****.**');
     $user->setPendingActivation($activation);
     $user->setActivationKey($key);
     $this->getEntityManager()->persist($user);
     $this->getEntityManager()->flush();
     $this->getContainer()->get('app.redis.cluster.approval')->attachNewApproval($key);
     $this->key = $key;
 }
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage Missing activation date!
  */
 public function testNoActivationDateIsGiven()
 {
     $model = new PendingActivation();
     $model->isActivationExpired();
 }
Example #3
0
 /**
  * Set state.
  *
  * @param string $state
  *
  * @return User
  */
 public function setState($state)
 {
     if (!in_array($state, [self::STATE_NEW, self::STATE_APPROVED])) {
         throw new \InvalidArgumentException(sprintf('Invalid state!'));
     }
     $this->state = (string) $state;
     if (self::STATE_APPROVED === $this->state) {
         $this->removeActivationKey();
     } else {
         $this->pendingActivation = new PendingActivation();
         $this->pendingActivation->setActivationDate($this->getRegistrationDate());
     }
     return $this;
 }
Example #4
0
 /**
  * Set activationKey.
  *
  * @param string $activationKey
  *
  * @return User
  */
 public function storeUniqueActivationKeyForNonApprovedUser(string $activationKey) : self
 {
     if (self::STATE_APPROVED === $this->state || self::STATE_LOCKED === $this->state) {
         throw new \LogicException('Approved users cannot have an activation key!');
     }
     $this->pendingActivation->setKey($activationKey);
     return $this;
 }
 public function testIsNonExpiredRegistration()
 {
     $model = new PendingActivation(new \DateTime());
     $this->assertFalse($model->isActivationExpired());
 }