Пример #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));
 }
Пример #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);
 }
Пример #3
0
 private function getGroupInstance($group_data)
 {
     if (is_null($group_data)) {
         throw new \UnexpectedValueException('Group not found in database');
     }
     return $this->factory->getGroupEntity($group_data['_id'], $group_data['name'], $group_data['country'], $group_data['bio']);
 }