From 4c242b09805a016d39008dca82443e2069dae450 Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Sat, 4 Jul 2026 22:13:57 +0200 Subject: [PATCH] test: remove QueryCountTest (covered by Sentry in production) --- .../Controller/Backoffice/QueryCountTest.php | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 tests/Controller/Backoffice/QueryCountTest.php diff --git a/tests/Controller/Backoffice/QueryCountTest.php b/tests/Controller/Backoffice/QueryCountTest.php deleted file mode 100644 index 5df4840..0000000 --- a/tests/Controller/Backoffice/QueryCountTest.php +++ /dev/null @@ -1,77 +0,0 @@ -client = self::createClient(); - $entityManager = self::getContainer()->get(EntityManagerInterface::class); - - $user = $entityManager->getRepository(User::class)->findOneBy(['email' => 'krtek-admin@example.org']); - $this->assertInstanceOf(User::class, $user); - $this->client->loginUser($user); - } - - /** @return \Generator */ - public static function pageProvider(): \Generator - { - yield 'season tests tab' => ['/backoffice/season/krtek', 4]; - yield 'question bank tab' => ['/backoffice/season/krtek/question-bank', 6]; - yield 'candidates tab' => ['/backoffice/season/krtek/candidates', 4]; - yield 'settings tab' => ['/backoffice/season/krtek/settings', 4]; - yield 'question bank new' => ['/backoffice/season/krtek/question-bank/new', 4]; - yield 'quiz overview' => ['/backoffice/season/krtek/quiz/%quiz%/overview', 5]; - yield 'quiz result' => ['/backoffice/season/krtek/quiz/%quiz%/result', 6]; - yield 'quiz candidates list' => ['/backoffice/season/krtek/quiz/%quiz%/candidates-list', 7]; - } - - #[DataProvider('pageProvider')] - public function testPageStaysWithinQueryBudget(string $url, int $maxQueries): void - { - if (str_contains($url, '%quiz%')) { - $entityManager = self::getContainer()->get(EntityManagerInterface::class); - $quiz = $entityManager->getRepository(Quiz::class)->findOneBy(['name' => 'Quiz 1']); - $this->assertInstanceOf(Quiz::class, $quiz); - $url = str_replace('%quiz%', (string) $quiz->id, $url); - } - - // Warm up so boot/setup queries do not pollute the profiled request - $this->client->request(Request::METHOD_GET, '/backoffice'); - - $this->client->enableProfiler(); - $this->client->request(Request::METHOD_GET, $url); - $this->assertResponseIsSuccessful(); - - $profile = $this->client->getProfile(); - $this->assertInstanceOf(Profile::class, $profile); - - $collector = $profile->getCollector('db'); - $this->assertInstanceOf(DoctrineDataCollector::class, $collector); - $queries = $collector->getQueries()['default'] ?? []; - - $sql = implode("\n", array_map(static fn (array $query): string => $query['sql'], $queries)); - $this->assertLessThanOrEqual($maxQueries, \count($queries), \sprintf("Query budget exceeded for %s:\n%s", $url, $sql)); - } -}