create([ 'username' => 'admin_report', 'password_hash' => 'unused', 'name' => '管理员', 'status' => 'active', ])); $competition = Competition::query()->create([ 'slug' => 'hsxt-report', 'name' => '看板测试赛', 'published' => true, ]); foreach (['材料与芯片', '器件与模块', '场景与应用', '设备与服务'] as $i => $title) { CompetitionTrack::query()->create([ 'competition_id' => $competition->id, 'track_code' => 't'.($i + 1), 'title' => $title, 'sort' => $i + 1, 'is_enabled' => true, ]); } Application::query()->create([ 'user_id' => User::query()->create(['mobile' => '13800138801'])->id, 'competition_id' => $competition->id, 'status' => 'submitted', 'project_name' => '已报名项目', 'track' => 't1', 'degree' => 'bachelor', 'location_country' => 'cn', 'event_location' => 'shanghai', ]); $response = $this->getJson("/api/v1/admin/competitions/{$competition->id}/manage/report") ->assertOk(); $this->assertSame( ['材料与芯片', '器件与模块', '场景与应用', '设备与服务'], collect($response->json('track_counts'))->pluck('label')->all() ); $this->assertSame(1, $response->json('track_counts.0.count')); $this->assertSame(0, $response->json('track_counts.1.count')); $this->assertSame( ['大专', '本科', '硕士', '博士', '其他'], collect($response->json('degree_counts'))->pluck('label')->all() ); $this->assertSame( ['中国', '海外'], collect($response->json('country_counts'))->pluck('label')->all() ); $this->assertSame( ['上海赛区', '苏州赛区', '深圳赛区'], collect($response->json('event_location_counts'))->pluck('label')->all() ); $this->assertSame( ['材料与芯片', '器件与模块', '场景与应用', '设备与服务'], collect($response->json('track_score_rank'))->pluck('track')->all() ); } }