/** * Create a registration. * * @param Request $request * * @return Response */ public function doRegistration(Request $request) { try { $this->validator->isValidUserName(); $this->validator->isValidPassword(); $user = $this->userBuilder->getUser($request->getUserName(), $request->getPassword()); $userId = $this->userDao->create($user); return new Response('yes', '201', $userId); } catch (InvalidUserNameException $exception) { return new Response('no', '601', ''); } catch (InvalidPasswordException $exception) { return new Response('no', '602', ''); } catch (UserExistsException $exception) { return new Response('no', '701', ''); } catch (Exception $exception) { return new Response('no', '500', ''); } }
/** * User create test. * * @param User $user * @dataProvider providerCreateUser * @expectedException \Kata\Registration\UserExistsException */ public function testUserExistsException(User $user) { $this->userDao->create($user); }