红包领取增加全员通知
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user