getFirstName()); self::assertSame('Muster', $confirmation->getLastName()); self::assertSame([1, 2], $confirmation->getMailjetListIds()); } public function testConstructorConvertsBlankNamesToNull(): void { $confirmation = new NewsletterOptInRequest( 'customer@example.com', str_repeat('a', 64), new \DateTimeImmutable('+1 hour'), [], ' ', '', ); self::assertNull($confirmation->getFirstName()); self::assertNull($confirmation->getLastName()); } public function testRefreshRequestPreservesMissingNamesAndUpdatesProvidedValues(): void { $confirmation = new NewsletterOptInRequest( 'customer@example.com', str_repeat('a', 64), new \DateTimeImmutable('+1 hour'), [1], 'Mia', 'Muster', ); $confirmation->refreshRequest( str_repeat('b', 64), new \DateTimeImmutable('+2 hour'), [2, 1], null, 'Meyer', ); self::assertSame('Mia', $confirmation->getFirstName()); self::assertSame('Meyer', $confirmation->getLastName()); self::assertSame([1, 2], $confirmation->getMailjetListIds()); self::assertFalse($confirmation->isConfirmed()); } public function testMarkRevokedAndConfirmedLifecycleClearsRevocationState(): void { $confirmation = new NewsletterOptInRequest( 'customer@example.com', str_repeat('a', 64), new \DateTimeImmutable('+1 hour'), [1], 'Mia', 'Muster', ); $confirmation->markRevoked(new \DateTimeImmutable('2026-04-28 12:00:00')); self::assertTrue($confirmation->isRevoked()); self::assertNotNull($confirmation->getRevokedAt()); $confirmation->markConfirmed(new \DateTimeImmutable('2026-04-28 12:05:00')); self::assertFalse($confirmation->isRevoked()); self::assertNull($confirmation->getRevokedAt()); $confirmation->markRevoked(new \DateTimeImmutable('2026-04-28 12:10:00')); $confirmation->refreshRequest( str_repeat('b', 64), new \DateTimeImmutable('+2 hour'), [2, 1], 'New', null, ); self::assertFalse($confirmation->isRevoked()); self::assertNull($confirmation->getRevokedAt()); self::assertSame('New', $confirmation->getFirstName()); self::assertSame('Muster', $confirmation->getLastName()); } }