mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Make it impossible to create a short URL with an empty long URL
This commit is contained in:
@@ -29,8 +29,8 @@ class DeleteShortUrlServiceTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::createEmpty()->setVisits(new ArrayCollection(
|
||||
map(range(0, 10), fn () => Visit::forValidShortUrl(ShortUrl::createEmpty(), Visitor::emptyInstance())),
|
||||
$shortUrl = ShortUrl::createFake()->setVisits(new ArrayCollection(
|
||||
map(range(0, 10), fn () => Visit::forValidShortUrl(ShortUrl::createFake(), Visitor::emptyInstance())),
|
||||
));
|
||||
$this->shortCode = $shortUrl->getShortCode();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class ShortUrlTest extends TestCase
|
||||
'The short code cannot be regenerated on ShortUrls where a custom slug was provided.',
|
||||
];
|
||||
yield 'already persisted' => [
|
||||
ShortUrl::createEmpty()->setId('1'),
|
||||
ShortUrl::createFake()->setId('1'),
|
||||
'The short code can be regenerated only on new ShortUrls which have not been persisted yet.',
|
||||
];
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class ShortUrlTest extends TestCase
|
||||
|
||||
public function provideValidShortUrls(): iterable
|
||||
{
|
||||
yield 'no custom slug' => [ShortUrl::createEmpty()];
|
||||
yield 'no custom slug' => [ShortUrl::createFake()];
|
||||
yield 'imported with custom slug' => [ShortUrl::fromImport(
|
||||
new ImportedShlinkUrl(ImportSource::BITLY, 'longUrl', [], Chronos::now(), null, 'custom-slug', null),
|
||||
true,
|
||||
|
||||
@@ -36,10 +36,10 @@ class ShortUrlListServiceTest extends TestCase
|
||||
public function listedUrlsAreReturnedFromEntityManager(?ApiKey $apiKey): void
|
||||
{
|
||||
$list = [
|
||||
ShortUrl::createEmpty(),
|
||||
ShortUrl::createEmpty(),
|
||||
ShortUrl::createEmpty(),
|
||||
ShortUrl::createEmpty(),
|
||||
ShortUrl::createFake(),
|
||||
ShortUrl::createFake(),
|
||||
ShortUrl::createFake(),
|
||||
ShortUrl::createFake(),
|
||||
];
|
||||
|
||||
$this->repo->expects($this->once())->method('findList')->willReturn($list);
|
||||
|
||||
@@ -38,7 +38,7 @@ class ShortUrlDataTransformerTest extends TestCase
|
||||
$maxVisits = random_int(1, 1000);
|
||||
$now = Chronos::now();
|
||||
|
||||
yield 'no metadata' => [ShortUrl::createEmpty(), [
|
||||
yield 'no metadata' => [ShortUrl::createFake(), [
|
||||
'validSince' => null,
|
||||
'validUntil' => null,
|
||||
'maxVisits' => null,
|
||||
|
||||
Reference in New Issue
Block a user