TagConflictExceptionTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 10
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A properlyCreatesExceptionFromNotFoundTag() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Rest\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Core\Exception\TagConflictException;
9
10
use function sprintf;
11
12
class TagConflictExceptionTest extends TestCase
13
{
14
    /** @test */
15
    public function properlyCreatesExceptionFromNotFoundTag(): void
16
    {
17
        $oldName = 'foo';
18
        $newName = 'bar';
19
        $expectedMessage = sprintf('You cannot rename tag %s to %s, because it already exists', $oldName, $newName);
20
        $e = TagConflictException::fromExistingTag($oldName, $newName);
21
22
        self::assertEquals($expectedMessage, $e->getMessage());
23
        self::assertEquals($expectedMessage, $e->getDetail());
24
        self::assertEquals('Tag conflict', $e->getTitle());
25
        self::assertEquals('TAG_CONFLICT', $e->getType());
26
        self::assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
27
        self::assertEquals(409, $e->getStatus());
28
    }
29
}
30