Added some API tests for v3 API errors

This commit is contained in:
Alejandro Celaya
2022-08-13 17:48:55 +02:00
parent 905f51fbd0
commit 40bbcb3250
8 changed files with 105 additions and 20 deletions

View File

@@ -7,6 +7,8 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
use function sprintf;
class DeleteShortUrlTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;
@@ -33,6 +35,28 @@ class DeleteShortUrlTest extends ApiTestCase
self::assertEquals($domain, $payload['domain'] ?? null);
}
/**
* @test
* @dataProvider provideApiVersions
*/
public function expectedTypeIsReturnedBasedOnApiVersion(string $version, string $expectedType): void
{
$resp = $this->callApiWithKey(
self::METHOD_DELETE,
sprintf('/rest/v%s/short-urls/invalid-short-code', $version),
);
$payload = $this->getJsonResponsePayload($resp);
self::assertEquals($expectedType, $payload['type']);
}
public function provideApiVersions(): iterable
{
yield ['1', 'INVALID_SHORTCODE'];
yield ['2', 'INVALID_SHORTCODE'];
yield ['3', 'https://shlink.io/api/error/short-url-not-found'];
}
/** @test */
public function properShortUrlIsDeletedWhenDomainIsProvided(): void
{