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.
111 lines
4.5 KiB
PHP
111 lines
4.5 KiB
PHP
<?php
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
use App\Services\UserCopy\UserCopyCoverageScanner;
|
|
use App\Services\UserCopy\UserCopyManifest;
|
|
|
|
$root = dirname(__DIR__);
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$manifest = UserCopyManifest::load();
|
|
$entries = array_column($manifest['entries'], null, 'key');
|
|
$assert(($manifest['pages']['user.account']['scopes'] ?? null)
|
|
=== ['common', 'account']
|
|
&& ($manifest['pages']['user.recharge']['scopes'] ?? null)
|
|
=== ['common', 'recharge']
|
|
&& ($manifest['pages']['user.invite']['scopes'] ?? null)
|
|
=== ['common', 'invite'],
|
|
'Account, recharge and invite pages must publish bounded copy scopes.');
|
|
|
|
$required = [
|
|
'account.email.help', 'account.password.help',
|
|
'account.totp.unbind_failed', 'account.disabled.description',
|
|
'recharge.methods.loading', 'recharge.order.usdt_info',
|
|
'recharge.payment.expired', 'recharge.result.waiting_body',
|
|
'invite.link.help', 'invite.transfer.completed',
|
|
'invite.withdraw.failed', 'invite.link.reset_failed',
|
|
];
|
|
foreach ($required as $key) {
|
|
$assert(isset($entries[$key]),
|
|
'Required account/commerce copy is missing: ' . $key);
|
|
}
|
|
|
|
$assert($entries['account.email.help']['criticality'] === 'critical'
|
|
&& $entries['account.password.help']['criticality'] === 'critical'
|
|
&& $entries['account.disabled.description']['criticality'] === 'critical'
|
|
&& $entries['recharge.order.usdt_info']['criticality'] === 'critical'
|
|
&& $entries['recharge.result.waiting_body']['criticality'] === 'critical',
|
|
'Credential, disabled-account and payment safety copy must remain critical.');
|
|
$assert($entries['account.subtitle']['parameters'] === ['username' => 'string']
|
|
&& $entries['recharge.methods.select']['parameters'] === ['amount' => 'string']
|
|
&& $entries['invite.link.help']['parameters'] === ['days' => 'integer'],
|
|
'Account/commerce placeholder contracts drifted from their call sites.');
|
|
|
|
$paths = [
|
|
$root . '/resources/views/venix/user/edit.tpl',
|
|
$root . '/resources/views/venix/user/disable.tpl',
|
|
$root . '/resources/views/venix/user/paytaro.tpl',
|
|
$root . '/resources/views/venix/user/pay_success.tpl',
|
|
$root . '/resources/views/venix/user/invite.tpl',
|
|
$root . '/public/theme/venix/js/user-home.js',
|
|
$root . '/public/theme/venix/js/recharge.js',
|
|
];
|
|
$violations = UserCopyCoverageScanner::scanFiles($paths);
|
|
$assert($violations === [],
|
|
'Account/commerce pages retain direct user-visible copy: '
|
|
. json_encode($violations, JSON_UNESCAPED_UNICODE
|
|
| JSON_UNESCAPED_SLASHES));
|
|
|
|
$referenced = [];
|
|
foreach ($paths as $path) {
|
|
$source = (string) file_get_contents($path);
|
|
preg_match_all(
|
|
'/(?:user_copy\s+key=|\bt\()[\'\"]((?:account|recharge|invite)\.[a-z0-9_.]+)[\'\"]/',
|
|
$source,
|
|
$matches
|
|
);
|
|
array_push($referenced, ...$matches[1]);
|
|
}
|
|
foreach (array_unique($referenced) as $key) {
|
|
$assert(isset($entries[$key]),
|
|
'Account/commerce source references an undeclared key: ' . $key);
|
|
}
|
|
|
|
$homeModule = (string) file_get_contents(
|
|
$root . '/public/theme/venix/js/user-home.js'
|
|
);
|
|
$rechargeModule = (string) file_get_contents(
|
|
$root . '/public/theme/venix/js/recharge.js'
|
|
);
|
|
$assert(!preg_match('/data\.(?:msg|errmsg)|error\.message/',
|
|
$homeModule . "\n" . $rechargeModule)
|
|
&& !preg_match('/payload\?\.(?:detail|message|msg|error)/',
|
|
$homeModule . "\n" . $rechargeModule),
|
|
'Account/commerce feedback must not expose raw backend messages.');
|
|
$assert(str_contains($homeModule,
|
|
'responseMessage(data, "account.email.updated", "account.email.update_failed")')
|
|
&& str_contains($homeModule,
|
|
'responseMessage(data, "invite.withdraw.submitted", "invite.withdraw.failed")')
|
|
&& str_contains($rechargeModule,
|
|
'? "recharge.payment.expired" : "recharge.payment.failed"'),
|
|
'Account mutations and payment states must resolve through stable copy keys.');
|
|
|
|
foreach ([
|
|
'WALLET', 'REFERRAL LINK', '>Payment<', '>Order Status<',
|
|
] as $targetTranslation) {
|
|
$templates = implode("\n", array_map(
|
|
static fn (string $path): string => (string) file_get_contents($path),
|
|
array_slice($paths, 0, 5)
|
|
));
|
|
$assert(!str_contains($templates, $targetTranslation),
|
|
'Target-locale copy must not remain in source templates: '
|
|
. $targetTranslation);
|
|
}
|
|
|
|
echo "Account, recharge and invite user-copy contracts passed.\n";
|