public function testRemoveActivationKey()
 {
     $user = new User();
     $user->setActivationKey('any long api key');
     $user->setState(User::STATE_APPROVED);
     $this->assertEmpty($user->getActivationKey());
     $this->assertSame(User::STATE_APPROVED, $user->getState());
 }
 /**
  * {@inheritdoc}
  */
 public function checkApprovalByUser(User $user)
 {
     if (!$this->lookupKeyInRedisDatabase($user->getActivationKey())) {
         // the associated model will be loaded through lazy loading (doctrine sends a call to the db using a proxy for the model).
         // this is because the model representing parts of the approval process must be hydrated through
         // doctrine's complex hydration algorithm. In case of issues with redis, this data can be used
         // as backup, but the hydration of one-to-one relations is slow, so redis will be used by default.
         return !$user->getPendingActivation()->isActivationExpired();
     }
     return true;
 }