Passed
Pull Request — master (#567)
by Alejandro
03:47
created

tagIsProperlyRenamedWhenRenamingToItself()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioApiTest\Shlink\Rest\Action;
6
7
use GuzzleHttp\RequestOptions;
8
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
9
10
class UpdateTagActionTest extends ApiTestCase
11
{
12
    /** @test */
13
    public function errorIsThrownWhenTryingToRenameTagToAnotherTagName(): void
14
    {
15
        $resp = $this->callApiWithKey(self::METHOD_PUT, '/tags', [RequestOptions::JSON => [
16
            'oldName' => 'foo',
17
            'newName' => 'bar',
18
        ]]);
19
        $payload = $this->getJsonResponsePayload($resp);
20
21
        $this->assertEquals(self::STATUS_CONFLICT, $resp->getStatusCode());
22
        $this->assertEquals('TAG_CONFLICT', $payload['error']);
23
    }
24
25
    /** @test */
26
    public function tagIsProperlyRenamedWhenRenamingToItself(): void
27
    {
28
        $resp = $this->callApiWithKey(self::METHOD_PUT, '/tags', [RequestOptions::JSON => [
29
            'oldName' => 'foo',
30
            'newName' => 'foo',
31
        ]]);
32
33
        $this->assertEquals(self::STATUS_NO_CONTENT, $resp->getStatusCode());
34
    }
35
}
36