public function test_it_returns_shortened_url_for_shortened_url_suffix()
 {
     $shortenedUrlSuffix = $this->getMockShortenedUrlSuffix(1, 11);
     $shortenedUrl = $this->getMockShortenedUrl();
     $this->urlCallRepo->shouldReceive('getCallCountForSuffix')->with(1)->andReturn(2);
     $this->urlCallRepo->shouldReceive('getCallCountForOriginalUrl')->with(11)->andReturn(3);
     $this->shortenedUrlFactory->shouldReceive('create')->withArgs([$shortenedUrlSuffix, 2, 3])->andReturn($shortenedUrl);
     $this->service->getBySuffix($shortenedUrlSuffix);
 }
 /**
  * @param string $url
  * @return string
  */
 public function create($url)
 {
     $newUrlSuffix = $this->getShortened($url);
     $originalUrlEntity = $this->getOriginalUrlEntity($this->urlEncoder->encode($url));
     $shortenedUrlSuffixEntity = $this->shortenedUrlSuffixFactory->create($originalUrlEntity, $newUrlSuffix);
     $this->entityManager->persist($shortenedUrlSuffixEntity);
     $this->entityManager->flush();
     $shortenedUrl = $this->getShortenedUrlsService->getBySuffix($shortenedUrlSuffixEntity);
     return $shortenedUrl;
 }