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

properlyCreatesExceptionFromNotFoundTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.9332
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