Passed
Pull Request — master (#554)
by Alejandro
05:37
created

EditShortUrlActionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tryingToEditInvalidUrlReturnsNotFoundError() 0 7 1
A providingInvalidDataReturnsBadRequest() 0 9 1
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 EditShortUrlActionTest extends ApiTestCase
11
{
12
    /** @test */
13
    public function tryingToEditInvalidUrlReturnsNotFoundError(): void
14
    {
15
        $resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => []]);
16
        ['error' => $error] = $this->getJsonResponsePayload($resp);
17
18
        $this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
19
        $this->assertEquals('INVALID_SHORTCODE', $error);
20
    }
21
22
    /** @test */
23
    public function providingInvalidDataReturnsBadRequest(): void
24
    {
25
        $resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => [
26
            'maxVisits' => 'not_a_number',
27
        ]]);
28
        ['error' => $error] = $this->getJsonResponsePayload($resp);
29
30
        $this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
31
        $this->assertEquals('INVALID_ARGUMENT', $error);
32
    }
33
}
34