diff --git a/CHANGELOG.md b/CHANGELOG.md index 0716e52a2..96eec0213 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [0.8.16](https://github.com/php-enqueue/enqueue-dev/tree/0.8.16) (2018-01-13) +[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.15...0.8.16) + +- \[Sqs\] Allow array-based DSN configuration [\#315](https://github.com/php-enqueue/enqueue-dev/pull/315) ([beryllium](https://github.com/beryllium)) + ## [0.8.15](https://github.com/php-enqueue/enqueue-dev/tree/0.8.15) (2018-01-12) [Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.14...0.8.15) diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index a12f5e31c..db9768ed1 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -193,7 +193,7 @@ public function provideEnqueueConfigs() ]]; // travis build does not have secret env vars if contribution is from outside. - if (false == getenv('AWS_SQS_KEY')) { + if (getenv('AWS_SQS_KEY')) { yield 'sqs' => [[ 'transport' => [ 'default' => 'sqs', diff --git a/pkg/sqs/SqsConnectionFactory.php b/pkg/sqs/SqsConnectionFactory.php index 8a67db7e8..e89859c05 100644 --- a/pkg/sqs/SqsConnectionFactory.php +++ b/pkg/sqs/SqsConnectionFactory.php @@ -42,6 +42,12 @@ public function __construct($config = 'sqs:') } elseif (is_string($config)) { $config = $this->parseDsn($config); } elseif (is_array($config)) { + $dsn = array_key_exists('dsn', $config) ? $config['dsn'] : null; + unset($config['dsn']); + + if ($dsn) { + $config = array_replace($config, $this->parseDsn($dsn)); + } } else { throw new \LogicException('The config must be either an array of options, a DSN string or null'); } diff --git a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php index 5f74bcf2f..c6bf10d3f 100644 --- a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php +++ b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php @@ -104,6 +104,19 @@ public static function provideConfigs() ], ]; + yield [ + ['dsn' => 'sqs:?key=theKey&secret=theSecret&token=theToken&lazy=0'], + [ + 'key' => 'theKey', + 'secret' => 'theSecret', + 'token' => 'theToken', + 'region' => null, + 'retries' => 3, + 'version' => '2012-11-05', + 'lazy' => false, + ], + ]; + yield [ ['key' => 'theKey', 'secret' => 'theSecret', 'token' => 'theToken', 'lazy' => false], [