- Updated AGENTS.md to clarify agent account restrictions and permissions. - Implemented checks in AgentNodeAdminUserStoreController and AgentNodeRoleStoreController to restrict admin user and role creation to the agent's own node. - Enhanced validation in AdminPlayerStoreController and AdminPlayerUpdateController to enforce credit limit and rebate rate rules based on player funding mode. - Refactored various request classes to utilize shared admin account field rules for consistency. - Improved error handling in services related to credit allocation and rebate limits to ensure proper validation and messaging.
83 lines
2.9 KiB
PHP
83 lines
2.9 KiB
PHP
<?php
|
||
|
||
use App\Support\ApiValidationErrors;
|
||
|
||
test('normalizes english regex error for code field in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(
|
||
['code' => ['The code field format is invalid.']],
|
||
'zh',
|
||
);
|
||
|
||
expect($errors['code'][0])->toContain('编码只能使用字母、数字');
|
||
});
|
||
|
||
test('normalizes business shorthand unique in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(['code' => ['unique']], 'zh');
|
||
|
||
expect($errors['code'][0])->toBe('该内容已存在,请更换后重试。');
|
||
});
|
||
|
||
test('normalizes rebate exceeds limit with field specific message in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(['rebate_rate' => ['exceeds_limit']], 'zh');
|
||
|
||
expect($errors['rebate_rate'][0])->toBe('回水比例不能超过代理回水上限。');
|
||
});
|
||
|
||
test('normalizes settlement bill not payable in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(['bill' => ['not_payable']], 'zh');
|
||
|
||
expect($errors['bill'][0])->toBe('当前账单状态不允许登记收付,请先确认账单。');
|
||
});
|
||
|
||
test('summary joins multiple field errors', function (): void {
|
||
$normalized = [
|
||
'code' => ['编码格式不正确。'],
|
||
'name' => ['名称不能为空。'],
|
||
];
|
||
|
||
expect(ApiValidationErrors::summary($normalized))->toBe('编码格式不正确。;名称不能为空。');
|
||
});
|
||
|
||
test('keeps already localized chinese messages', function (): void {
|
||
$message = '最小下注额不能小于 0';
|
||
$errors = ApiValidationErrors::normalize(['items.0.min_bet_amount' => [$message]], 'zh');
|
||
|
||
expect($errors['items.0.min_bet_amount'][0])->toBe($message);
|
||
});
|
||
|
||
test('normalizes english min length for password in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(
|
||
['password' => ['The password field must be at least 8 characters.']],
|
||
'zh',
|
||
);
|
||
|
||
expect($errors['password'][0])->toBe('密码至少需要 8 个字符。');
|
||
});
|
||
|
||
test('normalizes exact draw items message in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(
|
||
['items' => ['items must contain the complete 23 draw prize slots.']],
|
||
'zh',
|
||
);
|
||
|
||
expect($errors['items'][0])->toContain('23');
|
||
});
|
||
|
||
test('normalizes compact english max for rebate rate in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(
|
||
['rebate_rate' => ['rebate rate must not be greater than 1.']],
|
||
'zh',
|
||
);
|
||
|
||
expect($errors['rebate_rate'][0])->toBe('回水比例不能超过 1(100% 记为 1)。');
|
||
});
|
||
|
||
test('normalizes compact english max for rebate limit in zh', function (): void {
|
||
$errors = ApiValidationErrors::normalize(
|
||
['rebate_limit' => ['rebate limit must not be greater than 1.']],
|
||
'zh',
|
||
);
|
||
|
||
expect($errors['rebate_limit'][0])->toBe('回水上限不能超过 1(100% 记为 1)。');
|
||
});
|