createUser(['ROLE_DOCTOR']); $doctor = new Doctor($owner, 'دکتر'); $this->em->persist($doctor); $this->em->flush(); for ($i = 0; $i < $count; $i++) { $secUser = $this->createUser(['ROLE_SECRETARY']); $this->em->persist(new DoctorSecretary($doctor, $secUser)); } $this->em->flush(); return [$owner, $doctor]; } public function testQueryCountDoesNotGrowWithSecretaryCount(): void { $this->client->disableReboot(); [$ownerS, $small] = $this->makeDoctorWithSecretaries(1); [$ownerL, $large] = $this->makeDoctorWithSecretaries(5); $this->em->clear(); $qSmall = $this->countQueries(fn () => $this->authJson('GET', '/api/v1/secretaries/' . $small->getUuid(), $ownerS)); $qLarge = $this->countQueries(fn () => $this->authJson('GET', '/api/v1/secretaries/' . $large->getUuid(), $ownerL)); $this->assertLessThanOrEqual($qSmall + 1, $qLarge, "N+1: query count grew from $qSmall to $qLarge"); } }