Completed
Pull Request — master (#554)
by Alejandro
14:05
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\Rest\Util\RestUtils;
9
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
10
11
class EditShortUrlActionTest extends ApiTestCase
12
{
13
    /** @test */
14
    public function tryingToEditInvalidUrlReturnsNotFoundError(): void
15
    {
16
        $resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => []]);
17
        ['error' => $error] = $this->getJsonResponsePayload($resp);
18
19
        $this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
20
        $this->assertEquals(RestUtils::INVALID_SHORTCODE_ERROR, $error);
0 ignored issues
show
introduced by
The constant Shlinkio\Shlink\Rest\Uti...INVALID_SHORTCODE_ERROR has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
        $this->assertEquals(/** @scrutinizer ignore-deprecated */ RestUtils::INVALID_SHORTCODE_ERROR, $error);
Loading history...
21
    }
22
23
    /** @test */
24
    public function providingInvalidDataReturnsBadRequest(): void
25
    {
26
        $resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => [
27
            'maxVisits' => 'not_a_number',
28
        ]]);
29
        ['error' => $error] = $this->getJsonResponsePayload($resp);
30
31
        $this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
32
        $this->assertEquals(RestUtils::INVALID_ARGUMENT_ERROR, $error);
0 ignored issues
show
introduced by
The constant Shlinkio\Shlink\Rest\Uti...:INVALID_ARGUMENT_ERROR has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

32
        $this->assertEquals(/** @scrutinizer ignore-deprecated */ RestUtils::INVALID_ARGUMENT_ERROR, $error);
Loading history...
33
    }
34
}
35