예제 #1
0
 /**
  * @param LoginUserRequest $request
  *
  * @return LoginUserResponse
  */
 public function execute(LoginUserRequest $request)
 {
     $user = $this->repository->getByUsername($request->username());
     if (false === $user->isValidPassword($request->password())) {
         throw new \InvalidArgumentException('Invalid password');
     }
     return new LoginUserResponse($user);
 }
예제 #2
0
 /**
  * @param HHPnet\Core\Application\Services\Users\SignUpUser\SignUpUserRequest $request
  */
 public function it_is_not_possible_to_register_a_given_user_twice(SignUpUserRequest $request)
 {
     $request->username()->willReturn('test');
     $request->password()->willReturn('test');
     $request->email()->willReturn('test');
     $this->repository->getByEmail('test')->willReturn(true);
     $this->shouldThrow('\\DomainException')->during('execute', array($request));
 }
예제 #3
0
 /**
  * @param SignUpUserRequest $request
  *
  * @return SignUpUserResponse
  */
 public function execute(SignUpUserRequest $request)
 {
     try {
         $this->repository->getByEmail($request->email());
         throw new \DomainException('Given email has been found in database and can not be registered');
     } catch (\UnexpectedValueException $e) {
     }
     $save_user_result = $this->repository->save($this->factory->getUserEntity($this->repository->nextIdentity(), $request->username(), $request->password(), $request->email()));
     return new SignUpUserResponse($save_user_result);
 }
예제 #4
0
 /**
  * @param HHPnet\Core\Domain\Users\UserRepositoryInterface $repository
  * @param HHPnet\Core\Domain\Users\User                    $user
  */
 public function let(UserRepositoryInterface $repository, User $user)
 {
     $this->user = $user;
     $repository->getByUsername(Argument::any())->willReturn($this->user);
     $this->beConstructedWith($repository);
 }