44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Lvl0\FediDiscover\Tests\Unit;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Lvl0\FediDiscover\Events\UrlDiscovered;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class UrlDiscoveredTest extends TestCase
|
|
{
|
|
public function test_it_exposes_all_payload_fields(): void
|
|
{
|
|
$discoveredAt = CarbonImmutable::parse('2026-04-26T12:00:00');
|
|
|
|
$event = new UrlDiscovered(
|
|
url: 'https://example.com/article',
|
|
instanceId: 42,
|
|
discoveredAt: $discoveredAt,
|
|
postUrl: 'https://mastodon.social/@alice/109876543210',
|
|
postBody: 'Check out this article: https://example.com/article'
|
|
);
|
|
|
|
$this->assertSame('https://example.com/article', $event->url);
|
|
$this->assertSame(42, $event->instanceId);
|
|
$this->assertTrue($discoveredAt->eq($event->discoveredAt));
|
|
$this->assertSame('https://mastodon.social/@alice/109876543210', $event->postUrl);
|
|
$this->assertSame('Check out this article: https://example.com/article', $event->postBody);
|
|
}
|
|
|
|
public function test_post_body_is_nullable(): void
|
|
{
|
|
$event = new UrlDiscovered(
|
|
url: 'https://example.com/article',
|
|
instanceId: 1,
|
|
discoveredAt: CarbonImmutable::parse('2026-04-26T12:00:00'),
|
|
postUrl: 'https://mastodon.social/@alice/109876543210',
|
|
postBody: null
|
|
);
|
|
|
|
$this->assertNull($event->postBody);
|
|
}
|
|
}
|