You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
use App\Controllers\CloudPageController;
|
|
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
$invoke = static function (object $target, string $method, array $arguments = []) {
|
|
$reflection = new ReflectionMethod($target, $method);
|
|
return $reflection->invokeArgs($target, $arguments);
|
|
};
|
|
|
|
$payload = [
|
|
'invoice' => [
|
|
'id' => '17',
|
|
'purpose' => 'renewal',
|
|
'title' => '实例续费',
|
|
'created_at' => 2_000_000_000,
|
|
'amount' => '12.51',
|
|
'status' => 'open',
|
|
'renews_expires_at' => 2_000_100_000,
|
|
'payment_deadline_at' => 2_000_359_200,
|
|
'payable' => true,
|
|
'validity_days' => 30,
|
|
'traffic_quota_bytes' => 0,
|
|
'items' => [
|
|
[
|
|
'id' => '31',
|
|
'code' => 'instance',
|
|
'label' => '实例套餐续费',
|
|
'amount' => '10.00',
|
|
'currency' => 'USD',
|
|
],
|
|
[
|
|
'id' => '32',
|
|
'code' => 'automatic_backup',
|
|
'label' => '<img src=x onerror=alert(1)>自动备份',
|
|
'amount' => '2.50',
|
|
'currency' => 'USD',
|
|
],
|
|
],
|
|
],
|
|
'balance_payment_allowed' => false,
|
|
'payment_methods' => [],
|
|
];
|
|
|
|
$controller = new CloudPageController();
|
|
$view = $invoke($controller, 'invoiceDetailView', [$payload]);
|
|
|
|
$assert(($view['show_line_items'] ?? false) === true,
|
|
'Invoice first paint does not expose its frozen line items.');
|
|
$assert(($view['line_items'] ?? null) === [
|
|
['label' => '实例套餐续费', 'amount_display' => '$10.00'],
|
|
[
|
|
'label' => '<img src=x onerror=alert(1)>自动备份',
|
|
'amount_display' => '$2.50',
|
|
],
|
|
], 'Invoice line-item projection changed labels or frozen amounts.');
|
|
$assert(($view['amount_display'] ?? null) === '$12.51',
|
|
'Invoice presentation recomputed the authoritative total from line items.');
|
|
|
|
echo "Cloud invoice SSR presentation checks passed.\n";
|