- 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>
146 lines
4.1 KiB
PHP
146 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
use App\Service\RgpdService;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
class LegalControllerTest extends WebTestCase
|
|
{
|
|
public function testMentionsLegales(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/mentions-legales');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testCgu(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/cgu');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testCgv(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/cgv');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testHosting(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/hebergement');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testCookies(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/cookies');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testRgpd(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/rgpd');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testConformite(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/conformite');
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testRgpdAccessEmptyFields(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('POST', '/rgpd/acces', ['ip' => '', 'email' => '']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
|
|
public function testRgpdAccessWithDataFound(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
$mock = $this->createMock(RgpdService::class);
|
|
$mock->method('handleAccessRequest')
|
|
->with('192.168.1.1', 'test@example.com')
|
|
->willReturn(['found' => true, 'count' => 5]);
|
|
|
|
static::getContainer()->set(RgpdService::class, $mock);
|
|
|
|
$client->request('POST', '/rgpd/acces', ['ip' => '192.168.1.1', 'email' => 'test@example.com']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
|
|
public function testRgpdAccessWithNoData(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
$mock = $this->createMock(RgpdService::class);
|
|
$mock->method('handleAccessRequest')
|
|
->with('192.168.1.1', 'test@example.com')
|
|
->willReturn(['found' => false, 'count' => 0]);
|
|
|
|
static::getContainer()->set(RgpdService::class, $mock);
|
|
|
|
$client->request('POST', '/rgpd/acces', ['ip' => '192.168.1.1', 'email' => 'test@example.com']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
|
|
public function testRgpdDeletionEmptyFields(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('POST', '/rgpd/suppression', ['ip' => '', 'email' => '']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
|
|
public function testRgpdDeletionWithDataFound(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
$mock = $this->createMock(RgpdService::class);
|
|
$mock->method('handleDeletionRequest')
|
|
->with('192.168.1.1', 'test@example.com')
|
|
->willReturn(['found' => true, 'count' => 3]);
|
|
|
|
static::getContainer()->set(RgpdService::class, $mock);
|
|
|
|
$client->request('POST', '/rgpd/suppression', ['ip' => '192.168.1.1', 'email' => 'test@example.com']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
|
|
public function testRgpdDeletionWithNoData(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
$mock = $this->createMock(RgpdService::class);
|
|
$mock->method('handleDeletionRequest')
|
|
->with('192.168.1.1', 'test@example.com')
|
|
->willReturn(['found' => false, 'count' => 0]);
|
|
|
|
static::getContainer()->set(RgpdService::class, $mock);
|
|
|
|
$client->request('POST', '/rgpd/suppression', ['ip' => '192.168.1.1', 'email' => 'test@example.com']);
|
|
|
|
self::assertResponseRedirects('/rgpd');
|
|
}
|
|
}
|