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/CloudAutomaticBackupInvoice...

46 lines
2.2 KiB
PHTML

<?php
$root = dirname(__DIR__);
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$read = static fn (string $path): string => (string) file_get_contents(
$root . '/' . $path
);
$pageService = $read('app/Services/Cloud/CloudInvoicePageService.php');
$invoiceService = $read('app/Services/Cloud/CloudInvoiceService.php');
$adminService = $read('app/Services/Cloud/CloudAdminBillingService.php');
$listTemplate = $read('resources/views/venix/cloud/pages/invoices.tpl');
$listRuntime = $read('public/cloud/invoices.js');
$detailRuntime = $read('public/cloud/invoice-detail-runtime.js');
$adminRuntime = $read('public/cloud/admin-billing.js');
$catalog = $read('app/Services/Cloud/CloudBillingPresentationCatalog.php');
$presentation = $read('app/Services/Cloud/CloudInvoicePresentation.php');
$adminPresentation = $read('app/Services/Cloud/CloudAdminBillingPresentation.php');
$assert(str_contains($pageService, "'backup_addon'")
&& substr_count($invoiceService,
'CloudBillingPresentationCatalog::knownPurposeLabel(') === 2
&& str_contains($catalog, "'backup_addon' => '自动备份开通'"),
'Automatic-backup bills are not recognized by user invoice services.');
$assert(str_contains($listTemplate, 'value="backup_addon"')
&& str_contains($listRuntime, 'invoice?.title')
&& str_contains($detailRuntime, 'payload?.presentation')
&& str_contains($presentation,
'CloudBillingPresentationCatalog::knownPurposeLabel($purpose)')
&& str_contains($catalog, "'backup_addon' => '自动备份开通'")
&& str_contains($detailRuntime, '/user/cloud/instances/'),
'User invoice UI hides the add-on type or its linked instance.');
$assert(str_contains($adminService,
"'provision', 'renewal', 'upgrade', 'ip_change', 'backup_addon', 'recharge'")
&& str_contains($adminRuntime,
'state.catalog[definition.optionsKey]')
&& str_contains($adminPresentation,
'CloudBillingPresentationCatalog::filterOptions()'),
'Administrator billing filters or labels omit automatic-backup add-ons.');
echo "Automatic-backup invoice presentation contract passed.\n";