コード例 #1
0
 public function testKeyCode()
 {
     $value = new UserActivation();
     $value->buildKeyCode(new ActivationKeyCodeGenerator());
     $bareValue = $value->getKeyCode();
     $this->assertTrue($value->compareKeyCode($bareValue));
 }
コード例 #2
0
 public function testActivateUser()
 {
     DomainEvents::setEventDispatcher(new EventDispatcher());
     $generator = new ActivationKeyCodeGenerator();
     $activation = new UserActivation();
     $activation->buildKeyCode($generator);
     $user = User::fromDTO(new CreateUserDTO('Ma27', 'test-password', '*****@*****.**'), $activation);
     $userRepository = $this->getMock(UserRepositoryInterface::class);
     $userRepository->expects($this->once())->method('modify');
     $service = new UserService($userRepository, $generator);
     $service->activateUser($user, new ActivateUserDTO($activation->getKeyCode()));
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $role = new Role('ROLE_USER');
     $admin = new Role('ROLE_ADMIN');
     $manager->persist($role);
     $manager->persist($admin);
     $user1 = new User(new Credentials('admin', '^special_password^'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [], [$role, $admin]);
     $user2 = new User(new Credentials('Ma27', 'test-password'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [$user1], [$role]);
     $user3 = new User(new Credentials('test', '123456'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [$user1, $user2], [$role]);
     $user4 = new User(new Credentials('test2', '123456'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [], [$role]);
     $user4->lock();
     $user5 = new User(new Credentials('test3', '123456'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [$user3], [$role]);
     $user6 = new User(new Credentials('test4', '123456'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime()), [$user5, $user3, $user1], [$role]);
     $activation = new UserActivation();
     $activation->buildKeyCode(new ActivationKeyCodeGenerator());
     $user7 = new User(new Credentials('unactivated', 'foo'), new UserDetails('*****@*****.**', new \DateTime('-3 days'), new \DateTime()), [], [], $activation);
     foreach ([$user1, $user2, $user3, $user4, $user5, $user6, $user7] as $entity) {
         $manager->persist($entity);
     }
     $manager->flush();
 }
コード例 #4
0
 /**
  * @expectedException \Sententiaregum\User\Domain\Exception\ActivationException
  */
 public function testFollowUnactivatedUser()
 {
     $activation = new UserActivation();
     $activation->buildKeyCode(new ActivationKeyCodeGenerator());
     $unactivated = User::fromDTO(new CreateUserDTO('test', '123456', '*****@*****.**'), $activation);
     $user = User::fromDTO(new CreateUserDTO('test123', 'foobar', '*****@*****.**'));
     $user->follow($unactivated);
 }
コード例 #5
0
 /**
  * Creates a new user
  *
  * @param CreateUserDTO $newUserData
  *
  * @return User
  */
 public function createUser(CreateUserDTO $newUserData)
 {
     $activation = new UserActivation();
     $activation->buildKeyCode($this->activationKeyCodeGenerator);
     return $this->userRepository->add(User::fromDTO($newUserData, $activation));
 }