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