示例#1
0
 /**
  * @param HHPnet\Core\Application\Services\Albums\SaveAlbumRequest $request
  *
  * @return HHPnet\Core\Application\Services\Albums\SaveAlbumResponse
  */
 public function execute(SaveAlbumRequest $request)
 {
     try {
         $this->repository->getAlbumByName($request->groupId(), $request->name());
         throw new \DomainException('Given album has been registered in our database');
     } catch (\UnexpectedValueException $e) {
     }
     $album = $this->repository->save($this->factory->getAlbumEntity(null, $request->groupId(), $request->name(), $request->description(), $request->releaseYear()));
     return new SaveAlbumResponse($album);
 }
示例#2
0
 /**
  * @param HHPnet\Core\Application\Services\Albums\SaveAlbum\SaveAlbumRequest $request
  * @param HHPnet\Core\Domain\Groups\GroupId                                  $group_id
  */
 public function it_is_not_possible_to_register_a_given_album_twice(SaveAlbumRequest $request, GroupId $group_id)
 {
     $request->groupId()->willReturn($group_id);
     $request->name()->willReturn('name');
     $request->description()->willReturn('description');
     $request->releaseYear()->willReturn(2001);
     $this->factory->getAlbumEntity(null, $group_id, 'name', 'description', 2001)->willReturn(true);
     $this->shouldThrow('\\DomainException')->during('execute', array($request));
 }