repository = new InMemoryParentInvitationRepository(); $clock = new class implements Clock { public function now(): DateTimeImmutable { return new DateTimeImmutable('2026-02-14 10:00:00'); } }; $this->handler = new ResendParentInvitationHandler( $this->repository, new InvitationCodeGenerator(), $clock, ); } #[Test] public function itResendsInvitationWithNewCode(): void { $invitation = $this->createSentInvitation(); $oldCode = (string) $invitation->code; $result = ($this->handler)(new ResendParentInvitationCommand( invitationId: (string) $invitation->id, tenantId: self::TENANT_ID, )); self::assertSame(InvitationStatus::SENT, $result->status); self::assertNotSame($oldCode, (string) $result->code); } #[Test] public function itUpdatesExpirationDate(): void { $invitation = $this->createSentInvitation(); $oldExpiresAt = $invitation->expiresAt; $result = ($this->handler)(new ResendParentInvitationCommand( invitationId: (string) $invitation->id, tenantId: self::TENANT_ID, )); self::assertGreaterThan($oldExpiresAt, $result->expiresAt); } private function createSentInvitation(): ParentInvitation { $invitation = ParentInvitation::creer( tenantId: TenantId::fromString(self::TENANT_ID), studentId: UserId::generate(), parentEmail: new Email('parent@example.com'), code: new InvitationCode(str_repeat('a', 32)), createdAt: new DateTimeImmutable('2026-02-07 10:00:00'), createdBy: UserId::generate(), ); $invitation->envoyer(new DateTimeImmutable('2026-02-07 10:00:00')); $invitation->pullDomainEvents(); $this->repository->save($invitation); return $invitation; } }