try to block removing a person

This commit is contained in:
Julien Fastré 2022-06-16 23:19:16 +02:00
parent 07608dc412
commit d55311ce40

View File

@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Tests\Controller;
use Chill\MainBundle\Test\PrepareClientTrait; use Chill\MainBundle\Test\PrepareClientTrait;
use DateTime; use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DomCrawler\Form; use Symfony\Component\DomCrawler\Form;
@ -48,21 +49,21 @@ final class PersonControllerCreateTest extends WebTestCase
public static function tearDownAfterClass(): void public static function tearDownAfterClass(): void
{ {
self::bootKernel(); self::bootKernel();
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager'); $em = self::$kernel->getContainer()->get(EntityManagerInterface::class);
//remove two people created during test //remove two people created during test
$jesus = $em->getRepository(\Chill\PersonBundle\Entity\Person::class) $jesus = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
->findOneBy(['firstName' => 'God']); ->findOneBy(['firstName' => 'God']);
if (null !== $jesus) { if (null !== $jesus) {
$em->remove($jesus); //$em->remove($jesus);
} }
$jesus2 = $em->getRepository(\Chill\PersonBundle\Entity\Person::class) $jesus2 = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)
->findOneBy(['firstName' => 'roger']); ->findOneBy(['firstName' => 'roger']);
if (null !== $jesus2) { if (null !== $jesus2) {
$em->remove($jesus2); //$em->remove($jesus2);
} }
$em->flush(); $em->flush();
} }