mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Add API test for short URL edition with device long URLs
This commit is contained in:
parent
d3590234a3
commit
b18c9e495f
1 changed files with 24 additions and 1 deletions
|
@ -154,7 +154,7 @@ class EditShortUrlTest extends ApiTestCase
|
|||
$editResp = $this->callApiWithKey(self::METHOD_PATCH, (string) $url, [RequestOptions::JSON => [
|
||||
'maxVisits' => 100,
|
||||
]]);
|
||||
$editedShortUrl = $this->getJsonResponsePayload($this->callApiWithKey(self::METHOD_GET, (string) $url));
|
||||
$editedShortUrl = $this->getJsonResponsePayload($editResp);
|
||||
|
||||
self::assertEquals(self::STATUS_OK, $editResp->getStatusCode());
|
||||
self::assertEquals($domain, $editedShortUrl['domain']);
|
||||
|
@ -170,4 +170,27 @@ class EditShortUrlTest extends ApiTestCase
|
|||
];
|
||||
yield 'no domain' => [null, 'https://shlink.io/documentation/'];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function deviceLongUrlsCanBeEdited(): void
|
||||
{
|
||||
$shortCode = 'def456';
|
||||
$url = new Uri(sprintf('/short-urls/%s', $shortCode));
|
||||
$editResp = $this->callApiWithKey(self::METHOD_PATCH, (string) $url, [RequestOptions::JSON => [
|
||||
'deviceLongUrls' => [
|
||||
'android' => null, // This one will get removed
|
||||
'ios' => 'https://blog.alejandrocelaya.com/ios/edited', // This one will be edited
|
||||
'desktop' => 'https://blog.alejandrocelaya.com/desktop', // This one is new and will be created
|
||||
],
|
||||
]]);
|
||||
$deviceLongUrls = $this->getJsonResponsePayload($editResp)['deviceLongUrls'] ?? [];
|
||||
|
||||
self::assertEquals(self::STATUS_OK, $editResp->getStatusCode());
|
||||
self::assertArrayHasKey('ios', $deviceLongUrls);
|
||||
self::assertEquals('https://blog.alejandrocelaya.com/ios/edited', $deviceLongUrls['ios']);
|
||||
self::assertArrayHasKey('desktop', $deviceLongUrls);
|
||||
self::assertEquals('https://blog.alejandrocelaya.com/desktop', $deviceLongUrls['desktop']);
|
||||
self::assertArrayHasKey('android', $deviceLongUrls);
|
||||
self::assertNull($deviceLongUrls['android']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue