tests/Entity/UserExtendedTest.php (8 nouveaux tests): - testSetIsEmailAuthEnabled: active l'auth email, verifie true sans keycloakId et false avec keycloakId - testSetIsGoogleAuthEnabled: active Google Auth + secret - testClearTempPassword: verifie clearTempPassword() met hasTempPassword a false - testGenerateBackupCodes: genere 5 codes, verifie le count - testSerializeUnserialize: serialise/deserialise, verifie l'email - testCreatedAt: verifie le type DateTimeImmutable - testUpdatedAt: null par defaut - testEraseCredentials: appel sans erreur tests/Entity/RevendeurTest.php (nouveau, 10 tests): - testConstructor: id null, codeRevendeur, user, createdAt, isActive - testRaisonSociale: get/set nullable - testSiret: get/set - testAddress: address, zipCode, city - testContact: email, phone - testStripeConnect: stripeConnectId, isUseStripe - testStripeConnectState: state, statePayment, statePayout - testContratPdf: unsigned, signed, audit, submitterId - testActive: setIsActive false - testUpdatedAt: get/set nullable tests/Entity/ServiceTest.php (nouveau, 12 tests): - testConstructor: tous les champs par defaut - testSetName, testSetUrl, testSetStatus (avec message) - testExternal: isExternal, externalType - testPosition: get/set - testStatusHistory: collection vide - testCategory: verifie la relation - testComputeUptimeRatioAllUp: 2 entries up = 100% - testComputeUptimeRatioMixed: ratio entre 0 et 100 - testComputeUptimeRatioEmpty: pas d'historique = 100% tests/Entity/ServiceCategoryTest.php (nouveau, 3 tests): - testConstructor: name, slug, position 0, createdAt, services vide - testSetName: modification du nom - testSetPosition: modification de la position Resultat: 294 tests, 534 assertions, 0 failures, 0 deprecations, 0 notices Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
128 lines
4.3 KiB
PHP
128 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Revendeur;
|
|
use App\Entity\User;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class RevendeurTest extends TestCase
|
|
{
|
|
private function createRevendeur(): Revendeur
|
|
{
|
|
$user = new User();
|
|
$user->setEmail('r@test.com');
|
|
$user->setFirstName('Jane');
|
|
$user->setLastName('Smith');
|
|
$user->setPassword('h');
|
|
|
|
return new Revendeur($user, 'SC-0001');
|
|
}
|
|
|
|
public function testConstructor(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertNull($rev->getId());
|
|
$this->assertSame('SC-0001', $rev->getCodeRevendeur());
|
|
$this->assertSame('Jane', $rev->getUser()->getFirstName());
|
|
$this->assertInstanceOf(\DateTimeImmutable::class, $rev->getCreatedAt());
|
|
$this->assertTrue($rev->isActive());
|
|
}
|
|
|
|
public function testRaisonSociale(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertNull($rev->getRaisonSociale());
|
|
$rev->setRaisonSociale('SARL Test');
|
|
$this->assertSame('SARL Test', $rev->getRaisonSociale());
|
|
}
|
|
|
|
public function testSiret(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$rev->setSiret('12345678901234');
|
|
$this->assertSame('12345678901234', $rev->getSiret());
|
|
}
|
|
|
|
public function testAddress(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$rev->setAddress('1 rue Test');
|
|
$rev->setZipCode('02100');
|
|
$rev->setCity('Saint-Quentin');
|
|
$this->assertSame('1 rue Test', $rev->getAddress());
|
|
$this->assertSame('02100', $rev->getZipCode());
|
|
$this->assertSame('Saint-Quentin', $rev->getCity());
|
|
}
|
|
|
|
public function testContact(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$rev->setEmail('contact@test.fr');
|
|
$rev->setPhone('0612345678');
|
|
$this->assertSame('contact@test.fr', $rev->getEmail());
|
|
$this->assertSame('0612345678', $rev->getPhone());
|
|
}
|
|
|
|
public function testStripeConnect(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertNull($rev->getStripeConnectId());
|
|
$this->assertFalse($rev->isUseStripe());
|
|
|
|
$rev->setStripeConnectId('acct_xxx');
|
|
$rev->setIsUseStripe(true);
|
|
$this->assertSame('acct_xxx', $rev->getStripeConnectId());
|
|
$this->assertTrue($rev->isUseStripe());
|
|
}
|
|
|
|
public function testStripeConnectState(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertSame('not_started', $rev->getStripeConnectState());
|
|
$this->assertNull($rev->getStripeConnectStatePayment());
|
|
$this->assertNull($rev->getStripeConnectStatePayout());
|
|
|
|
$rev->setStripeConnectState('active');
|
|
$rev->setStripeConnectStatePayment('enabled');
|
|
$rev->setStripeConnectStatePayout('enabled');
|
|
$this->assertSame('active', $rev->getStripeConnectState());
|
|
$this->assertSame('enabled', $rev->getStripeConnectStatePayment());
|
|
$this->assertSame('enabled', $rev->getStripeConnectStatePayout());
|
|
}
|
|
|
|
public function testContratPdf(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertNull($rev->getContratResellerPdfUnsigned());
|
|
$this->assertNull($rev->getContratResellerPdfSigned());
|
|
$this->assertNull($rev->getContratResellerPdfAudit());
|
|
$this->assertNull($rev->getContratSubmitterId());
|
|
|
|
$rev->setContratResellerPdfUnsigned('/path/unsigned.pdf');
|
|
$rev->setContratResellerPdfSigned('/path/signed.pdf');
|
|
$rev->setContratResellerPdfAudit('/path/audit.pdf');
|
|
$rev->setContratSubmitterId(42);
|
|
$this->assertSame('/path/unsigned.pdf', $rev->getContratResellerPdfUnsigned());
|
|
$this->assertSame('/path/signed.pdf', $rev->getContratResellerPdfSigned());
|
|
$this->assertSame('/path/audit.pdf', $rev->getContratResellerPdfAudit());
|
|
$this->assertSame(42, $rev->getContratSubmitterId());
|
|
}
|
|
|
|
public function testActive(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$rev->setIsActive(false);
|
|
$this->assertFalse($rev->isActive());
|
|
}
|
|
|
|
public function testUpdatedAt(): void
|
|
{
|
|
$rev = $this->createRevendeur();
|
|
$this->assertNull($rev->getUpdatedAt());
|
|
$date = new \DateTimeImmutable();
|
|
$rev->setUpdatedAt($date);
|
|
$this->assertSame($date, $rev->getUpdatedAt());
|
|
}
|
|
}
|