Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* commit '09cc9c7ca77f70e4b3fc4ecfe00f097abc9d77b5':
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents fcdc960 + 67d65de commit 164c7a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions Tests/Transport/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use AsyncAws\Sqs\Result\ReceiveMessageResult;
use AsyncAws\Sqs\SqsClient;
use AsyncAws\Sqs\ValueObject\Message;
use Composer\InstalledVersions;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
use Symfony\Component\HttpClient\MockHttpClient;
Expand Down Expand Up @@ -358,6 +359,16 @@ public function testLoggerWithDebugOption()

private function getMockedQueueUrlResponse(): MockResponse
{
if ($this->isAsyncAwsSqsVersion2Installed()) {
return new MockResponse(
<<<JSON
{
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
}
JSON
);
}

return new MockResponse(<<<XML
<GetQueueUrlResponse>
<GetQueueUrlResult>
Expand All @@ -373,6 +384,28 @@ private function getMockedQueueUrlResponse(): MockResponse

private function getMockedReceiveMessageResponse(): MockResponse
{
if ($this->isAsyncAwsSqsVersion2Installed()) {
return new MockResponse(<<<JSON
{
"Messages": [
{
"Attributes": {
"SenderId": "195004372649",
"ApproximateFirstReceiveTimestamp": "1250700979248",
"ApproximateReceiveCount": "5",
"SentTimestamp": "1238099229000"
},
"Body": "This is a test message",
"MD5OfBody": "fafb00f5732ab283681e124bf8747ed1",
"MessageId": "5fea7756-0ea4-451a-a703-a558b933e274",
"ReceiptHandle": "MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+CwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0="
}
]
}
JSON
);
}

return new MockResponse(<<<XML
<ReceiveMessageResponse>
<ReceiveMessageResult>
Expand Down Expand Up @@ -410,4 +443,11 @@ private function getMockedReceiveMessageResponse(): MockResponse
XML
);
}

private function isAsyncAwsSqsVersion2Installed(): bool
{
$version = InstalledVersions::getVersion('async-aws/sqs');

return 'dev-master' === $version || version_compare($version, '2.0.0') >= 0;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=8.1",
"async-aws/core": "^1.7",
"async-aws/sqs": "^1.0",
"async-aws/sqs": "^1.0|^2.0",
"symfony/messenger": "^5.4|^6.0|^7.0",
"symfony/service-contracts": "^2.5|^3",
"psr/log": "^1|^2|^3"
Expand Down

0 comments on commit 164c7a1

Please sign in to comment.