@@ -77,12 +77,18 @@ public function testCreate(array $optionConfig, bool $useScdStrategy, string $ex
77
77
->expects ($ this ->exactly (3 ))
78
78
->method ('satisfies ' )
79
79
->willReturn ($ useScdStrategy );
80
+ $ arguments = array_chunk ($ optionConfig ['excluded_themes ' ], 1 );
81
+ $ results = $ optionConfig ['resolve_return ' ];
80
82
$ this ->themeResolverMock
81
83
->expects ($ this ->exactly (count ($ optionConfig ['excluded_themes ' ])))
82
84
->method ('resolve ' )
83
- ->withConsecutive (...array_chunk ($ optionConfig ['excluded_themes ' ], 1 ))
84
- ->willReturnOnConsecutiveCalls (...$ optionConfig ['resolve_return ' ]);
85
-
85
+ // withConsecutive() alternative.
86
+ ->willReturnCallback (function ($ arguments ) use ($ results ) {
87
+ static $ callCount = 0 ;
88
+ $ returnValue = $ results [$ callCount ] ?? null ;
89
+ $ callCount ++;
90
+ return $ returnValue ;
91
+ });
86
92
$ this ->assertEquals (
87
93
$ expected ,
88
94
$ this ->commandFactory ->create (
@@ -274,12 +280,18 @@ public function testMatrix(array $optionConfig, array $matrix, array $expected)
274
280
->expects ($ this ->any ())
275
281
->method ('satisfies ' )
276
282
->willReturn (true );
283
+ $ arguments = $ optionConfig ['resolve_pass ' ];
284
+ $ results = $ optionConfig ['resolve_return ' ];
277
285
$ this ->themeResolverMock
278
286
->expects ($ this ->exactly (count ($ optionConfig ['resolve_pass ' ])))
279
287
->method ('resolve ' )
280
- ->withConsecutive (...$ optionConfig ['resolve_pass ' ])
281
- ->willReturnOnConsecutiveCalls (...$ optionConfig ['resolve_return ' ]);
282
-
288
+ // withConsecutive() alternative.
289
+ ->willReturnCallback (function ($ arguments ) use ($ results ) {
290
+ static $ callCount = 0 ;
291
+ $ returnValue = $ results [$ callCount ] ?? null ;
292
+ $ callCount ++;
293
+ return $ returnValue ;
294
+ });
283
295
$ this ->assertSame (
284
296
$ expected ,
285
297
$ this ->commandFactory ->matrix ($ optionMock , $ matrix )
@@ -390,11 +402,18 @@ public function testCreateNoResolve()
390
402
->expects ($ this ->exactly (3 ))
391
403
->method ('satisfies ' )
392
404
->willReturn ($ useScdStrategy );
405
+ $ arguments = array_chunk ($ excludedThemes , 1 );
406
+ $ results = $ optionConfig ['resolve_return ' ];
393
407
$ this ->themeResolverMock
394
408
->expects ($ this ->exactly ($ this ->count ($ excludedThemes )))
395
409
->method ('resolve ' )
396
- ->withConsecutive (...array_chunk ($ excludedThemes , 1 ))
397
- ->willReturnOnConsecutiveCalls (...$ optionConfig ['resolve_return ' ]);
410
+ // withConsecutive() alternative.
411
+ ->willReturnCallback (function ($ arguments ) use ($ results ) {
412
+ static $ callCount = 0 ;
413
+ $ returnValue = $ results [$ callCount ] ?? null ;
414
+ $ callCount ++;
415
+ return $ returnValue ;
416
+ });
398
417
399
418
$ this ->assertEquals (
400
419
$ expected ,
@@ -436,14 +455,11 @@ public function testMatrixNoResolve(): void
436
455
$ this ->themeResolverMock
437
456
->expects ($ this ->exactly (2 ))
438
457
->method ('resolve ' )
439
- ->withConsecutive (
440
- ['Magento/Backend ' ],
441
- ['Magento/Backend ' ]
442
- )
443
- ->willReturnOnConsecutiveCalls (
444
- '' ,
445
- ''
446
- );
458
+ // withConsecutive() alternative.
459
+ ->willReturnCallback (fn ($ param ) => match ([$ param ]) {
460
+ ['Magento/Backend ' ] => '' ,
461
+ ['Magento/Backend ' ] => ''
462
+ });
447
463
$ this ->loggerMock
448
464
->expects ($ this ->once ())
449
465
->method ('warning ' )
0 commit comments