示例#1
0
 public function testVerifyEmail()
 {
     $userManager = new UserManager($this->encoderFactoryMock, CustomUser::class);
     $user = new User();
     $this->assertFalse($user->getEmailVerified(), 'Email is not verified at beginning.');
     $userManager->initEmailVerification($user);
     $token = $user->getEmailVerificationToken();
     $resultWrong = $userManager->verifyEmail($user, 'wrong-token');
     $this->assertFalse($resultWrong, 'Cannot verify email on wrong token.');
     $this->assertFalse($user->getEmailVerified(), 'Email is not verified after wrong token.');
     $result = $userManager->verifyEmail($user, $token);
     $this->assertTrue($result, 'Returns true on success.');
     $this->assertTrue($user->getEmailVerified(), 'Email is flagged as verified.');
     $this->assertNull($user->getEmailVerificationToken(), 'Token is reset to null after verification.');
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function initEmailVerification(User $user)
 {
     $this->userManager->initEmailVerification($user);
     $this->userRepository->updateUser($user);
 }