mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated MercureUpdatesGeneratorTest
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"asyncapi": "2.0.0",
|
"asyncapi": "2.4.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Shlink",
|
"title": "Shlink",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Shlink, the self-hosted URL shortener",
|
"description": "Shlink, the self-hosted URL shortener",
|
||||||
"license": {
|
"license": {
|
||||||
"name": "MIT",
|
"name": "MIT",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"title": "Shlink",
|
"title": "Shlink",
|
||||||
"description": "Shlink, the self-hosted URL shortener",
|
"description": "Shlink, the self-hosted URL shortener",
|
||||||
"version": "1.0"
|
"version": "2.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"externalDocs": {
|
"externalDocs": {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Core\Mercure;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGenerator;
|
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGenerator;
|
||||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
@@ -109,4 +110,35 @@ class MercureUpdatesGeneratorTest extends TestCase
|
|||||||
yield VisitType::INVALID_SHORT_URL->value => [Visit::forInvalidShortUrl($visitor)];
|
yield VisitType::INVALID_SHORT_URL->value => [Visit::forInvalidShortUrl($visitor)];
|
||||||
yield VisitType::BASE_URL->value => [Visit::forBasePath($visitor)];
|
yield VisitType::BASE_URL->value => [Visit::forBasePath($visitor)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function shortUrlIsProperlySerializedIntoUpdate(): void
|
||||||
|
{
|
||||||
|
$shortUrl = ShortUrl::fromMeta(ShortUrlMeta::fromRawData([
|
||||||
|
'customSlug' => 'foo',
|
||||||
|
'longUrl' => '',
|
||||||
|
'title' => 'The title',
|
||||||
|
]));
|
||||||
|
|
||||||
|
$update = $this->generator->newShortUrlUpdate($shortUrl);
|
||||||
|
|
||||||
|
self::assertEquals([Topic::NEW_SHORT_URL->value], $update->getTopics());
|
||||||
|
self::assertEquals(['shortUrl' => [
|
||||||
|
'shortCode' => $shortUrl->getShortCode(),
|
||||||
|
'shortUrl' => 'http:/' . $shortUrl->getShortCode(),
|
||||||
|
'longUrl' => '',
|
||||||
|
'dateCreated' => $shortUrl->getDateCreated()->toAtomString(),
|
||||||
|
'visitsCount' => 0,
|
||||||
|
'tags' => [],
|
||||||
|
'meta' => [
|
||||||
|
'validSince' => null,
|
||||||
|
'validUntil' => null,
|
||||||
|
'maxVisits' => null,
|
||||||
|
],
|
||||||
|
'domain' => null,
|
||||||
|
'title' => $shortUrl->title(),
|
||||||
|
'crawlable' => false,
|
||||||
|
'forwardQuery' => true,
|
||||||
|
],], json_decode($update->getData()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user