67 lines
No EOL
2 KiB
PHP
67 lines
No EOL
2 KiB
PHP
<?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);
|
|
}
|
|
} |