@@ -99,22 +99,27 @@ public static function provideDsn()
9999 public function testCreatesTableInTransaction (string $ platform )
100100 {
101101 $ 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+
102109 $ conn ->expects ($ this ->atLeast (3 ))
103110 ->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+ ;
118123
119124 $ conn ->method ('isTransactionActive ' )
120125 ->willReturn (true );
@@ -145,21 +150,25 @@ public static function providePlatforms()
145150 public function testTableCreationInTransactionNotSupported ()
146151 {
147152 $ 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+
148159 $ conn ->expects ($ this ->atLeast (2 ))
149160 ->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+ ;
163172
164173 $ conn ->method ('isTransactionActive ' )
165174 ->willReturn (true );
@@ -181,22 +190,26 @@ public function testTableCreationInTransactionNotSupported()
181190 public function testCreatesTableOutsideTransaction ()
182191 {
183192 $ 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+
184200 $ conn ->expects ($ this ->atLeast (3 ))
185201 ->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+ ;
200213
201214 $ conn ->method ('isTransactionActive ' )
202215 ->willReturn (false );
0 commit comments