mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 23:23:42 -06:00
Created API tests for errors when updating tags
This commit is contained in:
parent
8607d58e18
commit
b3b67b051d
@ -27,9 +27,9 @@ return [
|
|||||||
Action\ShortUrl\EditShortUrlAction::class => ConfigAbstractFactory::class,
|
Action\ShortUrl\EditShortUrlAction::class => ConfigAbstractFactory::class,
|
||||||
Action\ShortUrl\DeleteShortUrlAction::class => ConfigAbstractFactory::class,
|
Action\ShortUrl\DeleteShortUrlAction::class => ConfigAbstractFactory::class,
|
||||||
Action\ShortUrl\ResolveShortUrlAction::class => ConfigAbstractFactory::class,
|
Action\ShortUrl\ResolveShortUrlAction::class => ConfigAbstractFactory::class,
|
||||||
Action\Visit\GetVisitsAction::class => ConfigAbstractFactory::class,
|
|
||||||
Action\ShortUrl\ListShortUrlsAction::class => ConfigAbstractFactory::class,
|
Action\ShortUrl\ListShortUrlsAction::class => ConfigAbstractFactory::class,
|
||||||
Action\ShortUrl\EditShortUrlTagsAction::class => ConfigAbstractFactory::class,
|
Action\ShortUrl\EditShortUrlTagsAction::class => ConfigAbstractFactory::class,
|
||||||
|
Action\Visit\GetVisitsAction::class => ConfigAbstractFactory::class,
|
||||||
Action\Tag\ListTagsAction::class => ConfigAbstractFactory::class,
|
Action\Tag\ListTagsAction::class => ConfigAbstractFactory::class,
|
||||||
Action\Tag\DeleteTagsAction::class => ConfigAbstractFactory::class,
|
Action\Tag\DeleteTagsAction::class => ConfigAbstractFactory::class,
|
||||||
Action\Tag\CreateTagsAction::class => ConfigAbstractFactory::class,
|
Action\Tag\CreateTagsAction::class => ConfigAbstractFactory::class,
|
||||||
|
45
module/Rest/test-api/Action/UpdateTagActionTest.php
Normal file
45
module/Rest/test-api/Action/UpdateTagActionTest.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?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 UpdateTagActionTest extends ApiTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @dataProvider provideInvalidBody
|
||||||
|
*/
|
||||||
|
public function notProvidingTagsReturnsBadRequest(array $body): void
|
||||||
|
{
|
||||||
|
$resp = $this->callApiWithKey(self::METHOD_PUT, '/tags', [RequestOptions::JSON => $body]);
|
||||||
|
['error' => $error] = $this->getJsonResponsePayload($resp);
|
||||||
|
|
||||||
|
$this->assertEquals(self::STATUS_BAD_REQUEST, $resp->getStatusCode());
|
||||||
|
$this->assertEquals(RestUtils::INVALID_ARGUMENT_ERROR, $error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideInvalidBody(): iterable
|
||||||
|
{
|
||||||
|
yield [[]];
|
||||||
|
yield [['oldName' => 'foo']];
|
||||||
|
yield [['newName' => 'foo']];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function tryingToRenameInvalidTagReturnsNotFound(): void
|
||||||
|
{
|
||||||
|
$resp = $this->callApiWithKey(self::METHOD_PUT, '/tags', [RequestOptions::JSON => [
|
||||||
|
'oldName' => 'invalid_tag',
|
||||||
|
'newName' => 'foo',
|
||||||
|
]]);
|
||||||
|
['error' => $error] = $this->getJsonResponsePayload($resp);
|
||||||
|
|
||||||
|
$this->assertEquals(self::STATUS_NOT_FOUND, $resp->getStatusCode());
|
||||||
|
$this->assertEquals(RestUtils::NOT_FOUND_ERROR, $error);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user