mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Improved tag conflict docs and tests
This commit is contained in:
parent
a070a68a57
commit
e5f262869c
2 changed files with 39 additions and 0 deletions
|
@ -229,6 +229,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "The name provided in newName param is already in use for another tag.",
|
||||
"content": {
|
||||
"application/problem+json": {
|
||||
"schema": {
|
||||
"$ref": "../definitions/Error.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Unexpected error.",
|
||||
"content": {
|
||||
|
|
29
module/Core/test/Exception/TagConflictExceptionTest.php
Normal file
29
module/Core/test/Exception/TagConflictExceptionTest.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Rest\Exception;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Exception\TagConflictException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class TagConflictExceptionTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function properlyCreatesExceptionFromNotFoundTag(): 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);
|
||||
|
||||
$this->assertEquals($expectedMessage, $e->getMessage());
|
||||
$this->assertEquals($expectedMessage, $e->getDetail());
|
||||
$this->assertEquals('Tag conflict', $e->getTitle());
|
||||
$this->assertEquals('TAG_CONFLICT', $e->getType());
|
||||
$this->assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
|
||||
$this->assertEquals(409, $e->getStatus());
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue