- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
71 lines
2.3 KiB
PHP
71 lines
2.3 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('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)。');
|
||
});
|