@@ -288,6 +288,144 @@ public function testShouldSendMessageToRouter()
288288 $ driver ->sendToRouter ($ message );
289289 }
290290
291+ public function testShouldNotInitDeliveryDelayOnSendMessageToRouter ()
292+ {
293+ $ topic = $ this ->createTopic ('' );
294+ $ transportMessage = $ this ->createMessage ();
295+
296+ $ producer = $ this ->createProducerMock ();
297+ $ producer
298+ ->expects ($ this ->once ())
299+ ->method ('send ' )
300+ ->with ($ this ->identicalTo ($ topic ), $ this ->identicalTo ($ transportMessage ))
301+ ;
302+ $ producer
303+ ->expects ($ this ->never ())
304+ ->method ('setDeliveryDelay ' )
305+ ;
306+
307+ $ context = $ this ->createContextMock ();
308+ $ context
309+ ->expects ($ this ->once ())
310+ ->method ('createTopic ' )
311+ ->willReturn ($ topic )
312+ ;
313+ $ context
314+ ->expects ($ this ->once ())
315+ ->method ('createProducer ' )
316+ ->willReturn ($ producer )
317+ ;
318+ $ context
319+ ->expects ($ this ->once ())
320+ ->method ('createMessage ' )
321+ ->willReturn ($ transportMessage )
322+ ;
323+
324+ $ driver = $ this ->createDriver (
325+ $ context ,
326+ $ this ->createDummyConfig (),
327+ new RouteCollection ([])
328+ );
329+
330+ $ message = new Message ();
331+ $ message ->setDelay (456 );
332+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
333+
334+ $ driver ->sendToRouter ($ message );
335+ }
336+
337+ public function testShouldNotInitTimeToLiveOnSendMessageToRouter ()
338+ {
339+ $ topic = $ this ->createTopic ('' );
340+ $ transportMessage = $ this ->createMessage ();
341+
342+ $ producer = $ this ->createProducerMock ();
343+ $ producer
344+ ->expects ($ this ->once ())
345+ ->method ('send ' )
346+ ->with ($ this ->identicalTo ($ topic ), $ this ->identicalTo ($ transportMessage ))
347+ ;
348+ $ producer
349+ ->expects ($ this ->never ())
350+ ->method ('setTimeToLive ' )
351+ ;
352+
353+ $ context = $ this ->createContextMock ();
354+ $ context
355+ ->expects ($ this ->once ())
356+ ->method ('createTopic ' )
357+ ->willReturn ($ topic )
358+ ;
359+ $ context
360+ ->expects ($ this ->once ())
361+ ->method ('createProducer ' )
362+ ->willReturn ($ producer )
363+ ;
364+ $ context
365+ ->expects ($ this ->once ())
366+ ->method ('createMessage ' )
367+ ->willReturn ($ transportMessage )
368+ ;
369+
370+ $ driver = $ this ->createDriver (
371+ $ context ,
372+ $ this ->createDummyConfig (),
373+ new RouteCollection ([])
374+ );
375+
376+ $ message = new Message ();
377+ $ message ->setExpire (456 );
378+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
379+
380+ $ driver ->sendToRouter ($ message );
381+ }
382+
383+ public function testShouldNotInitPriorityOnSendMessageToRouter ()
384+ {
385+ $ topic = $ this ->createTopic ('' );
386+ $ transportMessage = $ this ->createMessage ();
387+
388+ $ producer = $ this ->createProducerMock ();
389+ $ producer
390+ ->expects ($ this ->once ())
391+ ->method ('send ' )
392+ ->with ($ this ->identicalTo ($ topic ), $ this ->identicalTo ($ transportMessage ))
393+ ;
394+ $ producer
395+ ->expects ($ this ->never ())
396+ ->method ('setPriority ' )
397+ ;
398+
399+ $ context = $ this ->createContextMock ();
400+ $ context
401+ ->expects ($ this ->once ())
402+ ->method ('createTopic ' )
403+ ->willReturn ($ topic )
404+ ;
405+ $ context
406+ ->expects ($ this ->once ())
407+ ->method ('createProducer ' )
408+ ->willReturn ($ producer )
409+ ;
410+ $ context
411+ ->expects ($ this ->once ())
412+ ->method ('createMessage ' )
413+ ->willReturn ($ transportMessage )
414+ ;
415+
416+ $ driver = $ this ->createDriver (
417+ $ context ,
418+ $ this ->createDummyConfig (),
419+ new RouteCollection ([])
420+ );
421+
422+ $ message = new Message ();
423+ $ message ->setPriority (MessagePriority::HIGH );
424+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
425+
426+ $ driver ->sendToRouter ($ message );
427+ }
428+
291429 public function testThrowIfTopicIsNotSetOnSendToRouter ()
292430 {
293431 $ driver = $ this ->createDriver (
@@ -407,6 +545,156 @@ public function testShouldSendTopicMessageToProcessorToCustomQueue()
407545 $ driver ->sendToProcessor ($ message );
408546 }
409547
548+ public function testShouldInitDeliveryDelayIfDelayPropertyOnSendToProcessor ()
549+ {
550+ $ queue = $ this ->createQueue ('' );
551+ $ transportMessage = $ this ->createMessage ();
552+
553+ $ producer = $ this ->createProducerMock ();
554+ $ producer
555+ ->expects ($ this ->once ())
556+ ->method ('setDeliveryDelay ' )
557+ ->with (456000 )
558+ ;
559+ $ producer
560+ ->expects ($ this ->once ())
561+ ->method ('send ' )
562+ ->with ($ this ->identicalTo ($ queue ), $ this ->identicalTo ($ transportMessage ))
563+ ;
564+ $ context = $ this ->createContextMock ();
565+ $ context
566+ ->expects ($ this ->once ())
567+ ->method ('createQueue ' )
568+ ->with ('default ' )
569+ ->willReturn ($ queue )
570+ ;
571+ $ context
572+ ->expects ($ this ->once ())
573+ ->method ('createProducer ' )
574+ ->willReturn ($ producer )
575+ ;
576+ $ context
577+ ->expects ($ this ->once ())
578+ ->method ('createMessage ' )
579+ ->willReturn ($ transportMessage )
580+ ;
581+
582+ $ driver = $ this ->createDriver (
583+ $ context ,
584+ $ this ->createDummyConfig (),
585+ new RouteCollection ([
586+ new Route ('topic ' , Route::TOPIC , 'processor ' ),
587+ ])
588+ );
589+
590+ $ message = new Message ();
591+ $ message ->setDelay (456 );
592+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
593+ $ message ->setProperty (Config::PARAMETER_PROCESSOR_NAME , 'processor ' );
594+
595+ $ driver ->sendToProcessor ($ message );
596+ }
597+
598+ public function testShouldSetInitTimeToLiveIfExpirePropertyOnSendToProcessor ()
599+ {
600+ $ queue = $ this ->createQueue ('' );
601+ $ transportMessage = $ this ->createMessage ();
602+
603+ $ producer = $ this ->createProducerMock ();
604+ $ producer
605+ ->expects ($ this ->once ())
606+ ->method ('setTimeToLive ' )
607+ ->with (678000 )
608+ ;
609+ $ producer
610+ ->expects ($ this ->once ())
611+ ->method ('send ' )
612+ ->with ($ this ->identicalTo ($ queue ), $ this ->identicalTo ($ transportMessage ))
613+ ;
614+ $ context = $ this ->createContextMock ();
615+ $ context
616+ ->expects ($ this ->once ())
617+ ->method ('createQueue ' )
618+ ->with ('default ' )
619+ ->willReturn ($ queue )
620+ ;
621+ $ context
622+ ->expects ($ this ->once ())
623+ ->method ('createProducer ' )
624+ ->willReturn ($ producer )
625+ ;
626+ $ context
627+ ->expects ($ this ->once ())
628+ ->method ('createMessage ' )
629+ ->willReturn ($ transportMessage )
630+ ;
631+
632+ $ driver = $ this ->createDriver (
633+ $ context ,
634+ $ this ->createDummyConfig (),
635+ new RouteCollection ([
636+ new Route ('topic ' , Route::TOPIC , 'processor ' ),
637+ ])
638+ );
639+
640+ $ message = new Message ();
641+ $ message ->setExpire (678 );
642+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
643+ $ message ->setProperty (Config::PARAMETER_PROCESSOR_NAME , 'processor ' );
644+
645+ $ driver ->sendToProcessor ($ message );
646+ }
647+
648+ public function testShouldSetInitPriorityIfPriorityPropertyOnSendToProcessor ()
649+ {
650+ $ queue = $ this ->createQueue ('' );
651+ $ transportMessage = $ this ->createMessage ();
652+
653+ $ producer = $ this ->createProducerMock ();
654+ $ producer
655+ ->expects ($ this ->once ())
656+ ->method ('setPriority ' )
657+ ->with (3 )
658+ ;
659+ $ producer
660+ ->expects ($ this ->once ())
661+ ->method ('send ' )
662+ ->with ($ this ->identicalTo ($ queue ), $ this ->identicalTo ($ transportMessage ))
663+ ;
664+ $ context = $ this ->createContextMock ();
665+ $ context
666+ ->expects ($ this ->once ())
667+ ->method ('createQueue ' )
668+ ->with ('default ' )
669+ ->willReturn ($ queue )
670+ ;
671+ $ context
672+ ->expects ($ this ->once ())
673+ ->method ('createProducer ' )
674+ ->willReturn ($ producer )
675+ ;
676+ $ context
677+ ->expects ($ this ->once ())
678+ ->method ('createMessage ' )
679+ ->willReturn ($ transportMessage )
680+ ;
681+
682+ $ driver = $ this ->createDriver (
683+ $ context ,
684+ $ this ->createDummyConfig (),
685+ new RouteCollection ([
686+ new Route ('topic ' , Route::TOPIC , 'processor ' ),
687+ ])
688+ );
689+
690+ $ message = new Message ();
691+ $ message ->setPriority (MessagePriority::HIGH );
692+ $ message ->setProperty (Config::PARAMETER_TOPIC_NAME , 'topic ' );
693+ $ message ->setProperty (Config::PARAMETER_PROCESSOR_NAME , 'processor ' );
694+
695+ $ driver ->sendToProcessor ($ message );
696+ }
697+
410698 public function testThrowIfNoRouteFoundForTopicMessageOnSendToProcessor ()
411699 {
412700 $ context = $ this ->createContextMock ();
0 commit comments