getContainer()->get('doctrine'); $this->entityManager = $doctrine->getManager(); } protected function getEntityManager(): ObjectManager { return $this->entityManager; } protected function tearDown(): void { parent::tearDown(); if ($this->entityManager instanceof EntityManagerInterface) { $this->entityManager->close(); } $this->entityManager = null; // avoid memory leaks } }