Skip to content

Commit b5ac8be

Browse files
committed
sqs transport
1 parent 2627a58 commit b5ac8be

3 files changed

Lines changed: 33 additions & 26 deletions

File tree

‎pkg/sqs/SqsContext.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function deleteQueue(SqsDestination $dest)
187187
/**
188188
* @param SqsDestination $dest
189189
*/
190-
public function purgeQueue(SqsDestination $dest)
190+
public function purge(SqsDestination $dest)
191191
{
192192
$this->getClient()->purgeQueue([
193193
'QueueUrl' => $this->getQueueUrl($dest),

‎pkg/sqs/Tests/Client/SqsDriverTest.php‎

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,22 @@ public function testShouldCreateAndReturnQueueInstance()
4646
{
4747
$expectedQueue = new SqsDestination('aQueueName');
4848

49+
$meta = $this->createQueueMetaRegistryMock();
50+
$meta
51+
->expects($this->once())
52+
->method('getQueueMeta')
53+
->willReturn(new QueueMeta('theClientName', 'theTransportName'))
54+
;
55+
4956
$context = $this->createPsrContextMock();
5057
$context
5158
->expects($this->once())
5259
->method('createQueue')
53-
->with('name')
60+
->with('theTransportName')
5461
->will($this->returnValue($expectedQueue))
5562
;
5663

57-
$driver = new SqsDriver($context, Config::create(), $this->createQueueMetaRegistryMock());
64+
$driver = new SqsDriver($context, Config::create(), $meta);
5865

5966
$queue = $driver->createQueue('name');
6067

@@ -161,17 +168,6 @@ public function testShouldSendMessageToRouterQueue()
161168
$transportMessage = new SqsMessage();
162169
$config = $this->createConfigMock();
163170

164-
$config
165-
->expects($this->once())
166-
->method('getRouterQueueName')
167-
->willReturn('queueName');
168-
169-
$config
170-
->expects($this->once())
171-
->method('createTransportQueueName')
172-
->with('queueName')
173-
->willReturn('app.queueName');
174-
175171
$producer = $this->createPsrProducerMock();
176172
$producer
177173
->expects($this->once())
@@ -182,7 +178,7 @@ public function testShouldSendMessageToRouterQueue()
182178
$context
183179
->expects($this->once())
184180
->method('createQueue')
185-
->with('app.queueName')
181+
->with('theTransportName')
186182
->willReturn($topic)
187183
;
188184
$context
@@ -196,11 +192,14 @@ public function testShouldSendMessageToRouterQueue()
196192
->willReturn($transportMessage)
197193
;
198194

199-
$driver = new SqsDriver(
200-
$context,
201-
$config,
202-
$this->createQueueMetaRegistryMock()
203-
);
195+
$meta = $this->createQueueMetaRegistryMock();
196+
$meta
197+
->expects($this->once())
198+
->method('getQueueMeta')
199+
->willReturn(new QueueMeta('theClientName', 'theTransportName'))
200+
;
201+
202+
$driver = new SqsDriver($context, $config, $meta);
204203

205204
$message = new Message();
206205
$message->setProperty(Config::PARAMETER_TOPIC_NAME, 'topic');
@@ -250,11 +249,14 @@ public function testShouldSendMessageToProcessor()
250249
->willReturn($transportMessage)
251250
;
252251

253-
$driver = new SqsDriver(
254-
$context,
255-
Config::create(),
256-
$this->createQueueMetaRegistryMock()
257-
);
252+
$meta = $this->createQueueMetaRegistryMock();
253+
$meta
254+
->expects($this->once())
255+
->method('getQueueMeta')
256+
->willReturn(new QueueMeta('theClientName', 'theTransportName'))
257+
;
258+
259+
$driver = new SqsDriver($context, Config::create(), $meta);
258260

259261
$message = new Message();
260262
$message->setProperty(Config::PARAMETER_PROCESSOR_NAME, 'processor');
@@ -329,6 +331,11 @@ public function testShouldSetupBroker()
329331
->method('getQueuesMeta')
330332
->willReturn([new QueueMeta('theClientName', 'theTransportName')])
331333
;
334+
$metaRegistry
335+
->expects($this->exactly(2))
336+
->method('getQueueMeta')
337+
->willReturn(new QueueMeta('theClientName', 'theTransportName'))
338+
;
332339

333340
$driver = new SqsDriver($context, $this->createConfigMock(), $metaRegistry);
334341

‎pkg/sqs/Tests/SqsContextTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function testShouldAllowPurgeQueue()
186186

187187
$queue = $context->createQueue('aQueueName');
188188

189-
$context->purgeQueue($queue);
189+
$context->purge($queue);
190190
}
191191

192192
public function testShouldAllowGetQueueUrl()

0 commit comments

Comments
 (0)