Passed
Pull Request — master (#588)
by Alejandro
03:34
created

TagConflictExceptionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

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
        $this->assertEquals($expectedMessage, $e->getMessage());
23
        $this->assertEquals($expectedMessage, $e->getDetail());
24
        $this->assertEquals('Tag conflict', $e->getTitle());
25
        $this->assertEquals('TAG_CONFLICT', $e->getType());
26
        $this->assertEquals(['oldName' => $oldName, 'newName' => $newName], $e->getAdditionalData());
27
        $this->assertEquals(409, $e->getStatus());
28
    }
29
}
30