public function testGetUserUseCaseWillGetUserControllerReturnsUser()
 {
     $user = new User();
     $user->setFirstName('Wincenty')->setLastName('Kwiatek');
     $this->useCaseMock->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $this->assertSame($user, $this->controller->getUserAction(1));
 }
Exemplo n.º 2
0
 /**
  * @param User $user
  * @return void
  */
 public function removeUser(User $user)
 {
     if (!$this->repository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $this->repository->remove($user);
     $this->repository->synchronize();
 }
Exemplo n.º 3
0
 /**
  * @param User $user
  * @throws EditUserException
  *
  */
 private function validateUser(User $user)
 {
     if (!$this->repository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $violations = $this->validator->validate($user);
     if ($violations->count()) {
         throw new EditUserException($violations, 'Invalid User entity.');
     }
 }
Exemplo n.º 4
0
 public function testListUsers()
 {
     $user1 = new User();
     $user1->setFirstName('Wincenty')->setLastName('Kwiatek');
     $user2 = new User();
     $user2->setFirstName('Zenon')->setLastName('Majkowski');
     $expectedUsers = [$user1, $user2];
     $this->repositoryMock->expects($this->any())->method('search')->will($this->returnValue($expectedUsers));
     $this->assertSame($expectedUsers, $this->useCase->listUsers());
 }
 /**
  * @param PhoneNumber $number
  * @param User $user
  * @throws NotExistingUserException
  * @throws AddNumberToUserException
  */
 private function validateInput(PhoneNumber $number, User $user)
 {
     if (!$this->userRepository->findById($user->getId())) {
         throw new NotExistingUserException(sprintf('User with [id = %d] does not exist', $user->getId()));
     }
     $violations = $this->validator->validate($number);
     if ($violations->count()) {
         throw new AddNumberToUserException($violations);
     }
 }
 /**
  * @inheritDoc
  */
 public function findUserNumber(User $user, $numberId)
 {
     return $this->createQueryBuilder('pn')->where('pn.owner = :user_id')->andWhere('pn.id = :number_id')->setParameter('user_id', $user->getId(), \PDO::PARAM_INT)->setParameter('number_id', $numberId, \PDO::PARAM_INT)->getQuery()->getOneOrNullResult();
 }