'exp_per_heartbeat'], ['body' => '0']); Sysparam::updateOrCreate(['alias' => 'jjb_per_heartbeat'], ['body' => '0']); Sysparam::updateOrCreate(['alias' => 'superlevel'], ['body' => '100']); Cache::flush(); $room = Room::create(['room_name' => 'asave']); $vipLevel = VipLevel::factory()->create([ 'name' => '至尊会员', 'icon' => '👑', ]); $user = User::factory()->create([ 'username' => 'autosave-user', 'user_level' => 100, 'exp_num' => 168762, 'jjb' => 1100017, 'vip_level_id' => $vipLevel->id, 'hy_time' => now()->addDay(), ]); $department = Department::create([ 'name' => '办公厅', 'rank' => 100, 'color' => '#1d4ed8', 'sort_order' => 1, ]); $position = Position::create([ 'department_id' => $department->id, 'name' => '厅长', 'icon' => '🏛️', 'rank' => 100, 'level' => 100, 'sort_order' => 1, ]); UserPosition::create([ 'user_id' => $user->id, 'position_id' => $position->id, 'appointed_at' => now(), 'is_active' => true, ]); Redis::hset("room:{$room->id}:users", $user->username, json_encode(['username' => $user->username], JSON_UNESCAPED_UNICODE)); $this->artisan('chatroom:auto-save-exp')->assertSuccessful(); $messages = collect(Redis::lrange("room:{$room->id}:messages", 0, -1)) ->map(fn (string $message): array => json_decode($message, true)); $notice = $messages->first(fn (array $message): bool => ($message['to_user'] ?? '') === $user->username); $this->assertIsArray($notice); $this->assertStringContainsString('部门 办公厅 · 职务 🏛️ 厅长 · 会员 👑 至尊会员', $notice['content']); $this->assertStringContainsString('LV.100 · 经验 168762 · 金币 1100017 · 已满级 ✓', $notice['content']); } }