Skip to content

Commit e4089c6

Browse files
author
Gytis Semenas
committed
Added endpoint configuration and updated the tests
1 parent 6b5b7cd commit e4089c6

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎pkg/sqs/SqsConnectionFactory.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SqsConnectionFactory implements PsrConnectionFactory
2626
* 'retries' => 3, - (int, default=int(3)) Configures the maximum number of allowed retries for a client (pass 0 to disable retries).
2727
* 'version' => '2012-11-05', - (string, required) The version of the webservice to utilize
2828
* 'lazy' => true, - Enable lazy connection (boolean)
29+
* 'endpoint' => null - (string, default=null) The full URI of the webservice. This is only required when connecting to a custom endpoint e.g. localstack
2930
* ].
3031
*
3132
* or
@@ -93,6 +94,10 @@ private function establishConnection()
9394
'region' => $this->config['region'],
9495
];
9596

97+
if (isset($this->config['endpoint'])) {
98+
$config['endpoint'] = $this->config['endpoint'];
99+
}
100+
96101
if ($this->config['key'] && $this->config['secret']) {
97102
$config['credentials'] = [
98103
'key' => $this->config['key'],
@@ -151,6 +156,7 @@ private function defaultConfig()
151156
'retries' => 3,
152157
'version' => '2012-11-05',
153158
'lazy' => true,
159+
'endpoint' => null
154160
];
155161
}
156162
}

‎pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static function provideConfigs()
6262
'retries' => 3,
6363
'version' => '2012-11-05',
6464
'lazy' => true,
65+
'endpoint' => null,
6566
],
6667
];
6768

@@ -75,6 +76,7 @@ public static function provideConfigs()
7576
'retries' => 3,
7677
'version' => '2012-11-05',
7778
'lazy' => true,
79+
'endpoint' => null,
7880
],
7981
];
8082

@@ -88,6 +90,7 @@ public static function provideConfigs()
8890
'retries' => 3,
8991
'version' => '2012-11-05',
9092
'lazy' => true,
93+
'endpoint' => null,
9194
],
9295
];
9396

@@ -101,6 +104,7 @@ public static function provideConfigs()
101104
'retries' => 3,
102105
'version' => '2012-11-05',
103106
'lazy' => false,
107+
'endpoint' => null,
104108
],
105109
];
106110

@@ -114,6 +118,7 @@ public static function provideConfigs()
114118
'retries' => 3,
115119
'version' => '2012-11-05',
116120
'lazy' => false,
121+
'endpoint' => null,
117122
],
118123
];
119124

@@ -127,6 +132,27 @@ public static function provideConfigs()
127132
'retries' => 3,
128133
'version' => '2012-11-05',
129134
'lazy' => false,
135+
'endpoint' => null,
136+
],
137+
];
138+
139+
yield [
140+
[
141+
'key' => 'theKey',
142+
'secret' => 'theSecret',
143+
'token' => 'theToken',
144+
'lazy' => false,
145+
'endpoint' => 'http://localstack:1111'
146+
],
147+
[
148+
'key' => 'theKey',
149+
'secret' => 'theSecret',
150+
'token' => 'theToken',
151+
'region' => null,
152+
'retries' => 3,
153+
'version' => '2012-11-05',
154+
'lazy' => false,
155+
'endpoint' => 'http://localstack:1111',
130156
],
131157
];
132158
}

‎pkg/sqs/Tests/SqsConnectionFactoryTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function testCouldBeConstructedWithCustomConfiguration()
4343
'region' => null,
4444
'retries' => 3,
4545
'version' => '2012-11-05',
46+
'endpoint' => null
4647
], 'config', $factory);
4748
}
4849

0 commit comments

Comments
 (0)