mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-11 17:03:53 +03:00
34 lines
890 B
PHP
34 lines
890 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\Core\Exception;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
|
|
|
|
class NonUniqueSlugExceptionTest extends TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
* @dataProvider provideMessages
|
|
*/
|
|
public function properlyCreatesExceptionFromSlug(string $expectedMessage, string $slug, ?string $domain): void
|
|
{
|
|
$e = NonUniqueSlugException::fromSlug($slug, $domain);
|
|
$this->assertEquals($expectedMessage, $e->getMessage());
|
|
}
|
|
|
|
public function provideMessages(): iterable
|
|
{
|
|
yield 'without domain' => [
|
|
'Provided slug "foo" is not unique.',
|
|
'foo',
|
|
null,
|
|
];
|
|
yield 'with domain' => [
|
|
'Provided slug "baz" is not unique for domain "bar".',
|
|
'baz',
|
|
'bar',
|
|
];
|
|
}
|
|
}
|