'docs', 'token_hash' => hash('sha256', 'x')]); $user = User::create(['login' => 'n', 'tz' => 'UTC', 'quiet_start' => '22:00:00', 'quiet_end' => '09:00:00']); $channel = Channel::create(['user_id' => $user->id, 'type' => ChannelType::Webhook, 'config' => ['deliver_url' => 'u', 'presence_url' => 'p'], 'enabled' => true]); $this->event = Event::create([ 'source_id' => $source->id, 'user_id' => $user->id, 'source_ref' => 'r', 'topic' => '', 'due_mode' => DueMode::Local, 'due_date' => '2026-09-30', 'due_time' => '24:00:00', 'fire_on' => '2026-09-30', 'after_due' => AfterDue::Keep, 'payload' => ['title' => 'T'], 'state' => EventState::Today, 'quiet_until' => CarbonImmutable::parse('2000-01-01Z'), ]); Delivery::create(['event_id' => $this->event->id, 'channel_id' => $channel->id, 'window_start' => now(), 'action_token' => 'tok', 'result' => DeliveryResult::Ok]); } protected function tearDown(): void { CarbonImmutable::setTestNow(); parent::tearDown(); } public function test_ack_by_token(): void { $this->postJson('/a/tok/ack')->assertOk()->assertJsonPath('state', 'today'); $this->assertSame('2026-09-30T13:00:00+00:00', $this->event->fresh()->quiet_until->toIso8601String()); } public function test_public_route_sets_no_session_cookie(): void { $this->postJson('/a/tok/ack')->assertOk()->assertHeaderMissing('Set-Cookie'); } public function test_done_by_token_then_gone(): void { $this->postJson('/a/tok/done')->assertOk()->assertJsonPath('state', 'done'); $this->assertSame(EventState::Done, $this->event->fresh()->state); $this->postJson('/a/tok/done')->assertStatus(410); $this->postJson('/a/tok/ack')->assertStatus(410); } public function test_unknown_token(): void { $this->postJson('/a/nope/done')->assertNotFound(); } }