@@ -227,7 +227,7 @@ public function testItSetupsTheConnectionWithDefaults()
227
227
);
228
228
229
229
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
230
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => []]);
230
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
231
231
$ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
232
232
$ amqpQueue ->expects ($ this ->once ())->method ('bind ' )->with (self ::DEFAULT_EXCHANGE_NAME , null );
233
233
@@ -250,7 +250,7 @@ public function testItSetupsTheConnection()
250
250
$ factory ->method ('createQueue ' )->will ($ this ->onConsecutiveCalls ($ amqpQueue0 , $ amqpQueue1 ));
251
251
252
252
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
253
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , 'routing_key ' , AMQP_NOPARAM , ['headers ' => []]);
253
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , 'routing_key ' , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
254
254
$ amqpQueue0 ->expects ($ this ->once ())->method ('declareQueue ' );
255
255
$ amqpQueue0 ->expects ($ this ->exactly (2 ))->method ('bind ' )->withConsecutive (
256
256
[self ::DEFAULT_EXCHANGE_NAME , 'binding_key0 ' ],
@@ -287,7 +287,7 @@ public function testBindingArguments()
287
287
$ factory ->method ('createQueue ' )->willReturn ($ amqpQueue );
288
288
289
289
$ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
290
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => []]);
290
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
291
291
$ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
292
292
$ amqpQueue ->expects ($ this ->exactly (1 ))->method ('bind ' )->withConsecutive (
293
293
[self ::DEFAULT_EXCHANGE_NAME , null , ['x-match ' => 'all ' ]]
@@ -400,7 +400,7 @@ public function testItDelaysTheMessage()
400
400
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
401
401
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__5000 ' );
402
402
403
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ]]);
403
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ], ' delivery_mode ' => 2 ]);
404
404
405
405
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
406
406
$ connection ->publish ('{} ' , ['x-some-headers ' => 'foo ' ], 5000 );
@@ -442,7 +442,7 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
442
442
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
443
443
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__120000 ' );
444
444
445
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => []]);
445
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
446
446
$ connection ->publish ('{} ' , [], 120000 );
447
447
}
448
448
@@ -474,12 +474,27 @@ public function testAmqpStampHeadersAreUsed()
474
474
$ amqpExchange = $ this ->createMock (\AMQPExchange::class)
475
475
);
476
476
477
- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ]]);
477
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ], ' delivery_mode ' => 2 ]);
478
478
479
479
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
480
480
$ connection ->publish ('body ' , ['Foo ' => 'X ' ], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['headers ' => ['Bar ' => 'Y ' ]]));
481
481
}
482
482
483
+ public function testAmqpStampDelireryModeIsUsed ()
484
+ {
485
+ $ factory = new TestAmqpFactory (
486
+ $ this ->createMock (\AMQPConnection::class),
487
+ $ this ->createMock (\AMQPChannel::class),
488
+ $ this ->createMock (\AMQPQueue::class),
489
+ $ amqpExchange = $ this ->createMock (\AMQPExchange::class)
490
+ );
491
+
492
+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 1 ]);
493
+
494
+ $ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
495
+ $ connection ->publish ('body ' , [], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['delivery_mode ' => 1 ]));
496
+ }
497
+
483
498
public function testItCanPublishWithTheDefaultRoutingKey ()
484
499
{
485
500
$ factory = new TestAmqpFactory (
@@ -546,7 +561,7 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
546
561
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
547
562
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages_routing_key_120000 ' );
548
563
549
- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => []]);
564
+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
550
565
$ connection ->publish ('{} ' , [], 120000 , new AmqpStamp ('routing_key ' ));
551
566
}
552
567
0 commit comments