fedi-feed-router/backend/tests/Feature/Http/Console/Commands/SyncChannelPostsCommandTest.php
2025-08-15 18:20:19 +02:00

55 lines
No EOL
1.8 KiB
PHP

<?php
namespace Tests\Feature\Http\Console\Commands;
use Domains\Platform\Jobs\SyncChannelPostsJob;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Illuminate\Testing\PendingCommand;
use Tests\TestCase;
class SyncChannelPostsCommandTest extends TestCase
{
use RefreshDatabase;
public function test_command_fails_with_unsupported_platform(): void
{
// Act
/** @var PendingCommand $exitCode */
$exitCode = $this->artisan('channel:sync unsupported');
// Assert
$exitCode->assertFailed();
$exitCode->expectsOutput('Unsupported platform: unsupported');
}
public function test_command_returns_failure_exit_code_for_unsupported_platform(): void
{
// Act
/** @var PendingCommand $exitCode */
$exitCode = $this->artisan('channel:sync invalid');
// Assert
$exitCode->assertExitCode(1);
}
public function test_command_accepts_lemmy_platform_argument(): void
{
// Act - Test that the command accepts lemmy as a valid platform argument
$exitCode = $this->artisan('channel:sync lemmy');
// Assert - Command should succeed (not fail with argument validation error)
$exitCode->assertSuccessful();
$exitCode->expectsOutput('Successfully dispatched sync jobs for all active Lemmy channels');
}
public function test_command_handles_default_platform(): void
{
// Act - Test that the command works with default platform (should be lemmy)
$exitCode = $this->artisan('channel:sync');
// Assert - Command should succeed with default platform
$exitCode->assertSuccessful();
$exitCode->expectsOutput('Successfully dispatched sync jobs for all active Lemmy channels');
}
}