From 6eac079440a312582ab9dab0a5bf4c6f43079026 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 21 Dec 2021 14:10:06 +0100 Subject: [PATCH] Ensured EM is closed and not cleared after running an async task --- .../src/EventDispatcher/CloseDbConnectionEventListener.php | 2 +- .../EventDispatcher/CloseDbConnectionEventListenerTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php b/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php index 079c6195..985b13c2 100644 --- a/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php +++ b/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php @@ -24,7 +24,7 @@ class CloseDbConnectionEventListener ($this->wrapped)($event); } finally { $this->em->getConnection()->close(); - $this->em->clear(); + $this->em->close(); } } } diff --git a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php index 3d830cf3..d0c7c374 100644 --- a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php +++ b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php @@ -35,7 +35,7 @@ class CloseDbConnectionEventListenerTest extends TestCase $close = $conn->close()->will(function (): void { }); $getConn = $this->em->getConnection()->willReturn($conn->reveal()); - $clear = $this->em->clear()->will(function (): void { + $close = $this->em->close()->will(function (): void { }); $open = $this->em->open()->will(function (): void { }); @@ -51,7 +51,7 @@ class CloseDbConnectionEventListenerTest extends TestCase self::assertTrue($wrappedWasCalled); $close->shouldHaveBeenCalledOnce(); $getConn->shouldHaveBeenCalledOnce(); - $clear->shouldHaveBeenCalledOnce(); + $close->shouldHaveBeenCalledOnce(); $open->shouldHaveBeenCalledOnce(); }