优化存点
This commit is contained in:
@@ -12,8 +12,10 @@ use App\Events\MessageSent;
|
||||
use App\Models\Department;
|
||||
use App\Models\Position;
|
||||
use App\Models\Room;
|
||||
use App\Models\Sysparam;
|
||||
use App\Models\User;
|
||||
use App\Models\UserPosition;
|
||||
use App\Models\VipLevel;
|
||||
use App\Support\PositionPermissionRegistry;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
@@ -21,6 +23,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
@@ -149,6 +152,63 @@ class ChatControllerTest extends TestCase
|
||||
$this->assertSame($position?->department?->name, $authorizedPayload['department_name'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试手动存点接口会返回部门、职务与会员展示字段,供前端复用自动存点格式。
|
||||
*/
|
||||
public function test_heartbeat_returns_identity_summary_for_save_notice(): void
|
||||
{
|
||||
Sysparam::updateOrCreate(['alias' => 'exp_per_heartbeat'], ['body' => '0']);
|
||||
Sysparam::updateOrCreate(['alias' => 'jjb_per_heartbeat'], ['body' => '0']);
|
||||
Sysparam::updateOrCreate(['alias' => 'auto_event_chance'], ['body' => '0']);
|
||||
Sysparam::updateOrCreate(['alias' => 'superlevel'], ['body' => '100']);
|
||||
Cache::flush();
|
||||
|
||||
$room = Room::create([
|
||||
'room_name' => 'hbident',
|
||||
'door_open' => true,
|
||||
]);
|
||||
$vipLevel = VipLevel::factory()->create([
|
||||
'name' => '至尊会员',
|
||||
'icon' => '👑',
|
||||
]);
|
||||
$user = User::factory()->create([
|
||||
'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,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('chat.heartbeat', $room->id));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonPath('data.identity_summary', '部门 办公厅 · 职务 🏛️ 厅长 · 会员 👑 至尊会员');
|
||||
$response->assertJsonPath('data.department_name', '办公厅');
|
||||
$response->assertJsonPath('data.position_name', '厅长');
|
||||
$response->assertJsonPath('data.vip_name', '至尊会员');
|
||||
$response->assertJsonPath('data.vip_icon', '👑');
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试聊天室 Presence 频道会返回仍在有效期内的当日状态载荷。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user