Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions tests/Queue/QueueSqsQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ public function testPushProperlyPushesJobStringOntoSqsFifoQueue()
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->fifoQueueName, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->fifoQueueName,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->push($this->mockedJob, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -345,7 +350,12 @@ public function testPushProperlyPushesJobObjectOntoSqsFifoQueue()
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($job, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->push($job, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -363,7 +373,12 @@ public function testPushProperlyPushesJobObjectOntoSqsFifoQueueWithDeduplication
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($job, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->push($job, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -386,7 +401,12 @@ public function testPushProperlyPushesJobObjectOntoSqsFifoQueueWithDeduplicator(
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($job, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->push($job, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -402,7 +422,12 @@ public function testPendingDispatchProperlyPushesJobObjectOntoSqsFifoQueue()
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($pendingDispatch->getJob(), $this->fifoQueueName, '')->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with(null)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);

$dispatcher = new Dispatcher($container, fn () => $queue);
app()->instance(DispatcherContract::class, $dispatcher);
Expand All @@ -425,7 +450,12 @@ public function testPendingDispatchProperlyPushesJobObjectOntoSqsFifoQueueWithDe
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($pendingDispatch->getJob(), $this->fifoQueueName, '')->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with(null)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);

$dispatcher = new Dispatcher($container, fn () => $queue);
app()->instance(DispatcherContract::class, $dispatcher);
Expand Down Expand Up @@ -457,7 +487,12 @@ public function testPendingDispatchProperlyPushesJobObjectOntoSqsFifoQueueWithDe
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($pendingDispatch->getJob(), $this->fifoQueueName, '')->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with(null)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);

$dispatcher = new Dispatcher($container, fn () => $queue);
app()->instance(DispatcherContract::class, $dispatcher);
Expand Down Expand Up @@ -515,7 +550,12 @@ public function testDelayedPushProperlyPushesJobStringOntoSqsFifoQueueWithoutDel
$queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->never())->method('secondsUntil')->with($this->mockedDelay)->willReturn($this->mockedDelay);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->fifoQueueName, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->fifoQueueName,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->later($this->mockedDelay, $this->mockedJob, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -534,7 +574,12 @@ public function testDelayedPushProperlyPushesJobObjectOntoSqsFifoQueueWithoutDel
$queue->expects($this->once())->method('createPayload')->with($job, $this->fifoQueueName, $this->mockedData)->willReturn($this->mockedPayload);
$queue->expects($this->never())->method('secondsUntil')->with($this->mockedDelay)->willReturn($this->mockedDelay);
$queue->expects($this->once())->method('getQueue')->with($this->fifoQueueName)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);
$id = $queue->later($this->mockedDelay, $job, $this->mockedData, $this->fifoQueueName);
$this->assertEquals($this->mockedMessageId, $id);
$container->shouldHaveReceived('bound')->with('events')->twice();
Expand All @@ -552,7 +597,12 @@ public function testDelayedPendingDispatchProperlyPushesJobObjectOntoSqsFifoQueu
$queue->setContainer($container = m::spy(Container::class));
$queue->expects($this->once())->method('createPayload')->with($pendingDispatch->getJob(), $this->fifoQueueName, '')->willReturn($this->mockedPayload);
$queue->expects($this->once())->method('getQueue')->with(null)->willReturn($this->fifoQueueUrl);
$this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->fifoQueueUrl, 'MessageBody' => $this->mockedPayload, 'MessageGroupId' => $this->mockedMessageGroupId, 'MessageDeduplicationId' => $this->mockedDeduplicationId])->andReturn($this->mockedSendMessageResponseModel);
$this->sqs->shouldReceive('sendMessage')->once()->with([
'QueueUrl' => $this->fifoQueueUrl,
'MessageBody' => $this->mockedPayload,
'MessageGroupId' => $this->mockedMessageGroupId,
'MessageDeduplicationId' => $this->mockedDeduplicationId,
])->andReturn($this->mockedSendMessageResponseModel);

$dispatcher = new Dispatcher($container, fn () => $queue);
app()->instance(DispatcherContract::class, $dispatcher);
Expand Down