Created value object to wrap the renaming of a tag

This commit is contained in:
Alejandro Celaya
2021-01-06 13:11:28 +01:00
parent 041f231ff2
commit b5710f87e2
10 changed files with 102 additions and 32 deletions

View File

@@ -2,22 +2,23 @@
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Rest\Exception;
namespace ShlinkioTest\Shlink\Core\Exception;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Exception\TagConflictException;
use Shlinkio\Shlink\Core\Tag\Model\TagRenaming;
use function sprintf;
class TagConflictExceptionTest extends TestCase
{
/** @test */
public function properlyCreatesExceptionFromNotFoundTag(): void
public function properlyCreatesExceptionForExistingTag(): void
{
$oldName = 'foo';
$newName = 'bar';
$expectedMessage = sprintf('You cannot rename tag %s to %s, because it already exists', $oldName, $newName);
$e = TagConflictException::fromExistingTag($oldName, $newName);
$e = TagConflictException::forExistingTag(TagRenaming::fromNames($oldName, $newName));
self::assertEquals($expectedMessage, $e->getMessage());
self::assertEquals($expectedMessage, $e->getDetail());