2025-08-10 15:46:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Feature\Http\Console\Commands;
|
|
|
|
|
|
|
|
|
|
use App\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
|
|
|
|
|
{
|
2025-08-15 02:50:42 +02:00
|
|
|
// Act - Test that the command accepts lemmy as a valid platform argument
|
|
|
|
|
$exitCode = $this->artisan('channel:sync lemmy');
|
2025-08-10 15:46:20 +02:00
|
|
|
|
2025-08-15 02:50:42 +02:00
|
|
|
// Assert - Command should succeed (not fail with argument validation error)
|
|
|
|
|
$exitCode->assertSuccessful();
|
|
|
|
|
$exitCode->expectsOutput('Successfully dispatched sync jobs for all active Lemmy channels');
|
2025-08-10 15:46:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test_command_handles_default_platform(): void
|
|
|
|
|
{
|
2025-08-15 02:50:42 +02:00
|
|
|
// Act - Test that the command works with default platform (should be lemmy)
|
|
|
|
|
$exitCode = $this->artisan('channel:sync');
|
2025-08-10 15:46:20 +02:00
|
|
|
|
2025-08-15 02:50:42 +02:00
|
|
|
// Assert - Command should succeed with default platform
|
|
|
|
|
$exitCode->assertSuccessful();
|
|
|
|
|
$exitCode->expectsOutput('Successfully dispatched sync jobs for all active Lemmy channels');
|
2025-08-10 15:46:20 +02:00
|
|
|
}
|
|
|
|
|
}
|