红包领取增加全员通知

This commit is contained in:
pllx
2026-04-30 15:52:16 +08:00
parent 9764961519
commit 92e3dd0cdf
3 changed files with 47 additions and 20 deletions
+18
View File
@@ -1,5 +1,11 @@
<?php
/**
* 文件功能:礼包红包控制器功能测试
*
* 覆盖礼包发放权限、领取入账、领取广播、状态查询和重复领取约束。
*/
namespace Tests\Feature;
use App\Events\RedPacketClaimed;
@@ -262,6 +268,18 @@ class RedPacketControllerTest extends TestCase
&& $event->remainingCount === 9
&& $event->type === 'gold';
});
$messages = Redis::lrange('room:1:messages', 0, -1);
$publicMessage = collect($messages)
->map(fn (string $item) => json_decode($item, true))
->first(fn (array $item) => ($item['to_user'] ?? null) === '大家'
&& ($item['toast_notification']['title'] ?? null) === '🧧 有人领取红包'
&& str_contains((string) ($item['toast_notification']['message'] ?? ''), $user->username));
$this->assertNotNull($publicMessage);
$this->assertFalse((bool) ($publicMessage['is_secret'] ?? true));
$this->assertStringContainsString('金币礼包', (string) ($publicMessage['toast_notification']['message'] ?? ''));
$this->assertSame('🧧', $publicMessage['toast_notification']['icon'] ?? null);
}
/**