/** * @param HHPnet\Core\Application\Services\Users\LoginUser\LoginUserRequest $request */ public function it_fails_when_given_credentials_are_invalid(LoginUserRequest $request) { $request->username()->willReturn('test'); $request->password()->willReturn('test'); $this->user->isValidPassword(Argument::any())->willReturn(false); $this->shouldThrow('\\InvalidArgumentException')->during('execute', array($request)); }
/** * @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); }