Add missing test coverage for MeilisearchService, AnalyticsCryptoService, AccountController and AdminController

- MeilisearchServiceTest: add test for invalidateSearchCache()
- AnalyticsCryptoService: mark unreachable tryDecryptJsFormat guard
  with @codeCoverageIgnore (decrypt already checks strlen >= 28)
- AccountControllerTest: add test for tickets search query (tq param)
- AdminControllerTest: add test for infra page with snapshot data file

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-01 20:19:52 +02:00
parent b1ec125bb9
commit 83f2f40a91
4 changed files with 62 additions and 3 deletions

View File

@@ -46,9 +46,9 @@ class AnalyticsCryptoService
private function tryDecryptJsFormat(string $iv, string $ciphertextWithTag): ?string
{
if (\strlen($ciphertextWithTag) < 16) {
return null;
}
if (\strlen($ciphertextWithTag) < 16) { // @codeCoverageIgnore
return null; // @codeCoverageIgnore
} // @codeCoverageIgnore
$json = openssl_decrypt(substr($ciphertextWithTag, 0, -16), 'aes-256-gcm', $this->key, \OPENSSL_RAW_DATA, $iv, substr($ciphertextWithTag, -16));

View File

@@ -1256,6 +1256,20 @@ class AccountControllerTest extends WebTestCase
self::assertResponseIsSuccessful();
}
public function testEditEventStatsTabWithTicketSearch(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$user = $this->createUser(['ROLE_ORGANIZER'], true);
$event = $this->createEvent($em, $user);
$client->loginUser($user);
$client->request('GET', '/mon-compte/evenement/'.$event->getId().'/modifier?tab=tickets&tq=jean');
self::assertResponseIsSuccessful();
}
public function testAddBilletPage(): void
{
$client = static::createClient();

View File

@@ -854,6 +854,38 @@ class AdminControllerTest extends WebTestCase
self::assertResponseIsSuccessful();
}
public function testInfraPageWithSnapshotData(): void
{
$client = static::createClient();
$admin = $this->createUser(['ROLE_ROOT']);
$projectDir = static::getContainer()->getParameter('kernel.project_dir');
$path = $projectDir.'/var/infra.json';
$existed = file_exists($path);
$originalContent = $existed ? file_get_contents($path) : null;
file_put_contents($path, json_encode([
'server' => ['hostname' => 'test'],
'containers' => [],
'redis_global' => ['connected' => true],
'redis_dbs' => [],
'postgres' => ['connected' => true],
'pgbouncer' => ['connected' => true],
'generated_at' => '2026-04-01',
]));
$client->loginUser($admin);
$client->request('GET', '/admin/infra');
self::assertResponseIsSuccessful();
if ($existed) {
file_put_contents($path, $originalContent);
} else {
unlink($path);
}
}
public function testInfraPageDeniedForNonRoot(): void
{
$client = static::createClient();

View File

@@ -248,6 +248,19 @@ class MeilisearchServiceTest extends TestCase
self::assertSame(['events', 'users'], $indexes);
}
public function testInvalidateSearchCache(): void
{
$item = $this->cache->getItem('test_key');
$item->set('value');
$this->cache->save($item);
self::assertTrue($this->cache->hasItem('test_key'));
$this->service->invalidateSearchCache();
self::assertFalse($this->cache->hasItem('test_key'));
}
public function testListIndexesEmpty(): void
{
$response = $this->createMock(ResponseInterface::class);