/**
  * @expectedException \Ma27\ApiKeyAuthenticationBundle\Exception\CredentialException
  * @expectedExceptionMessage BACKEND_AUTH_NON_APPROVED
  */
 public function testUserIsNonApprovedAndLocked()
 {
     $user = new User();
     $user->lock();
     $hook = new IncompleteUserCheckListener();
     $hook->validateUserOnAuthentication(new OnAuthenticationEvent($user));
 }
Exemplo n.º 2
0
 public function testLockUnlock()
 {
     $user = new User();
     $this->assertFalse($user->isLocked());
     $user->lock();
     $this->assertTrue($user->isLocked());
     $user->unlock();
     $this->assertFalse($user->isLocked());
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /* @var \Doctrine\ORM\EntityManager $manager */
     $this->checkEntityManager($manager);
     $passwordHasher = new PhpPasswordHasher();
     $userRole = $manager->getRepository('Account:Role')->findOneBy(['role' => 'ROLE_USER']);
     $user1 = new User();
     $user1->setState(User::STATE_APPROVED);
     $user1->setUsername('Ma27');
     $user1->setPassword($passwordHasher->generateHash('72aM'));
     $user1->setEmail('*****@*****.**');
     $user1->addRole($userRole);
     $user1->setLastAction(new \DateTime());
     $user1->setLocale('de');
     $user2 = new User();
     $user2->setState(User::STATE_APPROVED);
     $user2->setUsername('benbieler');
     $user2->setPassword($passwordHasher->generateHash('releibneb'));
     $user2->setEmail('*****@*****.**');
     $user2->addRole($userRole);
     $user2->setLastAction(new \DateTime());
     $locked = new User();
     $locked->setState(User::STATE_APPROVED);
     $locked->setUsername('anonymus');
     $locked->setPassword($passwordHasher->generateHash('sumynona'));
     $locked->setEmail('*****@*****.**');
     $locked->addRole($userRole);
     $locked->lock();
     $locked->setLastAction(new \DateTime());
     $user2->addFollowing($user1);
     $user1->addFollowing($user2);
     $user1->addFollowing($manager->getRepository('Account:User')->findOneBy(['username' => 'admin']));
     /** @var User $userModel */
     foreach ([$user1, $user2, $locked] as $userModel) {
         $manager->persist($userModel);
     }
     $manager->flush();
 }