/** * @param HHPnet\Core\Application\Services\Videos\SaveVideo\SaveVideoRequest $request * * @return HHPnet\Core\Application\Services\Videos\SaveVideo\SaveVideoResponse */ public function execute(SaveVideoRequest $request) { try { $this->repository->getByVideoServiceId($request->videoServiceId(), $request->videoService()); throw new \DomainException('Given video has been registered in our database'); } catch (\UnexpectedValueException $e) { } $video = $this->repository->save($this->factory->getVideoEntity(null, $request->videoServiceId(), $request->videoService(), $request->title(), $request->description())); return new SaveVideoResponse($video); }
/** * @param HHPnet\Core\Application\Services\Videos\GetVideo\GetVideoRequest $request */ public function it_is_not_possible_to_get_a_non_existing_video(GetVideoRequest $request) { $request->videoId()->willReturn(1); $this->repository->getById(1)->willThrow('\\UnexpectedValueException'); $this->shouldThrow('\\UnexpectedValueException')->during('execute', array($request)); }
/** * @param HHPnet\Core\Application\Services\Videos\GetVideo\GetVideoRequest $request * * @return HHPnet\Core\Application\Services\Videos\GetVideo\GetVideoResponse */ public function execute(GetVideoRequest $request) { return new GetVideoResponse($this->repository->getById($request->videoId())); }