@@ -41,6 +41,36 @@ public function test_queue_sends_message_group_id()
4141 $ queue ->pushRaw ($ job );
4242 }
4343
44+ public function test_queue_sends_message_group_id_as_string ()
45+ {
46+ $ group = 1234 ;
47+ $ job = 'test ' ;
48+ $ closure = function ($ message ) use ($ group ) {
49+ if (gettype ($ message ['MessageGroupId ' ]) != 'string ' ) {
50+ $ this ->fail ('MessageGroupId pushed to AWS must be a string. ' );
51+
52+ return false ;
53+ }
54+
55+ if ($ message ['MessageGroupId ' ] !== strval ($ group )) {
56+ $ this ->fail ('MessageGroupId pushed to AWS did not convert correctly. ' );
57+
58+ return false ;
59+ }
60+
61+ return true ;
62+ };
63+
64+ $ result = new Result (['MessageId ' => '1234 ' ]);
65+ $ client = m::mock (SqsClient::class);
66+ $ client ->shouldReceive ('sendMessage ' )->once ()->with (m::on ($ closure ))->andReturn ($ result );
67+
68+ $ queue = new SqsFifoQueue ($ client , '' , '' , '' , false , $ group , '' );
69+ $ queue ->setContainer ($ this ->app );
70+
71+ $ queue ->pushRaw ($ job );
72+ }
73+
4474 public function test_queue_sends_message_group_id_from_job ()
4575 {
4676 $ group = 'job-group ' ;
@@ -348,6 +378,40 @@ public function test_queue_sends_custom_message_deduplication_id()
348378 $ queue ->pushRaw ($ job );
349379 }
350380
381+ public function test_queue_sends_custom_message_deduplication_id_as_string ()
382+ {
383+ $ idResult = 1234 ;
384+
385+ $ this ->bind_custom_deduplicator ($ idResult );
386+
387+ $ job = 'test ' ;
388+ $ deduplication = 'custom ' ;
389+ $ closure = function ($ message ) use ($ job , $ idResult ) {
390+ if (gettype ($ message ['MessageDeduplicationId ' ]) != 'string ' ) {
391+ $ this ->fail ('MessageDeduplicationId pushed to AWS must be a string. ' );
392+
393+ return false ;
394+ }
395+
396+ if ($ message ['MessageDeduplicationId ' ] !== strval ($ idResult )) {
397+ $ this ->fail ('MessageDeduplicationId pushed to AWS did not convert correctly. ' );
398+
399+ return false ;
400+ }
401+
402+ return true ;
403+ };
404+
405+ $ result = new Result (['MessageId ' => '1234 ' ]);
406+ $ client = m::mock (SqsClient::class);
407+ $ client ->shouldReceive ('sendMessage ' )->once ()->with (m::on ($ closure ))->andReturn ($ result );
408+
409+ $ queue = new SqsFifoQueue ($ client , '' , '' , '' , false , '' , $ deduplication );
410+ $ queue ->setContainer ($ this ->app );
411+
412+ $ queue ->pushRaw ($ job );
413+ }
414+
351415 public function test_queue_throws_exception_with_invalid_deduplicator ()
352416 {
353417 $ this ->bind_invalid_custom_deduplicator ();
@@ -495,11 +559,11 @@ public function test_get_queue_properly_resolves_url_with_prefix_support()
495559 $ this ->assertEquals ($ queueUrl , $ queue ->getQueue ($ queueUrl ));
496560 }
497561
498- protected function bind_custom_deduplicator ()
562+ protected function bind_custom_deduplicator ($ returnId = ' custom ' )
499563 {
500- $ this ->app ->bind ('queue.sqs-fifo.deduplicator.custom ' , function () {
501- return new \ShiftOneLabs \LaravelSqsFifoQueue \Queue \Deduplicators \Callback (function ($ payload , $ queue ) {
502- return ' custom ' ;
564+ $ this ->app ->bind ('queue.sqs-fifo.deduplicator.custom ' , function () use ( $ returnId ) {
565+ return new \ShiftOneLabs \LaravelSqsFifoQueue \Queue \Deduplicators \Callback (function ($ payload , $ queue ) use ( $ returnId ) {
566+ return $ returnId ;
503567 });
504568 });
505569 }
0 commit comments