33namespace Enqueue \Bundle \Tests \Unit \Consumption \Extension ;
44
55use Doctrine \DBAL \Connection ;
6+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
67use Doctrine \Persistence \ManagerRegistry ;
78use Enqueue \Bundle \Consumption \Extension \DoctrinePingConnectionExtension ;
89use Enqueue \Consumption \Context \MessageReceived ;
@@ -29,10 +30,17 @@ public function testShouldNotReconnectIfConnectionIsOK()
2930 ->method ('isConnected ' )
3031 ->willReturn (true )
3132 ;
33+
34+ $ abstractPlatform = $ this ->createMock (AbstractPlatform::class);
35+ $ abstractPlatform ->expects ($ this ->once ())
36+ ->method ('getDummySelectSQL ' )
37+ ->willReturn ('dummy ' )
38+ ;
39+
3240 $ connection
3341 ->expects ($ this ->once ())
34- ->method ('ping ' )
35- ->willReturn (true )
42+ ->method ('getDatabasePlatform ' )
43+ ->willReturn ($ abstractPlatform )
3644 ;
3745 $ connection
3846 ->expects ($ this ->never ())
@@ -68,10 +76,11 @@ public function testShouldDoesReconnectIfConnectionFailed()
6876 ->method ('isConnected ' )
6977 ->willReturn (true )
7078 ;
79+
7180 $ connection
7281 ->expects ($ this ->once ())
73- ->method ('ping ' )
74- ->willReturn ( false )
82+ ->method ('getDatabasePlatform ' )
83+ ->willThrowException ( new \ Exception () )
7584 ;
7685 $ connection
7786 ->expects ($ this ->once ())
@@ -118,7 +127,7 @@ public function testShouldSkipIfConnectionWasNotOpened()
118127 ;
119128 $ connection1
120129 ->expects ($ this ->never ())
121- ->method ('ping ' )
130+ ->method ('getDatabasePlatform ' )
122131 ;
123132
124133 // 2nd connection was opened in the past
@@ -128,10 +137,16 @@ public function testShouldSkipIfConnectionWasNotOpened()
128137 ->method ('isConnected ' )
129138 ->willReturn (true )
130139 ;
140+ $ abstractPlatform = $ this ->createMock (AbstractPlatform::class);
141+ $ abstractPlatform ->expects ($ this ->once ())
142+ ->method ('getDummySelectSQL ' )
143+ ->willReturn ('dummy ' )
144+ ;
145+
131146 $ connection2
132147 ->expects ($ this ->once ())
133- ->method ('ping ' )
134- ->willReturn (true )
148+ ->method ('getDatabasePlatform ' )
149+ ->willReturn ($ abstractPlatform )
135150 ;
136151
137152 $ context = $ this ->createContext ();
0 commit comments