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

providingInvalidDataReturnsBadRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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