Add AST cache for AdminLogsTest.php with extracted nodes and edges

This commit is contained in:
hamed
2026-07-10 09:48:45 +03:30
parent 9d2023a72f
commit 11efed4100
13 changed files with 1133 additions and 791 deletions
+35
View File
@@ -45,4 +45,39 @@ class AdminLogsTest extends ApiTestCase
$this->em->getConnection()->executeStatement('DELETE FROM app_log WHERE message LIKE ?', [$marker . '%']);
}
public function testExportNonAdminForbidden(): void
{
$user = $this->createUser(['ROLE_USER']);
$this->authJson('GET', '/api/v1/admin/logs/export', $user);
self::assertSame(403, $this->responseCode());
}
public function testAdminExportsCsvFilteredByLevel(): void
{
$marker = 'ADMINLOGEXPORT_' . bin2hex(random_bytes(5));
$this->seedLog('error', $marker . '_err');
$this->seedLog('warning', $marker . '_warn');
$admin = $this->createUser(['ROLE_ADMIN']);
$this->client->request(
'GET',
'/api/v1/admin/logs/export?level=error&search=' . $marker,
server: ['HTTP_AUTHORIZATION' => 'Bearer ' . $this->jwtFor($admin)],
);
$response = $this->client->getResponse();
self::assertSame(200, $response->getStatusCode());
self::assertStringContainsString('text/csv', (string) $response->headers->get('Content-Type'));
self::assertStringContainsString('attachment', (string) $response->headers->get('Content-Disposition'));
// StreamedResponse body is captured by BrowserKit into the internal response.
$csv = $this->client->getInternalResponse()->getContent();
self::assertStringContainsString('id,level,message', $csv);
self::assertStringContainsString($marker . '_err', $csv);
self::assertStringNotContainsString($marker . '_warn', $csv);
$this->em->getConnection()->executeStatement('DELETE FROM app_log WHERE message LIKE ?', [$marker . '%']);
}
}