Remove support to validate long URLs during short URL creation/edition

This commit is contained in:
Alejandro Celaya
2024-02-17 12:02:57 +01:00
parent 5c1ab02753
commit e3de403c6c
28 changed files with 198 additions and 619 deletions

View File

@@ -75,28 +75,16 @@ class EditShortUrlTest extends ApiTestCase
return $matchingShortUrl['meta'] ?? [];
}
#[Test, DataProvider('provideLongUrls')]
public function longUrlCanBeEditedIfItIsValid(string $longUrl, int $expectedStatus, ?string $expectedError): void
public function longUrlCanBeEdited(): void
{
$shortCode = 'abc123';
$url = sprintf('/short-urls/%s', $shortCode);
$resp = $this->callApiWithKey(self::METHOD_PATCH, $url, [RequestOptions::JSON => [
'longUrl' => $longUrl,
'validateUrl' => true,
'longUrl' => 'https://shlink.io',
]]);
self::assertEquals($expectedStatus, $resp->getStatusCode());
if ($expectedError !== null) {
$payload = $this->getJsonResponsePayload($resp);
self::assertEquals($expectedError, $payload['type']);
}
}
public static function provideLongUrls(): iterable
{
yield 'valid URL' => ['https://shlink.io', self::STATUS_OK, null];
yield 'invalid URL' => ['http://foo', self::STATUS_BAD_REQUEST, 'https://shlink.io/api/error/invalid-url'];
self::assertEquals(self::STATUS_OK, $resp->getStatusCode());
}
#[Test, DataProviderExternal(ApiTestDataProviders::class, 'invalidUrlsProvider')]