mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Added API tests for the edition of the longURL
This commit is contained in:
parent
5432eb7b77
commit
3beb27acc2
1 changed files with 26 additions and 0 deletions
|
@ -71,6 +71,32 @@ class EditShortUrlActionTest extends ApiTestCase
|
|||
return $matchingShortUrl['meta'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideLongUrls
|
||||
*/
|
||||
public function longUrlCanBeEditedIfItIsValid(string $longUrl, int $expectedStatus, ?string $expectedError): void
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$url = sprintf('/short-urls/%s', $shortCode);
|
||||
|
||||
$resp = $this->callApiWithKey(self::METHOD_PATCH, $url, [RequestOptions::JSON => [
|
||||
'longUrl' => $longUrl,
|
||||
]]);
|
||||
|
||||
$this->assertEquals($expectedStatus, $resp->getStatusCode());
|
||||
if ($expectedError !== null) {
|
||||
$payload = $this->getJsonResponsePayload($resp);
|
||||
$this->assertEquals($expectedError, $payload['type']);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideLongUrls(): iterable
|
||||
{
|
||||
yield 'valid URL' => ['https://shlink.io', self::STATUS_NO_CONTENT, null];
|
||||
yield 'invalid URL' => ['htt:foo', self::STATUS_BAD_REQUEST, 'INVALID_URL'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideInvalidUrls
|
||||
|
|
Loading…
Add table
Reference in a new issue