3
3
namespace Enqueue \Bundle \Tests \Unit \Consumption \Extension ;
4
4
5
5
use Doctrine \DBAL \Connection ;
6
+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
6
7
use Doctrine \Persistence \ManagerRegistry ;
7
8
use Enqueue \Bundle \Consumption \Extension \DoctrinePingConnectionExtension ;
8
9
use Enqueue \Consumption \Context \MessageReceived ;
@@ -29,10 +30,17 @@ public function testShouldNotReconnectIfConnectionIsOK()
29
30
->method ('isConnected ' )
30
31
->willReturn (true )
31
32
;
33
+
34
+ $ abstractPlatform = $ this ->createMock (AbstractPlatform::class);
35
+ $ abstractPlatform ->expects ($ this ->once ())
36
+ ->method ('getDummySelectSQL ' )
37
+ ->willReturn ('dummy ' )
38
+ ;
39
+
32
40
$ connection
33
41
->expects ($ this ->once ())
34
- ->method ('ping ' )
35
- ->willReturn (true )
42
+ ->method ('getDatabasePlatform ' )
43
+ ->willReturn ($ abstractPlatform )
36
44
;
37
45
$ connection
38
46
->expects ($ this ->never ())
@@ -68,10 +76,11 @@ public function testShouldDoesReconnectIfConnectionFailed()
68
76
->method ('isConnected ' )
69
77
->willReturn (true )
70
78
;
79
+
71
80
$ connection
72
81
->expects ($ this ->once ())
73
- ->method ('ping ' )
74
- ->willReturn ( false )
82
+ ->method ('getDatabasePlatform ' )
83
+ ->willThrowException ( new \ Exception () )
75
84
;
76
85
$ connection
77
86
->expects ($ this ->once ())
@@ -118,7 +127,7 @@ public function testShouldSkipIfConnectionWasNotOpened()
118
127
;
119
128
$ connection1
120
129
->expects ($ this ->never ())
121
- ->method ('ping ' )
130
+ ->method ('getDatabasePlatform ' )
122
131
;
123
132
124
133
// 2nd connection was opened in the past
@@ -128,10 +137,16 @@ public function testShouldSkipIfConnectionWasNotOpened()
128
137
->method ('isConnected ' )
129
138
->willReturn (true )
130
139
;
140
+ $ abstractPlatform = $ this ->createMock (AbstractPlatform::class);
141
+ $ abstractPlatform ->expects ($ this ->once ())
142
+ ->method ('getDummySelectSQL ' )
143
+ ->willReturn ('dummy ' )
144
+ ;
145
+
131
146
$ connection2
132
147
->expects ($ this ->once ())
133
- ->method ('ping ' )
134
- ->willReturn (true )
148
+ ->method ('getDatabasePlatform ' )
149
+ ->willReturn ($ abstractPlatform )
135
150
;
136
151
137
152
$ context = $ this ->createContext ();
0 commit comments