File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \Bridge \Doctrine \Messenger ;
1313
1414use Doctrine \DBAL \DBALException ;
15+ use Doctrine \DBAL \Exception ;
1516use Doctrine \ORM \EntityManagerInterface ;
1617use Symfony \Component \Messenger \Envelope ;
1718use Symfony \Component \Messenger \Middleware \StackInterface ;
@@ -38,8 +39,8 @@ private function pingConnection(EntityManagerInterface $entityManager)
3839 $ connection = $ entityManager ->getConnection ();
3940
4041 try {
41- $ connection ->query ($ connection ->getDatabasePlatform ()->getDummySelectSQL ());
42- } catch (DBALException $ e ) {
42+ $ connection ->executeQuery ($ connection ->getDatabasePlatform ()->getDummySelectSQL ());
43+ } catch (DBALException | Exception $ e ) {
4344 $ connection ->close ();
4445 $ connection ->connect ();
4546 }
Original file line number Diff line number Diff line change 1313
1414use Doctrine \DBAL \Connection ;
1515use Doctrine \DBAL \DBALException ;
16+ use Doctrine \DBAL \Exception ;
1617use Doctrine \ORM \EntityManagerInterface ;
1718use Doctrine \Persistence \ManagerRegistry ;
1819use Symfony \Bridge \Doctrine \Messenger \DoctrinePingConnectionMiddleware ;
@@ -49,7 +50,7 @@ public function testMiddlewarePingOk()
4950 {
5051 $ this ->connection ->expects ($ this ->once ())
5152 ->method ('getDatabasePlatform ' )
52- ->will ($ this ->throwException (new DBALException ()));
53+ ->will ($ this ->throwException (class_exists (Exception::class) ? new Exception () : new DBALException ()));
5354
5455 $ this ->connection ->expects ($ this ->once ())
5556 ->method ('close ' )
@@ -68,7 +69,7 @@ public function testMiddlewarePingResetEntityManager()
6869 {
6970 $ this ->connection ->expects ($ this ->once ())
7071 ->method ('getDatabasePlatform ' )
71- ->will ($ this ->throwException (new DBALException ()));
72+ ->will ($ this ->throwException (class_exists (Exception::class) ? new Exception () : new DBALException ()));
7273
7374 $ this ->entityManager ->expects ($ this ->once ())
7475 ->method ('isOpen ' )
You can’t perform that action at this time.
0 commit comments