/** * @param string $urlSuffixString * @return string * @throws GetRedirectUrlException */ public function get($urlSuffixString) { $shortenedUrlSuffix = $this->shortenedUrlSuffixRepo->findBySuffix($urlSuffixString); if (null === $shortenedUrlSuffix) { throw new GetRedirectUrlException("Url does not exist"); } $this->registerUrlCallService->register($shortenedUrlSuffix); return $this->urlEncoder->decode($shortenedUrlSuffix->getOriginalUrlEncodedLink()); }
public function test_it_creates_and_persists_new_url_call_entity() { $shortenedUrlSuffix = m::mock('AppBundle\\Entity\\ShortenedUrlSuffix'); $urlCall = m::mock('AppBundle\\Entity\\UrlCall'); $this->urlCallFactory->shouldReceive('create')->with($shortenedUrlSuffix)->andReturn($urlCall); $this->entityManager->shouldReceive('persist')->with($urlCall); $this->entityManager->shouldReceive('flush')->withNoArgs(); $this->service->register($shortenedUrlSuffix); }