Пример #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\Albums\Album                                    $album
  * @param HHPnet\Core\Domain\Groups\GroupId                                  $group_id
  */
 public function it_is_possible_to_save_a_new_album(SaveAlbumRequest $request, Album $album, 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($album);
     $this->repository->getAlbumByName($group_id, 'name')->willThrow('\\UnexpectedValueException');
     $this->repository->save($album)->willReturn($album);
     $this->execute($request)->shouldHaveType('HHPnet\\Core\\Application\\Services\\Albums\\SaveAlbum\\SaveAlbumResponse');
 }