Exemplo n.º 1
0
 public function testFollower()
 {
     $user = new User();
     $user->setUsername('Ma27');
     $following = new User();
     $following->setUsername('benbieler');
     $user->addFollowing($following);
     $this->assertTrue($user->follows($following));
     $this->assertCount(1, $user->getFollowing());
     $user->removeFollowing($following);
     $this->assertFalse($user->follows($following));
     $this->assertCount(0, $user->getFollowing());
 }
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /* @var \Doctrine\ORM\EntityManager $manager */
     $this->checkEntityManager($manager);
     $passwordHasher = new PhpPasswordHasher();
     $roleRepository = $manager->getRepository('Account:Role');
     $userRole = $roleRepository->findOneBy(['role' => 'ROLE_USER']);
     $adminRole = $roleRepository->findOneBy(['role' => 'ROLE_ADMIN']);
     $admin = new User();
     $admin->setState(User::STATE_APPROVED);
     $admin->setUsername('admin');
     $admin->setPassword($passwordHasher->generateHash('123456'));
     $admin->setEmail('*****@*****.**');
     $admin->addRole($adminRole);
     $admin->addRole($userRole);
     $admin->setLastAction(new \DateTime());
     $manager->persist($admin);
     $manager->flush();
 }
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();
 }