feat: 添加货币组至设置控制器并更新测试用例
- 在 SettingIndexController 中新增 'currency' 组,以支持货币相关设置。 - 更新 PublicSettingsApiTest,新增测试用例以验证货币组的返回数据,确保 API 正确处理货币设置。
This commit is contained in:
@@ -17,6 +17,7 @@ final class SettingIndexController extends Controller
|
|||||||
/** @var list<string> */
|
/** @var list<string> */
|
||||||
private const PUBLIC_GROUPS = [
|
private const PUBLIC_GROUPS = [
|
||||||
'frontend',
|
'frontend',
|
||||||
|
'currency',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __invoke(Request $request): JsonResponse
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
|||||||
@@ -20,6 +20,22 @@ test('public settings requires allowed group', function (): void {
|
|||||||
->assertJsonPath('code', ErrorCode::ClientHttpError->value);
|
->assertJsonPath('code', ErrorCode::ClientHttpError->value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('public settings returns currency group', function (): void {
|
||||||
|
\App\Models\LotterySetting::query()->updateOrCreate(
|
||||||
|
['setting_key' => 'currency.display_decimals'],
|
||||||
|
[
|
||||||
|
'group_name' => 'currency',
|
||||||
|
'value_json' => 3,
|
||||||
|
'description_zh' => '展示小数位',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->getJson('/api/v1/settings?group=currency')
|
||||||
|
->assertOk()
|
||||||
|
->assertJsonPath('code', ErrorCode::Success->value)
|
||||||
|
->assertJsonFragment(['key' => 'currency.display_decimals', 'value' => 3]);
|
||||||
|
});
|
||||||
|
|
||||||
test('public settings returns frontend group only', function (): void {
|
test('public settings returns frontend group only', function (): void {
|
||||||
\App\Models\LotterySetting::query()->updateOrCreate(
|
\App\Models\LotterySetting::query()->updateOrCreate(
|
||||||
['setting_key' => 'frontend.play_rules_html_zh'],
|
['setting_key' => 'frontend.play_rules_html_zh'],
|
||||||
|
|||||||
Reference in New Issue
Block a user