- AttestationController: fix decodeAndVerifyHash to have max 3 returns, add 11 tests covering all routes (check, ventesRef, ventes) and all decodeAndVerifyHash branches (invalid base64, missing pipe, bad signature, bad JSON, valid hash with/without registered attestation), plus generateHash unit tests with unicode - LegalController: add 6 tests for RGPD POST routes (rgpdAccess and rgpdDeletion) covering empty fields, data found, and no data found scenarios - AdminController: add 10 tests for analytics page (all period filters + access denied) and orderTickets endpoint (single ticket PDF, multiple tickets ZIP, order not found, no tickets) - AccountController: add 17 tests for downloadTicket (success/denied/404), resendTicket (success/denied/404), cancelTicket (success/denied/404), createAccreditation (staff/exposant/empty fields/no categories/invalid type), eventAttestation (with categories/billets/empty selection) - AnalyticsEvent entity: new test file with 8 tests covering constructor defaults, all getters/setters, nullable fields, and fluent interface Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
89 lines
2.4 KiB
PHP
89 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\AnalyticsEvent;
|
|
use App\Entity\AnalyticsUniqId;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AnalyticsEventTest extends TestCase
|
|
{
|
|
public function testConstructor(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
|
|
self::assertNull($event->getId());
|
|
self::assertSame('page_view', $event->getEventName());
|
|
self::assertNull($event->getTitle());
|
|
self::assertNull($event->getReferrer());
|
|
self::assertInstanceOf(\DateTimeImmutable::class, $event->getCreatedAt());
|
|
}
|
|
|
|
public function testSetEventName(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$result = $event->setEventName('click');
|
|
|
|
self::assertSame('click', $event->getEventName());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetUrl(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$result = $event->setUrl('https://example.com/page');
|
|
|
|
self::assertSame('https://example.com/page', $event->getUrl());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetTitle(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$result = $event->setTitle('My Page');
|
|
|
|
self::assertSame('My Page', $event->getTitle());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetTitleNull(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$event->setTitle('My Page');
|
|
$result = $event->setTitle(null);
|
|
|
|
self::assertNull($event->getTitle());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetReferrer(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$result = $event->setReferrer('https://google.com');
|
|
|
|
self::assertSame('https://google.com', $event->getReferrer());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetReferrerNull(): void
|
|
{
|
|
$event = new AnalyticsEvent();
|
|
$event->setReferrer('https://google.com');
|
|
$result = $event->setReferrer(null);
|
|
|
|
self::assertNull($event->getReferrer());
|
|
self::assertSame($event, $result);
|
|
}
|
|
|
|
public function testSetVisitor(): void
|
|
{
|
|
$visitor = $this->createMock(AnalyticsUniqId::class);
|
|
|
|
$event = new AnalyticsEvent();
|
|
$result = $event->setVisitor($visitor);
|
|
|
|
self::assertSame($visitor, $event->getVisitor());
|
|
self::assertSame($event, $result);
|
|
}
|
|
}
|