mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Test error when short URLs cannot be resolved
This commit is contained in:
parent
c597738915
commit
8d1776af98
@ -59,7 +59,7 @@ class ShortUrlResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
|
||||
public function exceptionIsThrownIfShortcodeIsNotFound(?ApiKey $apiKey): void
|
||||
public function exceptionIsThrownIfShortCodeIsNotFound(?ApiKey $apiKey): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$identifier = ShortUrlIdentifier::fromShortCodeAndDomain($shortCode);
|
||||
@ -73,7 +73,7 @@ class ShortUrlResolverTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function shortCodeToEnabledShortUrlProperlyParsesShortCode(): void
|
||||
public function resolveEnabledShortUrlProperlyParsesShortCode(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl('https://expected_url');
|
||||
$shortCode = $shortUrl->getShortCode();
|
||||
@ -89,8 +89,30 @@ class ShortUrlResolverTest extends TestCase
|
||||
self::assertSame($shortUrl, $result);
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideResolutionMethods')]
|
||||
public function resolutionThrowsExceptionIfUrlIsNotEnabled(string $method): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
|
||||
$this->repo->expects($this->once())->method('findOneWithDomainFallback')->with(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
|
||||
ShortUrlMode::STRICT,
|
||||
)->willReturn(null);
|
||||
$this->em->expects($this->once())->method('getRepository')->with(ShortUrl::class)->willReturn($this->repo);
|
||||
|
||||
$this->expectException(ShortUrlNotFoundException::class);
|
||||
|
||||
$this->urlResolver->{$method}(ShortUrlIdentifier::fromShortCodeAndDomain($shortCode));
|
||||
}
|
||||
|
||||
public static function provideResolutionMethods(): iterable
|
||||
{
|
||||
yield 'resolveEnabledShortUrl' => ['resolveEnabledShortUrl'];
|
||||
yield 'resolvePublicShortUrl' => ['resolvePublicShortUrl'];
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideDisabledShortUrls')]
|
||||
public function shortCodeToEnabledShortUrlThrowsExceptionIfUrlIsNotEnabled(ShortUrl $shortUrl): void
|
||||
public function resolveEnabledShortUrlThrowsExceptionIfUrlIsNotEnabled(ShortUrl $shortUrl): void
|
||||
{
|
||||
$shortCode = $shortUrl->getShortCode();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user