fedi-feed-router/backend/tests/Unit/Jobs/SyncChannelPostsJobTest.php

67 lines
2 KiB
PHP
Raw Normal View History

2025-08-10 15:46:20 +02:00
<?php
namespace Tests\Unit\Jobs;
use App\Enums\PlatformEnum;
use App\Jobs\SyncChannelPostsJob;
use App\Models\PlatformChannel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SyncChannelPostsJobTest extends TestCase
{
use RefreshDatabase;
public function test_constructor_sets_correct_queue(): void
{
// Arrange
$channel = new PlatformChannel(['name' => 'Test Channel']);
// Act
$job = new SyncChannelPostsJob($channel);
// Assert
$this->assertEquals('sync', $job->queue);
}
public function test_job_implements_required_interfaces(): void
{
// Arrange
$channel = new PlatformChannel(['name' => 'Test Channel']);
$job = new SyncChannelPostsJob($channel);
// Assert
$this->assertInstanceOf(\Illuminate\Contracts\Queue\ShouldQueue::class, $job);
$this->assertInstanceOf(\Illuminate\Contracts\Queue\ShouldBeUnique::class, $job);
}
public function test_job_uses_queueable_trait(): void
{
// Arrange
$channel = new PlatformChannel(['name' => 'Test Channel']);
$job = new SyncChannelPostsJob($channel);
// Assert
$this->assertTrue(method_exists($job, 'onQueue'));
$this->assertTrue(method_exists($job, 'onConnection'));
$this->assertTrue(method_exists($job, 'delay'));
}
public function test_dispatch_for_all_active_channels_method_exists(): void
{
// Assert - Test that the static method exists
$this->assertTrue(method_exists(SyncChannelPostsJob::class, 'dispatchForAllActiveChannels'));
}
public function test_job_has_correct_structure(): void
{
// Arrange
$channel = new PlatformChannel(['name' => 'Test Channel']);
$job = new SyncChannelPostsJob($channel);
// Assert - Basic structure tests
$this->assertIsObject($job);
$this->assertTrue(method_exists($job, 'handle'));
$this->assertIsString($job->queue);
}
}