6 - Add PollFailed event to FediDiscover package
This commit is contained in:
parent
bbd74c1954
commit
8d063a8262
2 changed files with 54 additions and 0 deletions
23
packages/Lvl0/FediDiscover/src/Events/PollFailed.php
Normal file
23
packages/Lvl0/FediDiscover/src/Events/PollFailed.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Lvl0\FediDiscover\Events;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Lvl0\FediDiscover\Models\Instance;
|
||||
|
||||
class PollFailed
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public Instance $instance,
|
||||
public string $message,
|
||||
public CarbonImmutable $failedAt,
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
31
packages/Lvl0/FediDiscover/tests/Unit/PollFailedTest.php
Normal file
31
packages/Lvl0/FediDiscover/tests/Unit/PollFailedTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Lvl0\FediDiscover\Tests\Unit;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Lvl0\FediDiscover\Events\PollFailed;
|
||||
use Lvl0\FediDiscover\Models\Instance;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PollFailedTest extends TestCase
|
||||
{
|
||||
public function test_it_exposes_all_payload_fields(): void
|
||||
{
|
||||
$instance = new Instance;
|
||||
$instance->id = 7;
|
||||
|
||||
$failedAt = CarbonImmutable::parse('2026-04-28T09:00:00');
|
||||
|
||||
$event = new PollFailed(
|
||||
instance: $instance,
|
||||
message: 'Connection timed out',
|
||||
failedAt: $failedAt,
|
||||
);
|
||||
|
||||
$this->assertSame($instance, $event->instance);
|
||||
$this->assertSame('Connection timed out', $event->message);
|
||||
$this->assertTrue($failedAt->eq($event->failedAt));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue