From a2a660c954443fa0825fd3edad4161cf3444d911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 1 Sep 2023 17:07:10 +0200 Subject: [PATCH] Try to avoid open db connections --- .../ChillMainBundle/Test/Export/AbstractAggregatorTest.php | 6 ++++++ .../ChillMainBundle/Test/Export/AbstractFilterTest.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index faaa4a560..f056adc92 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Test\Export; use Doctrine\ORM\AbstractQuery; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Traversable; @@ -30,6 +31,11 @@ abstract class AbstractAggregatorTest extends KernelTestCase public static function tearDownAfterClass(): void { + if (null !== self::$container) { + /** @var EntityManagerInterface $em */ + $em = self::$container->get(EntityManagerInterface::class); + $em->getConnection()->close(); + } self::ensureKernelShutdown(); } diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 2f79abc3d..54740db82 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Test\Export; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Exception; use Prophecy\PhpUnit\ProphecyTrait; @@ -40,6 +41,11 @@ abstract class AbstractFilterTest extends KernelTestCase public static function tearDownAfterClass(): void { + if (null !== self::$container) { + /** @var EntityManagerInterface $em */ + $em = self::$container->get(EntityManagerInterface::class); + $em->getConnection()->close(); + } self::ensureKernelShutdown(); }