@@ -196,14 +196,9 @@ public function shouldSendMessageToDelayExchangeIfDelaySet()
196
196
197
197
$ producer = $ this ->createProducerMock ();
198
198
$ producer
199
- ->expects ($ this ->at ( 0 ))
199
+ ->expects ($ this ->exactly ( 2 ))
200
200
->method ('setDeliveryDelay ' )
201
- ->with (10000 )
202
- ;
203
- $ producer
204
- ->expects ($ this ->at (1 ))
205
- ->method ('setDeliveryDelay ' )
206
- ->with (null )
201
+ ->with ($ this ->logicalOr (10000 , null ))
207
202
;
208
203
$ producer
209
204
->expects ($ this ->once ())
@@ -300,7 +295,7 @@ public function testShouldSetupBroker()
300
295
301
296
$ managementClient = $ this ->createManagementClientMock ();
302
297
$ managementClient
303
- ->expects ($ this ->at ( 0 ))
298
+ ->expects ($ this ->once ( ))
304
299
->method ('declareExchange ' )
305
300
->with ('aprefix.router ' , [
306
301
'type ' => 'fanout ' ,
@@ -309,7 +304,7 @@ public function testShouldSetupBroker()
309
304
])
310
305
;
311
306
$ managementClient
312
- ->expects ($ this ->at ( 1 ))
307
+ ->expects ($ this ->exactly ( 2 ))
313
308
->method ('declareQueue ' )
314
309
->with ('aprefix.default ' , [
315
310
'durable ' => true ,
@@ -320,21 +315,10 @@ public function testShouldSetupBroker()
320
315
])
321
316
;
322
317
$ managementClient
323
- ->expects ($ this ->at ( 2 ))
318
+ ->expects ($ this ->once ( ))
324
319
->method ('bind ' )
325
320
->with ('aprefix.router ' , 'aprefix.default ' , 'aprefix.default ' )
326
321
;
327
- $ managementClient
328
- ->expects ($ this ->at (3 ))
329
- ->method ('declareQueue ' )
330
- ->with ('aprefix.default ' , [
331
- 'durable ' => true ,
332
- 'auto_delete ' => false ,
333
- 'arguments ' => [
334
- 'x-max-priority ' => 4 ,
335
- ],
336
- ])
337
- ;
338
322
339
323
$ contextMock = $ this ->createContextMock ();
340
324
$ contextMock
@@ -400,22 +384,39 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
400
384
]);
401
385
402
386
$ managementClient = $ this ->createManagementClientMock ();
387
+ $ invoked = $ this ->exactly (2 );
403
388
$ managementClient
404
- ->expects ($ this -> at ( 4 ) )
389
+ ->expects ($ invoked )
405
390
->method ('declareExchange ' )
406
- ->with ('aprefix.default.delayed ' , [
407
- 'type ' => 'x-delayed-message ' ,
408
- 'durable ' => true ,
409
- 'auto_delete ' => false ,
410
- 'arguments ' => [
411
- 'x-delayed-type ' => 'direct ' ,
412
- ],
413
- ])
414
- ;
391
+ ->willReturnCallback (function (string $ name , array $ options ) use ($ invoked ) {
392
+ match ($ invoked ->getInvocationCount ()) {
393
+ 1 => $ this ->assertSame ([
394
+ 'aprefix.router ' ,
395
+ ['type ' => 'fanout ' , 'durable ' => true , 'auto_delete ' => false ],
396
+ ], [$ name , $ options ]),
397
+ 2 => $ this ->assertSame ([
398
+ 'aprefix.default.delayed ' ,
399
+ ['type ' => 'x-delayed-message ' , 'durable ' => true , 'auto_delete ' => false , 'arguments ' => ['x-delayed-type ' => 'direct ' ]],
400
+ ], [$ name , $ options ]),
401
+ };
402
+ });
403
+
404
+ $ bindInvoked = $ this ->exactly (2 );
415
405
$ managementClient
416
- ->expects ($ this -> at ( 5 ) )
406
+ ->expects ($ bindInvoked )
417
407
->method ('bind ' )
418
- ->with ('aprefix.default.delayed ' , 'aprefix.default ' , 'aprefix.default ' )
408
+ ->willReturnCallback (function (string $ exchange , string $ queue , ?string $ routingKey = null , $ arguments = null ) use ($ bindInvoked ) {
409
+ match ($ bindInvoked ->getInvocationCount ()) {
410
+ 1 =>$ this ->assertSame (
411
+ ['aprefix.router ' , 'aprefix.default ' , 'aprefix.default ' , null ],
412
+ [$ exchange , $ queue , $ routingKey , $ arguments ],
413
+ ),
414
+ 2 => $ this ->assertSame (
415
+ ['aprefix.default.delayed ' , 'aprefix.default ' , 'aprefix.default ' , null ],
416
+ [$ exchange , $ queue , $ routingKey , $ arguments ],
417
+ ),
418
+ };
419
+ })
419
420
;
420
421
421
422
$ config = Config::create (
0 commit comments