@@ -99,22 +99,27 @@ public static function provideDsn()
99
99
public function testCreatesTableInTransaction (string $ platform )
100
100
{
101
101
$ conn = $ this ->createMock (Connection::class);
102
+
103
+ $ series = [
104
+ [$ this ->stringContains ('INSERT INTO ' ), $ this ->createMock (TableNotFoundException::class)],
105
+ [$ this ->matches ('create sql stmt ' ), 1 ],
106
+ [$ this ->stringContains ('INSERT INTO ' ), 1 ],
107
+ ];
108
+
102
109
$ conn ->expects ($ this ->atLeast (3 ))
103
110
->method ('executeStatement ' )
104
- ->withConsecutive (
105
- [$ this ->stringContains ('INSERT INTO ' )],
106
- [$ this ->matches ('create sql stmt ' )],
107
- [$ this ->stringContains ('INSERT INTO ' )]
108
- )
109
- ->will (
110
- $ this ->onConsecutiveCalls (
111
- $ this ->throwException (
112
- $ this ->createMock (TableNotFoundException::class)
113
- ),
114
- 1 ,
115
- 1
116
- )
117
- );
111
+ ->willReturnCallback (function ($ sql ) use (&$ series ) {
112
+ if ([$ constraint , $ return ] = array_shift ($ series )) {
113
+ $ constraint ->evaluate ($ sql );
114
+ }
115
+
116
+ if ($ return instanceof \Exception) {
117
+ throw $ return ;
118
+ }
119
+
120
+ return $ return ?? 1 ;
121
+ })
122
+ ;
118
123
119
124
$ conn ->method ('isTransactionActive ' )
120
125
->willReturn (true );
@@ -145,21 +150,25 @@ public static function providePlatforms()
145
150
public function testTableCreationInTransactionNotSupported ()
146
151
{
147
152
$ conn = $ this ->createMock (Connection::class);
153
+
154
+ $ series = [
155
+ [$ this ->stringContains ('INSERT INTO ' ), $ this ->createMock (TableNotFoundException::class)],
156
+ [$ this ->stringContains ('INSERT INTO ' ), 1 ],
157
+ ];
158
+
148
159
$ conn ->expects ($ this ->atLeast (2 ))
149
160
->method ('executeStatement ' )
150
- ->withConsecutive (
151
- [$ this ->stringContains ('INSERT INTO ' )],
152
- [$ this ->stringContains ('INSERT INTO ' )]
153
- )
154
- ->will (
155
- $ this ->onConsecutiveCalls (
156
- $ this ->throwException (
157
- $ this ->createMock (TableNotFoundException::class)
158
- ),
159
- 1 ,
160
- 1
161
- )
162
- );
161
+ ->willReturnCallback (function ($ sql ) use (&$ series ) {
162
+ [$ constraint , $ return ] = array_shift ($ series );
163
+ $ constraint ->evaluate ($ sql );
164
+
165
+ if ($ return instanceof \Exception) {
166
+ throw $ return ;
167
+ }
168
+
169
+ return $ return ;
170
+ })
171
+ ;
163
172
164
173
$ conn ->method ('isTransactionActive ' )
165
174
->willReturn (true );
@@ -181,22 +190,26 @@ public function testTableCreationInTransactionNotSupported()
181
190
public function testCreatesTableOutsideTransaction ()
182
191
{
183
192
$ conn = $ this ->createMock (Connection::class);
193
+
194
+ $ series = [
195
+ [$ this ->stringContains ('INSERT INTO ' ), $ this ->createMock (TableNotFoundException::class)],
196
+ [$ this ->matches ('create sql stmt ' ), 1 ],
197
+ [$ this ->stringContains ('INSERT INTO ' ), 1 ],
198
+ ];
199
+
184
200
$ conn ->expects ($ this ->atLeast (3 ))
185
201
->method ('executeStatement ' )
186
- ->withConsecutive (
187
- [$ this ->stringContains ('INSERT INTO ' )],
188
- [$ this ->matches ('create sql stmt ' )],
189
- [$ this ->stringContains ('INSERT INTO ' )]
190
- )
191
- ->will (
192
- $ this ->onConsecutiveCalls (
193
- $ this ->throwException (
194
- $ this ->createMock (TableNotFoundException::class)
195
- ),
196
- 1 ,
197
- 1
198
- )
199
- );
202
+ ->willReturnCallback (function ($ sql ) use (&$ series ) {
203
+ [$ constraint , $ return ] = array_shift ($ series );
204
+ $ constraint ->evaluate ($ sql );
205
+
206
+ if ($ return instanceof \Exception) {
207
+ throw $ return ;
208
+ }
209
+
210
+ return $ return ;
211
+ })
212
+ ;
200
213
201
214
$ conn ->method ('isTransactionActive ' )
202
215
->willReturn (false );
0 commit comments