mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Add unit test to cover device URLs edition, and fix bug thanks to it
This commit is contained in:
@@ -7,8 +7,10 @@ namespace ShlinkioTest\Shlink\Core\ShortUrl\Entity;
|
||||
use Cake\Chronos\Chronos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Exception\ShortCodeCannotBeRegeneratedException;
|
||||
use Shlinkio\Shlink\Core\Model\DeviceType;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlEdition;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\Validation\ShortUrlInputFilter;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||
@@ -89,4 +91,46 @@ class ShortUrlTest extends TestCase
|
||||
yield [null, DEFAULT_SHORT_CODES_LENGTH];
|
||||
yield from map(range(4, 10), fn (int $value) => [$value, $value]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function deviceLongUrlsAreUpdated(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl('foo');
|
||||
|
||||
$shortUrl->update(ShortUrlEdition::fromRawData([
|
||||
ShortUrlInputFilter::DEVICE_LONG_URLS => [
|
||||
DeviceType::ANDROID->value => 'android',
|
||||
DeviceType::IOS->value => 'ios',
|
||||
],
|
||||
]));
|
||||
self::assertEquals([
|
||||
DeviceType::ANDROID->value => 'android',
|
||||
DeviceType::IOS->value => 'ios',
|
||||
DeviceType::DESKTOP->value => null,
|
||||
], $shortUrl->deviceLongUrls());
|
||||
|
||||
$shortUrl->update(ShortUrlEdition::fromRawData([
|
||||
ShortUrlInputFilter::DEVICE_LONG_URLS => [
|
||||
DeviceType::ANDROID->value => null,
|
||||
DeviceType::DESKTOP->value => 'desktop',
|
||||
],
|
||||
]));
|
||||
self::assertEquals([
|
||||
DeviceType::ANDROID->value => null,
|
||||
DeviceType::IOS->value => 'ios',
|
||||
DeviceType::DESKTOP->value => 'desktop',
|
||||
], $shortUrl->deviceLongUrls());
|
||||
|
||||
$shortUrl->update(ShortUrlEdition::fromRawData([
|
||||
ShortUrlInputFilter::DEVICE_LONG_URLS => [
|
||||
DeviceType::ANDROID->value => null,
|
||||
DeviceType::IOS->value => null,
|
||||
],
|
||||
]));
|
||||
self::assertEquals([
|
||||
DeviceType::ANDROID->value => null,
|
||||
DeviceType::IOS->value => null,
|
||||
DeviceType::DESKTOP->value => 'desktop',
|
||||
], $shortUrl->deviceLongUrls());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user