feat: entité DomainEmail liée à Domain avec migration
Entity DomainEmail : - domain (ManyToOne, CASCADE) : domaine parent - name : partie locale de l'email (lowercase auto, ex: contact) - state : active/suspended/disabled (défaut active) - quotaMb : quota en Mo (défaut 5120 = 5 Go) - createdAt / updatedAt : timestamps (updatedAt auto sur setState) - getFullEmail() : retourne name@domain.fqdn - isActive() : vérifie si state === active DomainEmailTest (3 tests, 19 assertions) : - testConstructor : valeurs par défaut, name lowercase/trim, fullEmail - testSetters : name, quotaMb, updatedAt - testState : active→suspended→disabled, updatedAt mis à jour Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
71
tests/Entity/DomainEmailTest.php
Normal file
71
tests/Entity/DomainEmailTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\DomainEmail;
|
||||
use App\Entity\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DomainEmailTest extends TestCase
|
||||
{
|
||||
private function createDomain(): Domain
|
||||
{
|
||||
$user = new User();
|
||||
$user->setEmail('c@t.com');
|
||||
$user->setFirstName('C');
|
||||
$user->setLastName('T');
|
||||
$user->setPassword('h');
|
||||
|
||||
return new Domain(new Customer($user), 'siteconseil.fr');
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$domain = $this->createDomain();
|
||||
$email = new DomainEmail($domain, ' Contact ');
|
||||
|
||||
$this->assertNull($email->getId());
|
||||
$this->assertSame($domain, $email->getDomain());
|
||||
$this->assertSame('contact', $email->getName());
|
||||
$this->assertSame('contact@siteconseil.fr', $email->getFullEmail());
|
||||
$this->assertSame(DomainEmail::STATE_ACTIVE, $email->getState());
|
||||
$this->assertTrue($email->isActive());
|
||||
$this->assertSame(5120, $email->getQuotaMb());
|
||||
$this->assertInstanceOf(\DateTimeImmutable::class, $email->getCreatedAt());
|
||||
$this->assertNull($email->getUpdatedAt());
|
||||
}
|
||||
|
||||
public function testSetters(): void
|
||||
{
|
||||
$email = new DomainEmail($this->createDomain(), 'info');
|
||||
|
||||
$email->setName(' Support ');
|
||||
$this->assertSame('support', $email->getName());
|
||||
$this->assertSame('support@siteconseil.fr', $email->getFullEmail());
|
||||
|
||||
$email->setQuotaMb(10240);
|
||||
$this->assertSame(10240, $email->getQuotaMb());
|
||||
|
||||
$now = new \DateTimeImmutable();
|
||||
$email->setUpdatedAt($now);
|
||||
$this->assertSame($now, $email->getUpdatedAt());
|
||||
}
|
||||
|
||||
public function testState(): void
|
||||
{
|
||||
$email = new DomainEmail($this->createDomain(), 'test');
|
||||
|
||||
$this->assertTrue($email->isActive());
|
||||
|
||||
$email->setState(DomainEmail::STATE_SUSPENDED);
|
||||
$this->assertSame(DomainEmail::STATE_SUSPENDED, $email->getState());
|
||||
$this->assertFalse($email->isActive());
|
||||
$this->assertInstanceOf(\DateTimeImmutable::class, $email->getUpdatedAt());
|
||||
|
||||
$email->setState(DomainEmail::STATE_DISABLED);
|
||||
$this->assertSame(DomainEmail::STATE_DISABLED, $email->getState());
|
||||
$this->assertFalse($email->isActive());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user