Exemplo n.º 1
0
 /**
  * @param HHPnet\Core\Application\Services\Groups\SaveGroupRequest $request
  *
  * @return HHPnet\Core\Application\Services\Groups\SaveGroupResponse
  */
 public function execute(SaveGroupRequest $request)
 {
     try {
         $this->repository->getByGroupByName($request->name());
         throw new \DomainException('Given group has been registered in our database');
     } catch (\UnexpectedValueException $e) {
     }
     $group = $this->repository->save($this->factory->getGroupEntity(null, $request->name(), $request->country(), $request->bio()));
     return new SaveGroupResponse($group);
 }
Exemplo n.º 2
0
 /**
  * @param HHPnet\Core\Application\Services\Groups\SaveGroup\SaveGroupRequest $request
  * @param HHPnet\Core\Domain\Groups\Group                                    $group
  */
 public function it_is_possible_to_save_a_new_group(SaveGroupRequest $request, Group $group)
 {
     $request->name()->willReturn('name');
     $request->country()->willReturn('country');
     $request->bio()->willReturn('bio');
     $this->factory->getGroupEntity(null, 'name', 'country', 'bio')->willReturn($group);
     $this->repository->getByGroupByName('name')->willThrow('\\UnexpectedValueException');
     $this->repository->save($group)->willReturn($group);
     $this->execute($request)->shouldHaveType('HHPnet\\Core\\Application\\Services\\Groups\\SaveGroup\\SaveGroupResponse');
 }
Exemplo n.º 3
0
 /**
  * @param HHPnet\Core\Application\Services\Groups\GetGroup\GetGroupRequest $request
  */
 public function it_is_not_possible_to_get_a_non_existing_group(GetGroupRequest $request)
 {
     $request->groupId()->willReturn(1);
     $this->repository->getById(1)->willThrow('\\UnexpectedValueException');
     $this->shouldThrow('\\UnexpectedValueException')->during('execute', array($request));
 }
Exemplo n.º 4
0
 /**
  * @param HHPnet\Core\Application\Services\Groups\GetGroupRequest $request
  *
  * @return HHPnet\Core\Application\Services\Groups\GetGroupResponse
  */
 public function execute(GetGroupRequest $request)
 {
     return new GetGroupResponse($this->repository->getById($request->groupId()));
 }