Les administrateurs ont besoin d'un moyen simple pour inviter les parents à rejoindre la plateforme. Cette fonctionnalité permet de générer des codes d'invitation uniques (8 caractères alphanumériques) avec une validité de 48h, de les envoyer par email, et de les activer via une page publique dédiée qui crée automatiquement le compte parent. L'interface d'administration offre l'envoi unitaire et en masse, le renvoi, le filtrage par statut, ainsi que la visualisation de l'état de chaque invitation (en attente, activée, expirée).
72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Administration\Domain\Model\Invitation;
|
|
|
|
use App\Administration\Domain\Exception\InvitationCodeInvalideException;
|
|
use App\Administration\Domain\Model\Invitation\InvitationCode;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class InvitationCodeTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function constructWithValidCodeCreatesInstance(): void
|
|
{
|
|
$code = new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4');
|
|
|
|
self::assertSame('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', $code->value);
|
|
}
|
|
|
|
#[Test]
|
|
public function constructWithEmptyStringThrowsException(): void
|
|
{
|
|
$this->expectException(InvitationCodeInvalideException::class);
|
|
|
|
new InvitationCode('');
|
|
}
|
|
|
|
#[Test]
|
|
public function constructWithTooShortCodeThrowsException(): void
|
|
{
|
|
$this->expectException(InvitationCodeInvalideException::class);
|
|
|
|
new InvitationCode('abc123');
|
|
}
|
|
|
|
#[Test]
|
|
public function constructWithTooLongCodeThrowsException(): void
|
|
{
|
|
$this->expectException(InvitationCodeInvalideException::class);
|
|
|
|
new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4extra');
|
|
}
|
|
|
|
#[Test]
|
|
public function equalsReturnsTrueForSameValue(): void
|
|
{
|
|
$code1 = new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4');
|
|
$code2 = new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4');
|
|
|
|
self::assertTrue($code1->equals($code2));
|
|
}
|
|
|
|
#[Test]
|
|
public function equalsReturnsFalseForDifferentValue(): void
|
|
{
|
|
$code1 = new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4');
|
|
$code2 = new InvitationCode('11111111111111111111111111111111');
|
|
|
|
self::assertFalse($code1->equals($code2));
|
|
}
|
|
|
|
#[Test]
|
|
public function toStringReturnsValue(): void
|
|
{
|
|
$code = new InvitationCode('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4');
|
|
|
|
self::assertSame('a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4', (string) $code);
|
|
}
|
|
}
|