/**
  * @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;
 }
 public function test_it_creates_and_returns_new_shortened_url_suffix_entity()
 {
     $encodedLink = "http%3A%2F%2Fsome-domain%2Fsome-resource-address";
     $originalUrl = m::mock('AppBundle\\Entity\\OriginalUrl', ['getEncodedLink' => $encodedLink]);
     $newUrlSuffixString = "shortString";
     $result = $this->factory->create($originalUrl, $newUrlSuffixString);
     $this->assertInstanceOf('AppBundle\\Entity\\ShortenedUrlSuffix', $result);
     $this->assertEquals($encodedLink, $result->getOriginalUrlEncodedLink());
     $this->assertEquals($newUrlSuffixString, $result->getSuffixString());
     $this->assertNotEmpty($result->getDateCreated());
 }