完善跑马面板与控制器逻辑
This commit is contained in:
@@ -307,6 +307,52 @@ class HorseRaceControllerTest extends TestCase
|
||||
$this->assertCount(1, $response->json('history'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:验证赛马接口可兼容旧场次中的异常马匹结构,不返回 PHP 警告页。
|
||||
*/
|
||||
public function test_horse_race_endpoints_tolerate_legacy_horse_payloads(): void
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::factory()->create(['jjb' => 3456]);
|
||||
|
||||
HorseRace::create([
|
||||
'status' => 'settled',
|
||||
'bet_opens_at' => now()->subMinutes(3),
|
||||
'bet_closes_at' => now()->subMinutes(2),
|
||||
'settled_at' => now()->subMinute(),
|
||||
'winner_horse_id' => 2,
|
||||
'horses' => [
|
||||
['name' => '旧赤兔'],
|
||||
'legacy-string-entry',
|
||||
['id' => 2, 'emoji' => '⚡'],
|
||||
],
|
||||
'total_bets' => 1,
|
||||
'total_pool' => 200,
|
||||
]);
|
||||
|
||||
HorseRace::create([
|
||||
'status' => 'betting',
|
||||
'bet_opens_at' => now()->subSeconds(10),
|
||||
'bet_closes_at' => now()->addMinute(),
|
||||
'horses' => [
|
||||
['name' => '缺编号旧马'],
|
||||
['id' => 2, 'emoji' => '🏇'],
|
||||
null,
|
||||
],
|
||||
'total_bets' => 0,
|
||||
'total_pool' => 0,
|
||||
]);
|
||||
|
||||
$currentResponse = $this->actingAs($user)->getJson(route('horse-race.current'));
|
||||
$historyResponse = $this->actingAs($user)->getJson(route('horse-race.history'));
|
||||
|
||||
$currentResponse->assertOk();
|
||||
$historyResponse->assertOk();
|
||||
$this->assertSame('缺编号旧马', $currentResponse->json('race.horses.0.name'));
|
||||
$this->assertSame('🐎', $currentResponse->json('race.horses.0.emoji'));
|
||||
$this->assertSame('⚡未知马匹', $historyResponse->json('history.0.winner_name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:验证单个赢家至少拿回本金,并可获得种子池补贴。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user