补充补签聊天室播报
This commit is contained in:
@@ -303,7 +303,10 @@ class DailySignInControllerTest extends TestCase
|
||||
*/
|
||||
public function test_user_can_makeup_missed_day_with_sign_repair_card(): void
|
||||
{
|
||||
Event::fake([MessageSent::class, UserStatusUpdated::class]);
|
||||
|
||||
$user = User::factory()->create(['jjb' => 0]);
|
||||
$room = Room::create(['room_name' => '补签通知房', 'door_open' => true]);
|
||||
SignInRewardRule::query()->updateOrCreate(['streak_days' => 1], [
|
||||
'streak_days' => 1,
|
||||
'gold_reward' => 10,
|
||||
@@ -333,9 +336,12 @@ class DailySignInControllerTest extends TestCase
|
||||
'sign_in_date' => '2026-04-24',
|
||||
'streak_days' => 1,
|
||||
]);
|
||||
Redis::hset("room:{$room->id}:users", $user->username, json_encode(['username' => $user->username], JSON_UNESCAPED_UNICODE));
|
||||
Redis::setex("room:{$room->id}:alive:{$user->username}", 90, 1);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('daily-sign-in.makeup'), [
|
||||
'target_date' => '2026-04-23',
|
||||
'room_id' => $room->id,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
@@ -368,6 +374,17 @@ class DailySignInControllerTest extends TestCase
|
||||
'source' => CurrencySource::SIGN_IN->value,
|
||||
'remark' => '补签 2026-04-23:当前连续签到 3 天',
|
||||
]);
|
||||
|
||||
$rawMessage = Redis::lindex("room:{$room->id}:messages", -1);
|
||||
$message = json_decode((string) $rawMessage, true);
|
||||
$this->assertSame('签到播报', $message['from_user']);
|
||||
$this->assertStringContainsString('使用补签卡补签 2026-04-23', $message['content']);
|
||||
$this->assertStringContainsString('当前连续签到 3 天', $message['content']);
|
||||
|
||||
Event::assertDispatched(MessageSent::class, function (MessageSent $event) use ($room): bool {
|
||||
return $event->roomId === $room->id
|
||||
&& str_contains((string) ($event->message['content'] ?? ''), '使用补签卡补签 2026-04-23');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user