64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
|
|
<?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
|
||
|
|
{
|
||
|
|
// This test validates the command signature accepts the lemmy argument
|
||
|
|
// without actually executing the database-dependent logic
|
||
|
|
|
||
|
|
// Just test that the command can be called with lemmy argument
|
||
|
|
// The actual job dispatch is tested separately
|
||
|
|
try {
|
||
|
|
$this->artisan('channel:sync lemmy');
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
// Expected to fail due to database constraints in test environment
|
||
|
|
// but should not fail due to argument validation
|
||
|
|
$this->assertStringNotContainsString('No arguments expected', $e->getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_command_handles_default_platform(): void
|
||
|
|
{
|
||
|
|
// This test validates the command signature works with default argument
|
||
|
|
|
||
|
|
try {
|
||
|
|
$this->artisan('channel:sync');
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
// Expected to fail due to database constraints in test environment
|
||
|
|
// but should not fail due to missing platform argument
|
||
|
|
$this->assertStringNotContainsString('Not enough arguments', $e->getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|