#!/usr/bin/env php
<?php
// Offline sanity check for whp_panel_url_normalize(). No DB, no network.
require_once __DIR__ . '/whp_panel_url.php';

$cases = [
    // raw input                       expected output
    ['whp01.cloud-hosting.io',         'https://whp01.cloud-hosting.io:8443'],
    ['whp01.cloud-hosting.io:8443',    'https://whp01.cloud-hosting.io:8443'],
    ['192.168.1.105:8080',             'http://192.168.1.105:8080'],
    ['192.168.1.105:80',               'http://192.168.1.105:80'],
    ['192.168.1.105:443',              'https://192.168.1.105:443'],
    ['panel.example.com:9000',         'https://panel.example.com:9000'],
    ['https://panel.example.com',      'https://panel.example.com'],
    ['http://panel.example.com:8080',  'http://panel.example.com:8080'],
    ['https://panel.example.com/',     'https://panel.example.com'],  // trailing slash stripped
];

$ok = true;
foreach ($cases as [$in, $want]) {
    $got = whp_panel_url_normalize($in);
    $pass = ($got === $want);
    if (!$pass) { $ok = false; }
    echo ($pass ? "PASS" : "FAIL"), "  ", $in, "  →  ", $got, ($pass ? "" : "   (expected {$want})"), "\n";
}
echo $ok ? "\nall ok\n" : "\nFAIL\n";
exit($ok ? 0 : 1);
