修复节日福利过期补发
This commit is contained in:
@@ -145,6 +145,43 @@ class HolidayEventSchedulingTest extends TestCase
|
||||
$this->assertSame('2026-08-01 09:00:00', $event->fresh()?->send_at?->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:验证本地停机导致年度福利过期后,自动任务只推进到下一次计划,不补发旧批次。
|
||||
*/
|
||||
public function test_automatic_trigger_skips_expired_yearly_occurrences_after_downtime(): void
|
||||
{
|
||||
Event::fake([HolidayEventStarted::class, MessageSent::class]);
|
||||
Queue::fake([SaveMessageJob::class]);
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-05-09 11:00:00'));
|
||||
|
||||
$chatState = $this->createMock(ChatStateService::class);
|
||||
$chatState->expects($this->never())->method('nextMessageId');
|
||||
$chatState->expects($this->never())->method('pushMessage');
|
||||
|
||||
$event = $this->createYearlyEvent([
|
||||
'name' => '五一劳动节',
|
||||
'schedule_month' => 5,
|
||||
'schedule_day' => 1,
|
||||
'schedule_time' => '10:00',
|
||||
'duration_days' => 3,
|
||||
'daily_occurrences' => 4,
|
||||
'occurrence_interval_minutes' => 180,
|
||||
'send_at' => '2026-05-03 13:00:00',
|
||||
'expire_minutes' => 120,
|
||||
]);
|
||||
|
||||
(new TriggerHolidayEventJob($event))->handle($chatState, app(HolidayEventScheduleService::class));
|
||||
|
||||
$freshEvent = $event->fresh();
|
||||
|
||||
$this->assertSame('2027-05-01 10:00:00', $freshEvent?->send_at?->format('Y-m-d H:i:s'));
|
||||
$this->assertSame('pending', $freshEvent?->status);
|
||||
$this->assertDatabaseCount('holiday_event_runs', 0);
|
||||
Event::assertNotDispatched(HolidayEventStarted::class);
|
||||
Event::assertNotDispatched(MessageSent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:验证旧的 daily 重复模式仍按原逻辑继续推进。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user