Пример #1
0
 public function testHandle()
 {
     $userService = $this->mockService->getUserService();
     $dtoBuilderFactory = $this->getDTOBuilderFactory();
     $request = new GetUserRequest(self::UUID_HEX);
     $response = new GetUserResponse();
     $handler = new GetUserHandler($userService, $dtoBuilderFactory);
     $handler->handle(new GetUserQuery($request, $response));
     $this->assertTrue($response->getUserDTO() instanceof UserDTO);
     $handler->handle(new GetUserQuery($request, $response));
     $this->assertTrue($response->getUserDTOWithRolesAndTokens() instanceof UserDTO);
 }
 /**
  * @param OrderAddressDTO $orderAddress
  * @return UserDTO
  */
 protected function getOrCreateUserFromOrderAddress(OrderAddressDTO $orderAddress)
 {
     try {
         $request = new GetUserByEmailRequest($orderAddress->email);
         $response = new GetUserByEmailResponse();
         $this->dispatchQuery(new GetUserByEmailQuery($request, $response));
         return $response->getUserDTO();
     } catch (EntityNotFoundException $e) {
         $user = new UserDTO();
         $user->firstName = $orderAddress->firstName;
         $user->lastName = $orderAddress->lastName;
         $user->email = $orderAddress->email;
         $createUserCommand = new CreateUserCommand($user);
         $this->dispatch($createUserCommand);
         $userId = $createUserCommand->getUserId();
         $request = new GetUserRequest($userId);
         $response = new GetUserResponse();
         $this->dispatchQuery(new GetUserQuery($request, $response));
         return $response->getUserDTO();
     }
 }