<?php
declare(strict_types=1);

require_once dirname(__DIR__) . '/subscriber_custom_print_lib.php';

function scp_test_assert(bool $condition, string $message): void
{
    if (!$condition) throw new RuntimeException($message);
}

$selected = scp_parse_columns(['id', 'name', 'sector']);
scp_test_assert($selected === ['id', 'name', 'sector'], 'The preview must keep exactly the selected columns and their order.');

$filtered = scp_parse_columns(['status', 'not_a_column', 'usage', 'status']);
scp_test_assert($filtered === ['status', 'usage'], 'Unknown and duplicate columns must not reach the preview.');

$none = scp_parse_columns([]);
scp_test_assert($none === [], 'An empty selection must stay empty instead of falling back to unselected columns.');

$ids = scp_parse_ids('7, 7; 12 / 0 / 19', 1000);
scp_test_assert($ids === [7, 12, 19], 'Selected subscriber IDs must be positive, unique and ordered.');

echo "subscriber_custom_print_columns_test: OK\n";
