[EDIT]
I fixed my issue with this trick :
Doctrine 2 OneToMany Cascade SET NULL
I'm facing an issue in my unit tests when i try to delete some entities between each tests.
I have this method :
 private function cleanEntities(?array $entities = null): void
    {
        if (!$entities) {
            $entities = [Nc::class, Chapter::class, Questionnaire::class, Audit::class];
        }
        foreach ($entities as $entity) {
            $data = static::$em->getRepository($entity)->findAll();
            foreach ($data as $element) {
                self::$em->remove($element);
            }
        }
        self::$em->flush();
    }
But in my example, in the entity "Nc", there's a foreign key pointing to the entity "Audit".
When I try do delete both, when I flush all the "remove" actions, I get an error from SQL Server stating that there'sa conflict between the "DELETE" action and the foreign key in my entity Nc.
From what I can see, the Audit has to be flushes after them all, that's why I've placed it last in the $entities array.
I'm wondering if there's an option or a way to avoid this type of conflict ?
The only solution I see, which I will do if there's no other wayn is to remove and flush the Audits after the rest, but that's not ideal at all because what if I have other entities conflicts ...
Thanks.
