2019-10-01 22:42:35 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2019-10-01 22:42:35 +03:00
|
|
|
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' => [
|
2019-11-25 01:32:37 +03:00
|
|
|
'Provided slug "foo" is already in use.',
|
2019-10-01 22:42:35 +03:00
|
|
|
'foo',
|
|
|
|
null,
|
|
|
|
];
|
|
|
|
yield 'with domain' => [
|
2019-11-25 01:32:37 +03:00
|
|
|
'Provided slug "baz" is already in use for domain "bar".',
|
2019-10-01 22:42:35 +03:00
|
|
|
'baz',
|
|
|
|
'bar',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|