feat: MailJet list handling with DOI, webhook receiver and API endpoint
addresses #869cut134
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\NewsletterOptInRequest;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NewsletterOptInRequestTest extends TestCase
|
||||
{
|
||||
public function testConstructorNormalizesNames(): void
|
||||
{
|
||||
$confirmation = new NewsletterOptInRequest(
|
||||
'[email protected]',
|
||||
str_repeat('a', 64),
|
||||
new \DateTimeImmutable('+1 hour'),
|
||||
[2, 1],
|
||||
' Mia ',
|
||||
' Muster ',
|
||||
);
|
||||
|
||||
self::assertSame('Mia', $confirmation->getFirstName());
|
||||
self::assertSame('Muster', $confirmation->getLastName());
|
||||
self::assertSame([1, 2], $confirmation->getMailjetListIds());
|
||||
}
|
||||
|
||||
public function testConstructorConvertsBlankNamesToNull(): void
|
||||
{
|
||||
$confirmation = new NewsletterOptInRequest(
|
||||
'[email protected]',
|
||||
str_repeat('a', 64),
|
||||
new \DateTimeImmutable('+1 hour'),
|
||||
[],
|
||||
' ',
|
||||
'',
|
||||
);
|
||||
|
||||
self::assertNull($confirmation->getFirstName());
|
||||
self::assertNull($confirmation->getLastName());
|
||||
}
|
||||
|
||||
public function testRefreshRequestPreservesMissingNamesAndUpdatesProvidedValues(): void
|
||||
{
|
||||
$confirmation = new NewsletterOptInRequest(
|
||||
'[email protected]',
|
||||
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(
|
||||
'[email protected]',
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user