Created API tests for errors when editting short URL tags

This commit is contained in:
Alejandro Celaya
2019-11-21 18:49:55 +01:00
parent 34e60ec5b8
commit 8607d58e18
3 changed files with 41 additions and 39 deletions

View File

@@ -0,0 +1,34 @@
<?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 EditShortUrlActionTagsTest extends ApiTestCase
{
/** @test */
public function notProvidingTagsReturnsBadRequest(): void
{
$resp = $this->callApiWithKey(self::METHOD_PUT, '/short-urls/abc123/tags', [RequestOptions::JSON => []]);
['error' => $error] = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
$this->assertEquals(RestUtils::INVALID_ARGUMENT_ERROR, $error);
}
/** @test */
public function providingInvalidShortCodeReturnsBadRequest(): void
{
$resp = $this->callApiWithKey(self::METHOD_PUT, '/short-urls/invalid/tags', [RequestOptions::JSON => [
'tags' => ['foo', 'bar'],
]]);
['error' => $error] = $this->getJsonResponsePayload($resp);
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
$this->assertEquals(RestUtils::INVALID_SHORTCODE_ERROR, $error);
}
}