mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Enforce a schema to be provided when short URLs are created
This commit is contained in:
@@ -58,7 +58,7 @@ class NotifyNewShortUrlToMercureTest extends TestCase
|
||||
#[Test]
|
||||
public function expectedNotificationIsPublished(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl('longUrl');
|
||||
$shortUrl = ShortUrl::withLongUrl('https://longUrl');
|
||||
$update = Update::forTopicAndPayload('', []);
|
||||
|
||||
$this->em->expects($this->once())->method('find')->with(ShortUrl::class, '123')->willReturn($shortUrl);
|
||||
@@ -75,7 +75,7 @@ class NotifyNewShortUrlToMercureTest extends TestCase
|
||||
#[Test]
|
||||
public function messageIsPrintedIfPublishingFails(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl('longUrl');
|
||||
$shortUrl = ShortUrl::withLongUrl('https://longUrl');
|
||||
$update = Update::forTopicAndPayload('', []);
|
||||
$e = new Exception('Error');
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
|
||||
{
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
'customSlug' => 'foo',
|
||||
'longUrl' => 'longUrl',
|
||||
'longUrl' => 'https://longUrl',
|
||||
'title' => $title,
|
||||
]));
|
||||
$visit = Visit::forValidShortUrl($shortUrl, Visitor::emptyInstance());
|
||||
@@ -50,7 +50,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
|
||||
'shortUrl' => [
|
||||
'shortCode' => $shortUrl->getShortCode(),
|
||||
'shortUrl' => 'http:/' . $shortUrl->getShortCode(),
|
||||
'longUrl' => 'longUrl',
|
||||
'longUrl' => 'https://longUrl',
|
||||
'deviceLongUrls' => $shortUrl->deviceLongUrls(),
|
||||
'dateCreated' => $shortUrl->getDateCreated()->toAtomString(),
|
||||
'visitsCount' => 0,
|
||||
@@ -115,7 +115,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
|
||||
{
|
||||
$shortUrl = ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
'customSlug' => 'foo',
|
||||
'longUrl' => 'longUrl',
|
||||
'longUrl' => 'https://longUrl',
|
||||
'title' => 'The title',
|
||||
]));
|
||||
|
||||
@@ -125,7 +125,7 @@ class PublishingUpdatesGeneratorTest extends TestCase
|
||||
self::assertEquals(['shortUrl' => [
|
||||
'shortCode' => $shortUrl->getShortCode(),
|
||||
'shortUrl' => 'http:/' . $shortUrl->getShortCode(),
|
||||
'longUrl' => 'longUrl',
|
||||
'longUrl' => 'https://longUrl',
|
||||
'deviceLongUrls' => $shortUrl->deviceLongUrls(),
|
||||
'dateCreated' => $shortUrl->getDateCreated()->toAtomString(),
|
||||
'visitsCount' => 0,
|
||||
|
||||
@@ -70,7 +70,7 @@ class NotifyNewShortUrlToRabbitMqTest extends TestCase
|
||||
$shortUrlId = '123';
|
||||
$update = Update::forTopicAndPayload(Topic::NEW_SHORT_URL->value, []);
|
||||
$this->em->expects($this->once())->method('find')->with(ShortUrl::class, $shortUrlId)->willReturn(
|
||||
ShortUrl::withLongUrl('longUrl'),
|
||||
ShortUrl::withLongUrl('https://longUrl'),
|
||||
);
|
||||
$this->updatesGenerator->expects($this->once())->method('newShortUrlUpdate')->with(
|
||||
$this->isInstanceOf(ShortUrl::class),
|
||||
@@ -87,7 +87,7 @@ class NotifyNewShortUrlToRabbitMqTest extends TestCase
|
||||
$shortUrlId = '123';
|
||||
$update = Update::forTopicAndPayload(Topic::NEW_SHORT_URL->value, []);
|
||||
$this->em->expects($this->once())->method('find')->with(ShortUrl::class, $shortUrlId)->willReturn(
|
||||
ShortUrl::withLongUrl('longUrl'),
|
||||
ShortUrl::withLongUrl('https://longUrl'),
|
||||
);
|
||||
$this->updatesGenerator->expects($this->once())->method('newShortUrlUpdate')->with(
|
||||
$this->isInstanceOf(ShortUrl::class),
|
||||
|
||||
@@ -98,7 +98,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
yield 'non-orphan visit' => [
|
||||
Visit::forValidShortUrl(
|
||||
ShortUrl::create(ShortUrlCreation::fromRawData([
|
||||
'longUrl' => 'foo',
|
||||
'longUrl' => 'https://foo',
|
||||
'customSlug' => 'bar',
|
||||
])),
|
||||
$visitor,
|
||||
@@ -152,7 +152,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
{
|
||||
yield 'legacy non-orphan visit' => [
|
||||
true,
|
||||
$visit = Visit::forValidShortUrl(ShortUrl::withLongUrl('longUrl'), Visitor::emptyInstance()),
|
||||
$visit = Visit::forValidShortUrl(ShortUrl::withLongUrl('https://longUrl'), Visitor::emptyInstance()),
|
||||
noop(...),
|
||||
function (MockObject & PublishingHelperInterface $helper) use ($visit): void {
|
||||
$helper->method('publishUpdate')->with(self::callback(function (Update $update) use ($visit): bool {
|
||||
@@ -183,7 +183,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
];
|
||||
yield 'non-legacy non-orphan visit' => [
|
||||
false,
|
||||
Visit::forValidShortUrl(ShortUrl::withLongUrl('longUrl'), Visitor::emptyInstance()),
|
||||
Visit::forValidShortUrl(ShortUrl::withLongUrl('https://longUrl'), Visitor::emptyInstance()),
|
||||
function (MockObject & PublishingUpdatesGeneratorInterface $updatesGenerator): void {
|
||||
$update = Update::forTopicAndPayload('', []);
|
||||
$updatesGenerator->expects(self::never())->method('newOrphanVisitUpdate');
|
||||
|
||||
@@ -54,7 +54,7 @@ class NotifyNewShortUrlToRedisTest extends TestCase
|
||||
$shortUrlId = '123';
|
||||
$update = Update::forTopicAndPayload(Topic::NEW_SHORT_URL->value, []);
|
||||
$this->em->expects($this->once())->method('find')->with(ShortUrl::class, $shortUrlId)->willReturn(
|
||||
ShortUrl::withLongUrl('longUrl'),
|
||||
ShortUrl::withLongUrl('https://longUrl'),
|
||||
);
|
||||
$this->updatesGenerator->expects($this->once())->method('newShortUrlUpdate')->with(
|
||||
$this->isInstanceOf(ShortUrl::class),
|
||||
|
||||
Reference in New Issue
Block a user