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.
49 lines
1.8 KiB
PHTML
49 lines
1.8 KiB
PHTML
|
4 weeks ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$controller = file_get_contents(
|
||
|
|
$root . '/app/Controllers/Admin/UserController.php'
|
||
|
|
);
|
||
|
|
$list = file_get_contents(
|
||
|
|
$root . '/resources/views/venix/admin/user/index.tpl'
|
||
|
|
);
|
||
|
|
$edit = file_get_contents(
|
||
|
|
$root . '/resources/views/venix/admin/user/edit.tpl'
|
||
|
|
);
|
||
|
|
|
||
|
|
$assert = static function (bool $condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$assert(is_string($controller) && is_string($list) && is_string($edit),
|
||
|
|
'Administrator user sources could not be read.');
|
||
|
|
$assert(str_contains($edit, 'id="userProfile"')
|
||
|
|
&& str_contains($edit, 'href="#userProfile"')
|
||
|
|
&& str_contains($edit, '此处仅展示用户保存的账户资料'),
|
||
|
|
'The administrator user page is missing its read-only account profile.');
|
||
|
|
|
||
|
|
$fields = [
|
||
|
|
'last_name', 'first_name', 'phone', 'country',
|
||
|
|
'province', 'city', 'address', 'postal_code',
|
||
|
|
];
|
||
|
|
foreach ($fields as $field) {
|
||
|
|
$assert(str_contains($controller, "'" . $field . "' =>")
|
||
|
|
&& str_contains($controller, "->orWhere('" . $field . "', 'LIKE'")
|
||
|
|
&& str_contains($list, "'" . $field . "'")
|
||
|
|
&& str_contains($list, "key: '" . $field . "'")
|
||
|
|
&& str_contains($list, $field . ': stripHtml(row.' . $field . ')')
|
||
|
|
&& preg_match('/id="' . preg_quote($field, '/')
|
||
|
|
. '"[^\r\n]*\breadonly\b/', $edit) === 1,
|
||
|
|
'Administrator profile display is incomplete for ' . $field . '.');
|
||
|
|
}
|
||
|
|
|
||
|
|
$assert(str_contains($controller,
|
||
|
|
"'phone' => AdminDataMasker::paymentAccount(\$user->phone)")
|
||
|
|
&& str_contains($controller,
|
||
|
|
"'address' => AdminDataMasker::account(\$user->address)"),
|
||
|
|
'Administrator list profile data must preserve role-based masking.');
|
||
|
|
|
||
|
|
echo "Administrator account profile display checks passed.\n";
|