Ensured CloseDbConnectionMiddleware clears the entity manager

This commit is contained in:
Alejandro Celaya 2018-11-24 13:24:43 +01:00
parent 0c26490e3f
commit f0330e9ae3
2 changed files with 4 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class CloseDbConnectionMiddleware implements MiddlewareInterface
{
$handledRequest = $handler->handle($request);
$this->em->getConnection()->close();
$this->em->clear();
return $handledRequest;
}

View File

@ -41,6 +41,8 @@ class CloseDbConnectionMiddlewareTest extends TestCase
$closeConn = $conn->close()->will(function () {
});
$getConn = $this->em->getConnection()->willReturn($conn->reveal());
$clear = $this->em->clear()->will(function () {
});
$handle = $this->handler->handle($req)->willReturn($resp);
$result = $this->middleware->process($req, $this->handler->reveal());
@ -48,6 +50,7 @@ class CloseDbConnectionMiddlewareTest extends TestCase
$this->assertSame($result, $resp);
$getConn->shouldHaveBeenCalledOnce();
$closeConn->shouldHaveBeenCalledOnce();
$clear->shouldHaveBeenCalledOnce();
$handle->shouldHaveBeenCalledOnce();
}
}