Files
crm_ecosplay/tests/Entity/EmailTrackingTest.php
Serreau Jovann 48dd36e1ae test: ajout tests Customer, EmailTracking, MessengerLog, PriceAutomatic
tests/Entity/CustomerTest.php (nouveau, 11 tests):
- testConstructor: id null, user, state active, createdAt, updatedAt null
- testCodeComptable: get/set nullable
- testGenerateCodeComptable: genere un code non vide
- testNames: firstName, lastName, fullName
- testRaisonSociale: get/set
- testContact: email, phone
- testAddress: address, address2, zipCode, city
- testLegal: siret, rcs, numTva
- testStripe: stripeCustomerId get/set nullable
- testTypeCompany: set TYPE_SARL
- testState: setState suspended, isActive false

tests/Entity/EmailTrackingTest.php (nouveau, 4 tests):
- testConstructor: messageId, recipient, subject, htmlBody, attachments,
  state='sent', sentAt DateTimeImmutable, openedAt null
- testConstructorWithoutOptionals: htmlBody et attachments null
- testMarkAsOpened: state='opened', openedAt set
- testMarkAsOpenedOnlyOnce: deuxieme appel ne change pas openedAt

tests/Entity/MessengerLogTest.php (nouveau, 4 tests):
- testConstructor: tous les champs avec valeurs, status='failed',
  createdAt et failedAt DateTimeImmutable
- testConstructorMinimal: messageBody, stackTrace, transportName null,
  retryCount 0
- testSetStatus: change le status
- testMarkAsResolved: status passe a 'resolved'

tests/Entity/PriceAutomaticTest.php (nouveau, 2 tests):
- testGettersSetters: tous les champs avec valeurs
- testNullables: description, stripeId, stripeAbonnementId null

Resultat: 315 tests, 605 assertions, 0 failures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 00:00:43 +02:00

51 lines
1.7 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\EmailTracking;
use PHPUnit\Framework\TestCase;
class EmailTrackingTest extends TestCase
{
public function testConstructor(): void
{
$t = new EmailTracking('msg-123', 'to@test.com', 'Subject', '<h1>Hi</h1>', [['path' => '/f.pdf', 'name' => 'f.pdf']]);
$this->assertNull($t->getId());
$this->assertSame('msg-123', $t->getMessageId());
$this->assertSame('to@test.com', $t->getRecipient());
$this->assertSame('Subject', $t->getSubject());
$this->assertSame('<h1>Hi</h1>', $t->getHtmlBody());
$this->assertCount(1, $t->getAttachments());
$this->assertSame('sent', $t->getState());
$this->assertInstanceOf(\DateTimeImmutable::class, $t->getSentAt());
$this->assertNull($t->getOpenedAt());
}
public function testConstructorWithoutOptionals(): void
{
$t = new EmailTracking('msg-456', 'to@test.com', 'Test');
$this->assertNull($t->getHtmlBody());
$this->assertNull($t->getAttachments());
}
public function testMarkAsOpened(): void
{
$t = new EmailTracking('msg-789', 'to@test.com', 'Test');
$this->assertNull($t->getOpenedAt());
$t->markAsOpened();
$this->assertSame('opened', $t->getState());
$this->assertInstanceOf(\DateTimeImmutable::class, $t->getOpenedAt());
}
public function testMarkAsOpenedOnlyOnce(): void
{
$t = new EmailTracking('msg-abc', 'to@test.com', 'Test');
$t->markAsOpened();
$firstOpenedAt = $t->getOpenedAt();
$t->markAsOpened();
$this->assertSame($firstOpenedAt, $t->getOpenedAt());
}
}