mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-06 22:23:54 -06:00
39 lines
968 B
PHP
39 lines
968 B
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace ShlinkioTest\Shlink\Core\Exception;
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
||
|
|
||
|
class ShortUrlNotFoundExceptionTest extends TestCase
|
||
|
{
|
||
|
/**
|
||
|
* @test
|
||
|
* @dataProvider provideMessages
|
||
|
*/
|
||
|
public function properlyCreatesExceptionFromNotFoundShortCode(
|
||
|
string $expectedMessage,
|
||
|
string $shortCode,
|
||
|
?string $domain
|
||
|
): void {
|
||
|
$e = ShortUrlNotFoundException::fromNotFoundShortCode($shortCode, $domain);
|
||
|
$this->assertEquals($expectedMessage, $e->getMessage());
|
||
|
}
|
||
|
|
||
|
public function provideMessages(): iterable
|
||
|
{
|
||
|
yield 'without domain' => [
|
||
|
'No URL found with short code "abc123"',
|
||
|
'abc123',
|
||
|
null,
|
||
|
];
|
||
|
yield 'with domain' => [
|
||
|
'No URL found with short code "bar" for domain "foo"',
|
||
|
'bar',
|
||
|
'foo',
|
||
|
];
|
||
|
}
|
||
|
}
|