public function it_can_be_executed_and_derive_display_name(InputInterface $input, OutputInterface $output) { $email = '*****@*****.**'; $pass = '******'; $input->getArgument('email-address')->willReturn($email); $input->getArgument('password')->willReturn($pass); $input->getArgument('display-name')->willReturn(''); $this->authenticationService->createUser(EmailAddress::get($email), $pass, 'joe'); $this->execute($input, $output); }
public function executeRequest(RequestInterface $request) : ResponseInterface { try { $token = $this->authenticationService->login($request['email_address'], $request['password']); return new Response(self::MESSAGE, ['token' => $token->getUuid()->toString(), 'pass_code' => $token->getPassCode(), 'expires' => $token->getExpires()->format('Y-m-d H:i:s')], $request); } catch (AuthException $exception) { return new Response($exception->getMessage(), [], $request); } catch (\Throwable $exception) { $this->log(LogLevel::ERROR, $exception->getMessage()); throw new ResponseException('An error occurred during LoginHandler.', new ServerErrorResponse([], $request)); } }
public function it_can_handle_errors_when_executing_a_request(RequestInterface $request) { $emailAddress = '*****@*****.**'; $password = '******'; $request->getAcceptContentType()->willReturn('*/*'); $request->offsetGet('email_address')->willReturn($emailAddress); $request->offsetGet('password')->willReturn($password); $this->authenticationService->login($emailAddress, $password)->willThrow(new \RuntimeException()); $this->shouldThrow(ResponseException::class)->duringExecuteRequest($request); }
public function execute(InputInterface $input, OutputInterface $output) { $this->authenticationService->createUser(EmailAddress::get($input->getArgument('email-address')), $input->getArgument('password'), $this->getDisplayName($input->getArgument('display-name'), $input->getArgument('email-address'))); }