Example #1
0
 /**
  * @param int $id
  *
  * @return User
  */
 protected function resolveData($id)
 {
     if (!is_null($id)) {
         return $this->getDoctrine()->getRepository('ClasticUserBundle:User')->find($id);
     }
     $user = new User();
     $user->setPlainPassword(rand());
     return $user;
 }
 public function testEmail()
 {
     $securityContext = $this->getMockBuilder(TokenStorage::class)->disableOriginalConstructor()->getMock();
     $user = new User();
     $user->setEmail('*****@*****.**');
     $token = $this->getMockBuilder(UsernamePasswordToken::class)->disableOriginalConstructor()->getMock();
     $token->expects($this->once())->method('getUser')->willReturn($user);
     $securityContext->expects($this->once())->method('getToken')->willReturn($token);
     $extension = new AvatarExtension($securityContext);
     $this->assertEquals('*****@*****.**', $extension->getUserEmail());
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->addRole('ROLE_SUPER_ADMIN');
     $userAdmin->setPlainPassword('secret');
     $userAdmin->setEnabled(true);
     $userManager = $this->container->get('fos_user.user_manager');
     $userManager->updateUser($userAdmin);
     $manager->persist($userAdmin);
     $manager->flush();
     $this->addReference('admin-user', $userAdmin);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $demoUser = new User();
     $demoUser->setUsername('demo');
     $demoUser->setEmail('*****@*****.**');
     $demoUser->addRole('ROLE_ADMIN');
     $demoUser->setPlainPassword('demo');
     $demoUser->setEnabled(true);
     $userManager = $this->container->get('fos_user.user_manager');
     $userManager->updateUser($demoUser);
     $manager->persist($demoUser);
     $manager->flush();
     $this->addReference('user-demo', $demoUser);
 }