File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
src/Symfony/Bridge/Doctrine Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \Bridge \Doctrine \Messenger ;
13
13
14
14
use Doctrine \DBAL \DBALException ;
15
+ use Doctrine \DBAL \Exception ;
15
16
use Doctrine \ORM \EntityManagerInterface ;
16
17
use Symfony \Component \Messenger \Envelope ;
17
18
use Symfony \Component \Messenger \Middleware \StackInterface ;
@@ -38,8 +39,8 @@ private function pingConnection(EntityManagerInterface $entityManager)
38
39
$ connection = $ entityManager ->getConnection ();
39
40
40
41
try {
41
- $ connection ->query ($ connection ->getDatabasePlatform ()->getDummySelectSQL ());
42
- } catch (DBALException $ e ) {
42
+ $ connection ->executeQuery ($ connection ->getDatabasePlatform ()->getDummySelectSQL ());
43
+ } catch (DBALException | Exception $ e ) {
43
44
$ connection ->close ();
44
45
$ connection ->connect ();
45
46
}
Original file line number Diff line number Diff line change 13
13
14
14
use Doctrine \DBAL \Connection ;
15
15
use Doctrine \DBAL \DBALException ;
16
+ use Doctrine \DBAL \Exception ;
16
17
use Doctrine \ORM \EntityManagerInterface ;
17
18
use Doctrine \Persistence \ManagerRegistry ;
18
19
use Symfony \Bridge \Doctrine \Messenger \DoctrinePingConnectionMiddleware ;
@@ -49,7 +50,7 @@ public function testMiddlewarePingOk()
49
50
{
50
51
$ this ->connection ->expects ($ this ->once ())
51
52
->method ('getDatabasePlatform ' )
52
- ->will ($ this ->throwException (new DBALException ()));
53
+ ->will ($ this ->throwException (class_exists (Exception::class) ? new Exception () : new DBALException ()));
53
54
54
55
$ this ->connection ->expects ($ this ->once ())
55
56
->method ('close ' )
@@ -68,7 +69,7 @@ public function testMiddlewarePingResetEntityManager()
68
69
{
69
70
$ this ->connection ->expects ($ this ->once ())
70
71
->method ('getDatabasePlatform ' )
71
- ->will ($ this ->throwException (new DBALException ()));
72
+ ->will ($ this ->throwException (class_exists (Exception::class) ? new Exception () : new DBALException ()));
72
73
73
74
$ this ->entityManager ->expects ($ this ->once ())
74
75
->method ('isOpen ' )
You can’t perform that action at this time.
0 commit comments