em->persist($tenant); $this->em->flush(); $coverage = new TenantServiceCoverage($tenant->getId(), 1); $this->em->persist($coverage); $this->em->persist(new EntityInsurancePricing($entityType, $entityId, 1)); $this->em->flush(); static::getContainer()->get(TenantInsuranceCleanupService::class) ->purgeForEntity($entityType, $entityId); $this->em->clear(); $this->assertCount(0, $this->em->getRepository(TenantInsurance::class) ->findBy(['entityType' => $entityType, 'entityId' => $entityId])); $this->assertCount(0, $this->em->getRepository(EntityInsurancePricing::class) ->findBy(['entityType' => $entityType, 'entityId' => $entityId])); $this->assertNull($this->em->getRepository(TenantServiceCoverage::class) ->findOneBy(['tenantInsuranceId' => $tenant->getId()])); } }