mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated resolve short url action to return all data for that short url
This commit is contained in:
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
||||
namespace ShlinkioTest\Shlink\Core\Service;
|
||||
|
||||
use Cocur\Slugify\SlugifyInterface;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -37,10 +35,6 @@ class UrlShortenerTest extends TestCase
|
||||
* @var ObjectProphecy
|
||||
*/
|
||||
protected $httpClient;
|
||||
/**
|
||||
* @var Cache
|
||||
*/
|
||||
protected $cache;
|
||||
/**
|
||||
* @var ObjectProphecy
|
||||
*/
|
||||
@@ -66,7 +60,6 @@ class UrlShortenerTest extends TestCase
|
||||
$repo->findOneBy(Argument::any())->willReturn(null);
|
||||
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
|
||||
|
||||
$this->cache = new ArrayCache();
|
||||
$this->slugger = $this->prophesize(SlugifyInterface::class);
|
||||
|
||||
$this->setUrlShortener(false);
|
||||
@@ -80,7 +73,6 @@ class UrlShortenerTest extends TestCase
|
||||
$this->urlShortener = new UrlShortener(
|
||||
$this->httpClient->reveal(),
|
||||
$this->em->reveal(),
|
||||
$this->cache,
|
||||
$urlValidationEnabled,
|
||||
UrlShortener::DEFAULT_CHARS,
|
||||
$this->slugger->reveal()
|
||||
@@ -205,10 +197,8 @@ class UrlShortenerTest extends TestCase
|
||||
$repo->findOneByShortCode($shortCode)->willReturn($shortUrl);
|
||||
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
|
||||
|
||||
$this->assertFalse($this->cache->contains($shortCode . '_longUrl'));
|
||||
$url = $this->urlShortener->shortCodeToUrl($shortCode);
|
||||
$this->assertEquals($shortUrl->getOriginalUrl(), $url);
|
||||
$this->assertTrue($this->cache->contains($shortCode . '_longUrl'));
|
||||
$this->assertSame($shortUrl, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,18 +209,4 @@ class UrlShortenerTest extends TestCase
|
||||
{
|
||||
$this->urlShortener->shortCodeToUrl('&/(');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function cachedShortCodeDoesNotHitDatabase()
|
||||
{
|
||||
$shortCode = '12C1c';
|
||||
$expectedUrl = 'expected_url';
|
||||
$this->cache->save($shortCode . '_longUrl', $expectedUrl);
|
||||
$this->em->getRepository(ShortUrl::class)->willReturn(null)->shouldBeCalledTimes(0);
|
||||
|
||||
$url = $this->urlShortener->shortCodeToUrl($shortCode);
|
||||
$this->assertEquals($expectedUrl, $url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user