@@ -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 ' ],
@@ -373,7 +373,7 @@ public function testItDelaysTheMessage()
373
373
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
374
374
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__5000 ' );
375
375
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 ]);
377
377
378
378
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
379
379
$ connection ->publish ('{} ' , ['x-some-headers ' => 'foo ' ], 5000 );
@@ -415,7 +415,7 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
415
415
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
416
416
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages__120000 ' );
417
417
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 ]);
419
419
$ connection ->publish ('{} ' , [], 120000 );
420
420
}
421
421
@@ -447,12 +447,27 @@ public function testAmqpStampHeadersAreUsed()
447
447
$ amqpExchange = $ this ->createMock (\AMQPExchange::class)
448
448
);
449
449
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 ]);
451
451
452
452
$ connection = Connection::fromDsn ('amqp://localhost ' , [], $ factory );
453
453
$ connection ->publish ('body ' , ['Foo ' => 'X ' ], 0 , new AmqpStamp (null , AMQP_NOPARAM , ['headers ' => ['Bar ' => 'Y ' ]]));
454
454
}
455
455
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
+
456
471
public function testItCanPublishWithTheDefaultRoutingKey ()
457
472
{
458
473
$ factory = new TestAmqpFactory (
@@ -519,7 +534,7 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
519
534
$ delayQueue ->expects ($ this ->once ())->method ('declareQueue ' );
520
535
$ delayQueue ->expects ($ this ->once ())->method ('bind ' )->with ('delays ' , 'delay_messages_routing_key_120000 ' );
521
536
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 ]);
523
538
$ connection ->publish ('{} ' , [], 120000 , new AmqpStamp ('routing_key ' ));
524
539
}
525
540
0 commit comments