From 50e3d4b0fb09f82b3550b65fd623b65302f440f5 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Tue, 3 May 2022 14:08:13 +0200 Subject: [PATCH 1/4] fix queue url passed to job --- src/Sub/Queue/SqsSnsQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sub/Queue/SqsSnsQueue.php b/src/Sub/Queue/SqsSnsQueue.php index f88e5dc..830afcb 100644 --- a/src/Sub/Queue/SqsSnsQueue.php +++ b/src/Sub/Queue/SqsSnsQueue.php @@ -41,7 +41,7 @@ public function later($delay, $job, $data = '', $queue = null) public function pop($queue = null) { $response = $this->sqs->receiveMessage([ - 'QueueUrl' => $this->getQueue($queue), + 'QueueUrl' => $queue = $this->getQueue($queue), 'AttributeNames' => ['ApproximateReceiveCount'], ]); From 46437e833bcb3b38bf093cc4b336f3c33d012ffd Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Tue, 3 May 2022 13:31:24 +0100 Subject: [PATCH 2/4] Update SqsSnsQueue.php --- src/Sub/Queue/SqsSnsQueue.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sub/Queue/SqsSnsQueue.php b/src/Sub/Queue/SqsSnsQueue.php index 830afcb..0265963 100644 --- a/src/Sub/Queue/SqsSnsQueue.php +++ b/src/Sub/Queue/SqsSnsQueue.php @@ -40,8 +40,10 @@ public function later($delay, $job, $data = '', $queue = null) */ public function pop($queue = null) { + $queue = $this->getQueue($queue); + $response = $this->sqs->receiveMessage([ - 'QueueUrl' => $queue = $this->getQueue($queue), + 'QueueUrl' => $queue, 'AttributeNames' => ['ApproximateReceiveCount'], ]); From 1c233fa55a8a82fcfd27a5ad0a67eb4c37813390 Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Tue, 3 May 2022 13:45:32 +0100 Subject: [PATCH 3/4] Add missing test --- composer.json | 3 ++- tests/Sub/Queue/SqsSnsQueueTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8aed55f..027e4cc 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ "php": "^7.3|^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52 || ^9.0" + "illuminate/support": "^8.52 || ^9.0", + "laravel/framework": "9.*" }, "require-dev": { "orchestra/testbench": "^6.0 || ^7.0" diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index 09442f3..ad067ee 100644 --- a/tests/Sub/Queue/SqsSnsQueueTest.php +++ b/tests/Sub/Queue/SqsSnsQueueTest.php @@ -42,12 +42,31 @@ public function it_can_receive_a_rich_notification_message_and_pop_it_off_the_qu { $this->sqs->shouldReceive('receiveMessage') ->once() + ->with(['QueueUrl' => '/default', 'AttributeNames' => ['ApproximateReceiveCount']]) ->andReturn($this->mockedRichNotificationMessage()); $queue = new SqsSnsQueue($this->sqs, 'default'); $queue->setContainer($this->app); $result = $queue->pop(); + + $this->assertInstanceOf(SnsEventDispatcherJob::class, $result); + $this->assertEquals('/default', $result->getQueue()); + } + + /** @test */ + public function it_should_use_the_queue_name_including_prefix_and_suffix() + { + $this->sqs->shouldReceive('receiveMessage') + ->once() + ->with(['QueueUrl' => 'prefix/default-suffix', 'AttributeNames' => ['ApproximateReceiveCount']]) + ->andReturn($this->mockedRichNotificationMessage()); + + $queue = new SqsSnsQueue($this->sqs, 'default', 'prefix', '-suffix'); + $queue->setContainer($this->app); + $result = $queue->pop(); + $this->assertInstanceOf(SnsEventDispatcherJob::class, $result); + $this->assertEquals('prefix/default-suffix', $result->getQueue()); } /** @test */ From a0dd6e91848d8bbc35e5916eb765733a2209249a Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Tue, 3 May 2022 13:46:06 +0100 Subject: [PATCH 4/4] WIP --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 027e4cc..8aed55f 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,7 @@ "php": "^7.3|^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52 || ^9.0", - "laravel/framework": "9.*" + "illuminate/support": "^8.52 || ^9.0" }, "require-dev": { "orchestra/testbench": "^6.0 || ^7.0"