mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-13 14:59:19 +03:00
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioApiTest\Shlink\Rest\Action;
|
|
|
|
use GuzzleHttp\RequestOptions;
|
|
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
|
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
|
|
|
class EditShortUrlActionTest extends ApiTestCase
|
|
{
|
|
/** @test */
|
|
public function tryingToEditInvalidUrlReturnsNotFoundError(): void
|
|
{
|
|
$resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => []]);
|
|
['error' => $error] = $this->getJsonResponsePayload($resp);
|
|
|
|
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
|
|
$this->assertEquals(RestUtils::INVALID_SHORTCODE_ERROR, $error);
|
|
}
|
|
|
|
/** @test */
|
|
public function providingInvalidDataReturnsBadRequest(): void
|
|
{
|
|
$resp = $this->callApiWithKey(self::METHOD_PATCH, '/short-urls/invalid', [RequestOptions::JSON => [
|
|
'maxVisits' => 'not_a_number',
|
|
]]);
|
|
['error' => $error] = $this->getJsonResponsePayload($resp);
|
|
|
|
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
|
|
$this->assertEquals(RestUtils::INVALID_ARGUMENT_ERROR, $error);
|
|
}
|
|
}
|