Beispiel #1
0
 /**
  * @param HHPnet\Core\Application\Services\Groups\SaveGroup\SaveGroupRequest $request
  */
 public function it_is_not_possible_to_register_a_given_group_twice(SaveGroupRequest $request)
 {
     $request->name()->willReturn('name');
     $request->country()->willReturn('country');
     $request->bio()->willReturn('bio');
     $this->factory->getGroupEntity(null, 'name', 'country', 'bio')->willReturn(true);
     $this->shouldThrow('\\DomainException')->during('execute', array($request));
 }
Beispiel #2
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);
 }