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