mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 01:33:11 +08:00
Added some API tests for v3 API errors
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user