@@ -227,7 +227,7 @@ public function testItSetupsTheConnectionWithDefaults()
227227 );
228228
229229 $ 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 ]);
231231 $ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
232232 $ amqpQueue ->expects ($ this ->once ())->method ('bind ' )->with (self ::DEFAULT_EXCHANGE_NAME , null );
233233
@@ -250,7 +250,7 @@ public function testItSetupsTheConnection()
250250 $ factory ->method ('createQueue ' )->will ($ this ->onConsecutiveCalls ($ amqpQueue0 , $ amqpQueue1 ));
251251
252252 $ 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 ]);
254254 $ amqpQueue0 ->expects ($ this ->once ())->method ('declareQueue ' );
255255 $ amqpQueue0 ->expects ($ this ->exactly (2 ))->method ('bind ' )->withConsecutive (
256256 [self ::DEFAULT_EXCHANGE_NAME , 'binding_key0 ' ],
@@ -373,7 +373,7 @@ public function testItDelaysTheMessage()
373373 $ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
374374 $ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__5000 ' );
375375
376- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ]]);
376+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__5000 ' , AMQP_NOPARAM , ['headers ' => ['x-some-headers ' => 'foo ' ], ' delivery_mode ' => 2 ]);
377377
378378 $ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
379379 $ connection ->publish ('{} ' , ['x-some-headers ' => 'foo ' ], 5000 );
@@ -415,7 +415,7 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
415415 $ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
416416 $ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__120000 ' );
417417
418- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => []]);
418+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages__120000 ' , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
419419 $ connection ->publish ('{} ' , [], 120000 );
420420 }
421421
@@ -447,12 +447,27 @@ public function testAmqpStampHeadersAreUsed()
447447 $ amqpExchange = $ this ->createMock (\AMQPExchange::class)
448448 );
449449
450- $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ]]);
450+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => ['Foo ' => 'X ' , 'Bar ' => 'Y ' ], ' delivery_mode ' => 2 ]);
451451
452452 $ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
453453 $ connection ->publish ('body ' , ['Foo ' => 'X ' ], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['headers ' => ['Bar ' => 'Y ' ]]));
454454 }
455455
456+ public function testAmqpStampDelireryModeIsUsed ()
457+ {
458+ $ factory = new TestAmqpFactory (
459+ $ this ->createMock (\AMQPConnection::class),
460+ $ this ->createMock (\AMQPChannel::class),
461+ $ this ->createMock (\AMQPQueue::class),
462+ $ amqpExchange = $ this ->createMock (\AMQPExchange::class)
463+ );
464+
465+ $ amqpExchange ->expects ($ this ->once ())->method ('publish ' )->with ('body ' , null , AMQP_NOPARAM , ['headers ' => [], 'delivery_mode ' => 1 ]);
466+
467+ $ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
468+ $ connection ->publish ('body ' , [], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['delivery_mode ' => 1 ]));
469+ }
470+
456471 public function testItCanPublishWithTheDefaultRoutingKey ()
457472 {
458473 $ factory = new TestAmqpFactory (
@@ -519,7 +534,7 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
519534 $ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
520535 $ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages_routing_key_120000 ' );
521536
522- $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => []]);
537+ $ delayExchange ->expects ($ this ->once ())->method ('publish ' )->with ('{} ' , 'delay_messages_routing_key_120000 ' , AMQP_NOPARAM , ['headers ' => [], ' delivery_mode ' => 2 ]);
523538 $ connection ->publish ('{} ' , [], 120000 , new AmqpStamp ('routing_key ' ));
524539 }
525540
0 commit comments