[Messenger] fix ignore account & endpoint options amazon sqs connection

This commit is contained in:
Juraj Surman 2020-07-21 17:20:50 +02:00
parent 08ff65fcb5
commit fc90a3b7c6
2 changed files with 13 additions and 1 deletions

View File

@ -139,6 +139,16 @@ class ConnectionTest extends TestCase
);
}
public function testFromDsnWithAccountAndEndpointOption()
{
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
$this->assertEquals(
new Connection(['account' => 12345], new SqsClient(['endpoint' => 'https://custom-endpoint.tld', 'region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
Connection::fromDsn('sqs://default', ['endpoint' => 'https://custom-endpoint.tld', 'account' => 12345], $httpClient)
);
}
public function testKeepGettingPendingMessages()
{
$client = $this->createMock(SqsClient::class);

View File

@ -117,13 +117,15 @@ class Connection
$clientConfiguration['region'] = $matches[1];
}
unset($query['sslmode']);
} elseif (self::DEFAULT_OPTIONS['endpoint'] !== $options['endpoint'] ?? self::DEFAULT_OPTIONS['endpoint']) {
$clientConfiguration['endpoint'] = $options['endpoint'];
}
$parsedPath = explode('/', ltrim($parsedUrl['path'] ?? '/', '/'));
if (\count($parsedPath) > 0 && !empty($queueName = end($parsedPath))) {
$configuration['queue_name'] = $queueName;
}
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : null;
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : $options['account'] ?? self::DEFAULT_OPTIONS['account'];
// check for extra keys in options
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));