feat: 增强风险池 Redis 操作,添加 TTL 支持并更新相关 Lua 脚本;新增 API 异常响应测试

This commit is contained in:
2026-06-09 17:06:05 +08:00
parent a0c3b8a1ff
commit 5bd7517ce9
6 changed files with 116 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
<?php
use App\Lottery\ErrorCode;
use Illuminate\Support\Facades\Route;
test('api internal exception response includes structured details in testing', function (): void {
Route::get('/api/v1/test-error-detail', function (): void {
throw new RuntimeException('测试异常明细');
});
$response = $this->getJson('/api/v1/test-error-detail');
$response
->assertStatus(500)
->assertJsonPath('code', ErrorCode::InternalError->value)
->assertJsonPath('msg', '测试异常明细')
->assertJsonPath('data.exception', RuntimeException::class)
->assertJsonPath('data.message', '测试异常明细');
expect($response->json('data.error_id'))->not->toBeEmpty()
->and($response->json('data.file'))->toContain('ApiExceptionResponseTest.php')
->and($response->json('data.line'))->toBeInt()
->and($response->getContent())->toContain('测试异常明细')
->and($response->getContent())->not->toContain('\u6d4b\u8bd5\u5f02\u5e38\u660e\u7ec6');
});