Files
miniapi/tests/customer_center_proxy_self_check.php
gaofeng 21b32e11c1 提交
2026-08-12 17:58:56 +08:00

49 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use app\miniapi\service\CustomerCenter\CustomerCenterService;
function customerCenterProxyAssertSame(mixed $expected, mixed $actual, string $message): void
{
if ($expected !== $actual) {
throw new RuntimeException($message . PHP_EOL
. 'Expected: ' . var_export($expected, true) . PHP_EOL
. 'Actual: ' . var_export($actual, true));
}
}
$service = new CustomerCenterService();
customerCenterProxyAssertSame([
'user_id' => 42,
'page' => 2,
], $service->payload(42, ['page' => 2]), 'The proxy request must use the original unsigned parameter style');
$materialsJson = '[{"material_type":"passport","oss_url":"https://files.jzvisa.com/jnevus/contact/42/passport.jpg"}]';
customerCenterProxyAssertSame([
'user_id' => 42,
'materials_json' => $materialsJson,
], $service->payload(42, ['materials_json' => $materialsJson]), 'The proxy must preserve the compact material JSON payload');
customerCenterProxyAssertSame(
'https://uniuser.jzvisa.com/home/customer_center/applications',
$service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin', 'applications'),
'The proxy endpoint must stay on the configured unified API host'
);
customerCenterProxyAssertSame(
'https://uniuser.jzvisa.com/home/customer_center/applicants',
$service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin/', 'applicants'),
'The proxy endpoint must accept the trailing slash used by the site configuration'
);
customerCenterProxyAssertSame(
'https://uniuser.jzvisa.com/home/customer_center/orders',
$service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin', 'orders'),
'Unified customer orders must use the customer center endpoint'
);
customerCenterProxyAssertSame(
'',
$service->endpoint('https://example.com/unexpected', 'applications'),
'Unexpected user API URLs must fail closed'
);
echo "Customer center proxy self-check passed\n";