<?php
declare(strict_types=1);

require_once __DIR__ . '/user_auth.php';

// CLI smoke test: php adminer/_smoke_register.php username password
// Uses FabianWebsite via user_auth.php config.

$username = $argv[1] ?? 'smoketest_user';
$password = $argv[2] ?? 'Smoketest123!';

try {
    adminer_app_bootstrap();

    $r = adminer_app_try_register($username, $password, $password);
    if (!empty($r['ok'])) {
        echo "REGISTER OK (needs verification)\n";
    } else {
        echo "REGISTER FAIL: " . ($r['error'] ?? 'unknown') . "\n";
    }

    $l = adminer_app_try_login($username, $password);
    if (!empty($l['ok'])) {
        echo "LOGIN OK (unexpected)\n";
    } else {
        echo "LOGIN BLOCKED: " . ($l['error'] ?? 'unknown') . "\n";
    }
} catch (Throwable $e) {
    echo "EXCEPTION: " . $e->getMessage() . "\n";
    exit(1);
}
