Exemple #1
0
 /**
  * Handles the given command.
  *
  * @param LogInUserCommand $aCommand The command
  *
  * @throws UserDoesNotExistException when the user does not exist
  */
 public function __invoke(LogInUserCommand $aCommand)
 {
     $user = $this->repository->userOfEmail(new UserEmail($aCommand->email()));
     if (null === $user) {
         throw new UserDoesNotExistException();
     }
     $user->login($aCommand->password(), $this->encoder);
     $this->repository->persist($user);
 }
Exemple #2
0
 function it_logs_the_user_in(LogInUserCommand $command, UserRepository $repository, User $user)
 {
     $encoder = new DummyUserPasswordEncoder('encodedPassword');
     $command->email()->shouldBeCalled()->willReturn('*****@*****.**');
     $command->password()->shouldBeCalled()->willReturn('plainPassword');
     $user->login('plainPassword', $encoder)->shouldBeCalled();
     $repository->userOfEmail(new UserEmail('*****@*****.**'))->shouldBeCalled()->willReturn($user);
     $repository->persist($user)->shouldBeCalled();
     $this->__invoke($command);
 }