<?php

it('defines economic transfer queue jobs schema bootstrap table and tracking columns', function (): void {
    $content = file_get_contents(app_path('classes/economic_transfer_queue_schema_bootstrap.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain('CREATE TABLE IF NOT EXISTS economic_transfer_queue_jobs');
    expect($content)->toContain("status VARCHAR(32) NOT NULL DEFAULT 'QUEUED'");
    expect($content)->toContain('progress_percent TINYINT UNSIGNED NOT NULL DEFAULT 0');
    expect($content)->toContain('error_message TEXT NULL');
    expect($content)->toContain('payload_json JSON NOT NULL');
    expect($content)->toContain('result_json JSON NULL');
    expect($content)->toContain('CREATE TABLE IF NOT EXISTS economic_transfer_queue_job_dismissals');
    expect($content)->toContain('queue_job_id BIGINT UNSIGNED NOT NULL');
    expect($content)->toContain('user_id INT NOT NULL');
    expect($content)->toContain('dismissed_status VARCHAR(32) NOT NULL');
    expect($content)->toContain('PRIMARY KEY (queue_job_id, user_id)');
});

it('provides queue processor class constants and processing entrypoint', function (): void {
    $content = file_get_contents(app_path('classes/economic_transfer_queue.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain('public const STATUS_QUEUED');
    expect($content)->toContain('public const STATUS_PROCESSING');
    expect($content)->toContain('public const STATUS_COMPLETED');
    expect($content)->toContain('public const STATUS_FAILED');
    expect($content)->toContain('public const TYPE_ORDER_DRAFT_EXPORT');
    expect($content)->toContain('public const TYPE_ORDER_INVOICE_EXPORT');
    expect($content)->toContain('public const TYPE_COLLECTED_INVOICE_EXPORT');
    expect($content)->toContain('public function processPending(int $limit = 5): array');
});
