Files
crm_ecosplay/tests/Entity/DomainTest.php
Serreau Jovann 8b35e2b6d2 feat: comptabilite + prestataires + rapport financier + stats dynamiques
Comptabilite (Super Admin) :
- ComptabiliteController avec 7 exports CSV/JSON compatibles SAGE
  (journal ventes, grand livre, FEC, balance agee, reglements,
  commissions Stripe 1.5%+0.25E, couts services)
- Export PDF via ComptaPdf (FPDF) avec bloc legal pre-rempli,
  tableau pagine, champ signature DocuSeal
- Signature electronique DocuSeal + callback + envoi email signe
  avec template dedie (compta_export_signed.html.twig)
- Rapport financier public (RapportFinancierPdf) : recettes par
  service, depenses (Stripe, infra, prestataires), bilan excedent/deficit
- Codes comptables clients EC-XXXX (plus de 411xxx)

Prestataires (Super Admin) :
- Entite Prestataire (raisonSociale, siret, email, phone, adresse)
- Entite FacturePrestataire (numFacture, montantHt, montantTtc,
  year, month, isPaid, PDF via Vich)
- CRUD complet avec recherche SIRET via proxy API data.gouv.fr
- Commande cron app:reminder:factures-prestataire (5 du mois)
- Factures prestataires integrees dans export couts services
- Sidebar Super Admin : entree Prestataires + Comptabilite

Stats (/admin/stats) :
- Cout prestataire dynamique depuis FacturePrestataire
- Fusion Infra + Prestataire en "Cout de fonctionnement"
- Commission Stripe corrigee (1.5% + 0.25E par transaction)

Divers :
- DocuSealService::sendComptaForSignature() + getApi()
- Customer::generateCodeComptable() format EC-XXXX-XXXXX
- Protection double prefixe EC- a la creation client
- Bouton regenerer PDF cache quand advert state=accepted
- Modals sans script inline (data-modal-open/close dans app.js)

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

98 lines
3.0 KiB
PHP

<?php
namespace App\Tests\Entity;
use App\Entity\Customer;
use App\Entity\Domain;
use App\Entity\User;
use PHPUnit\Framework\TestCase;
class DomainTest extends TestCase
{
private function createCustomer(): Customer
{
$user = new User();
$user->setEmail('c@t.com');
$user->setFirstName('C');
$user->setLastName('T');
$user->setPassword('h');
return new Customer($user);
}
public function testConstructor(): void
{
$customer = $this->createCustomer();
$domain = new Domain($customer, 'Example.COM ');
$this->assertNull($domain->getId());
$this->assertSame($customer, $domain->getCustomer());
$this->assertSame('example.com', $domain->getFqdn());
$this->assertNull($domain->getRegistrar());
$this->assertNull($domain->getZoneCloudflare());
$this->assertNull($domain->getZoneIdCloudflare());
$this->assertNull($domain->getExpiredAt());
$this->assertFalse($domain->isGestion());
$this->assertFalse($domain->isBilling());
$this->assertInstanceOf(\DateTimeImmutable::class, $domain->getCreatedAt());
$this->assertNull($domain->getUpdatedAt());
}
public function testSetters(): void
{
$domain = new Domain($this->createCustomer(), 'e-cosplay.fr');
$domain->setFqdn(' ESY-WEB.DEV ');
$this->assertSame('esy-web.dev', $domain->getFqdn());
$domain->setRegistrar('OVH');
$this->assertSame('OVH', $domain->getRegistrar());
$domain->setZoneCloudflare('active');
$this->assertSame('active', $domain->getZoneCloudflare());
$domain->setZoneIdCloudflare('zone_abc123');
$this->assertSame('zone_abc123', $domain->getZoneIdCloudflare());
$expiry = new \DateTimeImmutable('2027-01-01');
$domain->setExpiredAt($expiry);
$this->assertSame($expiry, $domain->getExpiredAt());
$domain->setIsGestion(true);
$this->assertTrue($domain->isGestion());
$domain->setIsBilling(true);
$this->assertTrue($domain->isBilling());
$now = new \DateTimeImmutable();
$domain->setUpdatedAt($now);
$this->assertSame($now, $domain->getUpdatedAt());
}
public function testIsExpired(): void
{
$domain = new Domain($this->createCustomer(), 'test.fr');
$this->assertFalse($domain->isExpired());
$domain->setExpiredAt(new \DateTimeImmutable('-1 day'));
$this->assertTrue($domain->isExpired());
$domain->setExpiredAt(new \DateTimeImmutable('+1 year'));
$this->assertFalse($domain->isExpired());
}
public function testIsExpiringSoon(): void
{
$domain = new Domain($this->createCustomer(), 'test.fr');
$this->assertFalse($domain->isExpiringSoon());
$domain->setExpiredAt(new \DateTimeImmutable('+15 days'));
$this->assertTrue($domain->isExpiringSoon(30));
$domain->setExpiredAt(new \DateTimeImmutable('+60 days'));
$this->assertFalse($domain->isExpiringSoon(30));
}
}