21
21
22
22
/**
23
23
* @requires extension amqp
24
+ *
25
+ * @group time-sensitive
24
26
*/
25
27
class ConnectionTest extends TestCase
26
28
{
@@ -266,7 +268,7 @@ public function testItSetupsTheConnectionWithDefaults()
266
268
);
267
269
268
270
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
269
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 ]);
271
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
270
272
$ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
271
273
$ amqpQueue ->expects ($ this ->once ())->method ('bind ' )->with (self ::DEFAULT_EXCHANGE_NAME , null );
272
274
@@ -289,7 +291,7 @@ public function testItSetupsTheConnection()
289
291
$ factory ->method ('createQueue ' )->will ($ this ->onConsecutiveCalls ($ amqpQueue0 , $ amqpQueue1 ));
290
292
291
293
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
292
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , 'routing_key ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 ]);
294
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , 'routing_key ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
293
295
$ amqpQueue0 ->expects ($ this ->once ())->method ('declareQueue ' );
294
296
$ amqpQueue0 ->expects ($ this ->exactly (2 ))->method ('bind ' )->withConsecutive (
295
297
[self ::DEFAULT_EXCHANGE_NAME , 'binding_key0 ' ],
@@ -326,7 +328,7 @@ public function testBindingArguments()
326
328
$ factory ->method ('createQueue ' )->willReturn ($ amqpQueue );
327
329
328
330
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
329
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 ]);
331
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
330
332
$ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
331
333
$ amqpQueue ->expects ($ this ->exactly (1 ))->method ('bind ' )->withConsecutive (
332
334
[self ::DEFAULT_EXCHANGE_NAME , null , ['x-match ' => 'all ' ]]
@@ -439,7 +441,7 @@ public function testItDelaysTheMessage()
439
441
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
440
442
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__5000 ' );
441
443
442
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ], 'delivery_mode ' => 2 ]);
444
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
443
445
444
446
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
445
447
$ connection ->publish ('{} ' , ['x-some-headers ' => 'foo ' ], 5000 );
@@ -481,7 +483,7 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
481
483
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
482
484
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__120000 ' );
483
485
484
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 ]);
486
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
485
487
$ connection ->publish ('{} ' , [], 120000 );
486
488
}
487
489
@@ -513,7 +515,7 @@ public function testAmqpStampHeadersAreUsed()
513
515
$ amqpExchange = $ this ->createMock (\AMQPExchange::class)
514
516
);
515
517
516
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ], 'delivery_mode ' => 2 ]);
518
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
517
519
518
520
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
519
521
$ connection ->publish ('body ' , ['Foo ' => 'X ' ], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['headers ' => ['Bar ' => 'Y ' ]]));
@@ -528,7 +530,7 @@ public function testAmqpStampDelireryModeIsUse
6D40
d()
528
530
$ amqpExchange = $ this ->createMock (\AMQPExchange::class)
529
531
);
530
532
531
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 1 ]);
533
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 1 , ' timestamp ' => time () ]);
532
534
533
535
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
534
536
$ connection ->publish ('body ' , [], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['delivery_mode ' => 1 ]));
@@ -600,7 +602,7 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
600
602
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
601
603
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages_routing_key_120000 ' );
602
604
603
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 ]);
605
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 2 , ' timestamp ' => time () ]);
604
606
$ connection ->publish ('{} ' , [], 120000 , new AmqpStamp ('routing_key ' ));
605
607
}
606
608
@@ -617,7 +619,7 @@ public function testItCanPublishWithCustomFlagsAndAttributes()
617
619
'body ' ,
618
620
'routing_key ' ,
619
621
AMQP_IMMEDIATE ,
620
- ['delivery_mode ' => 2 , 'headers ' => ['type ' => DummyMessage::class]]
622
+ ['delivery_mode ' => 2 , 'headers ' => ['type ' => DummyMessage::class], ' timestamp ' => time () ]
621
623
);
622
624
623
625
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
0 commit comments