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.
virt/web/tests/CloudExpiredInstancePresent...

51 lines
1.7 KiB
PHP

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Controllers\CloudPageController;
$assert = static function ($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);
};
$expiry = time() - 60;
$expiredRunning = [
'id' => '7',
'api_id' => '7',
'uuid' => '77777777-7777-4777-8777-777777777777',
'name' => 'expired-running-vm',
'state' => 'running',
'state_fresh' => true,
'state_sync_status' => 'fresh',
'service_status' => 'expired_grace',
'network_status' => 'blocked_expired',
'service_expires_at' => $expiry,
'service_paused' => true,
'region' => 'Tokyo',
'os_source' => 'cloud_template',
'os_name' => 'AlmaLinux 10',
'vcpu' => 2,
'memory_mib' => 2048,
'disk_gib' => 40,
];
$controller = new CloudPageController();
$row = $invoke($controller, 'vmListRow', [$expiredRunning]);
$detail = $invoke($controller, 'vmDetailView', [$expiredRunning]);
$assert($row['state_label'] === '已暂停' && $row['state_class'] === 'other',
'Expired list first paint still presents the live power state as running.');
$assert($row['service_expiry_display'] !== '暂未提供'
&& str_contains($row['service_expiry_display'], date('Y/m/d', $expiry)),
'Instance list first paint omitted the service expiry date.');
$assert($detail['state_label'] === '已暂停' && $detail['state_class'] === 'other',
'Expired detail first paint still presents the live power state as running.');
echo "Expired instance SSR presentation checks passed.\n";