Updated MercureUpdatesGeneratorTest

This commit is contained in:
Alejandro Celaya
2022-07-25 09:02:05 +02:00
parent 34e72b42dc
commit 074bfe3db2
3 changed files with 35 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Core\Mercure;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGenerator;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
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::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()));
}
}