public function testFindOneByHash() { $activationLink = $this->manager->findOneByHash('test-hash'); $this->assertInstanceOf(ActivationLink::class, $activationLink); $this->assertEquals(1, $activationLink->getId()); $this->assertEquals('test-hash', $activationLink->getHash()); $this->assertInstanceOf(\DateTime::class, $activationLink->getCreatedAt()); }
/** * @param string $email * @throws \Symfony\Component\Security\Core\Exception\UsernameNotFoundException * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @return bool */ public function sendNewActivationLink($email) { if (($user = $this->findUserByUsernameOrEmail($email)) === null) { throw new UsernameNotFoundException(); } if ($user->isEnabled()) { throw new BadRequestHttpException('users.activation_link.user_already_enabled'); } if (($activationLink = $user->getActivationLink()) !== null) { $user->setActivationLink(null); $this->em->persist($user); $this->em->remove($activationLink); $this->em->flush(); } $this->activationLinkManager->createActivationLink($user); $this->activationLinkManager->sendValidationMail($user); return true; }