Completed
Pull Request — master (#554)
by Alejandro
14:05
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\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