1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of graze/queue. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @license https://github.com/graze/queue/blob/master/LICENSE MIT |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/graze/queue |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Graze\Queue\Adapter; |
17
|
|
|
|
18
|
|
|
use Aws\ResultInterface; |
19
|
|
|
use Aws\Sqs\SqsClient; |
20
|
|
|
use Graze\DataStructure\Container\ContainerInterface; |
21
|
|
|
use Graze\Queue\Message\MessageFactoryInterface; |
22
|
|
|
use Graze\Queue\Message\MessageInterface; |
23
|
|
|
use Mockery as m; |
24
|
|
|
use Mockery\MockInterface; |
25
|
|
|
use PHPUnit_Framework_TestCase as TestCase; |
26
|
|
|
|
27
|
|
|
class SqsAdapterTest extends TestCase |
28
|
|
|
{ |
29
|
|
|
/** @var MessageInterface|MockInterface */ |
30
|
|
|
private $messageA; |
31
|
|
|
/** @var MessageInterface|MockInterface */ |
32
|
|
|
private $messageB; |
33
|
|
|
/** @var MessageInterface|MockInterface */ |
34
|
|
|
private $messageC; |
35
|
|
|
/** @var MessageInterface[]|MockInterface[] */ |
36
|
|
|
private $messages; |
37
|
|
|
/** @var ResultInterface|MockInterface */ |
38
|
|
|
private $model; |
39
|
|
|
/** @var MessageFactoryInterface|MockInterface */ |
40
|
|
|
private $factory; |
41
|
|
|
/** @var SqsClient */ |
42
|
|
|
private $client; |
43
|
|
|
|
44
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$this->client = m::mock(SqsClient::class); |
47
|
|
|
$this->model = m::mock(ResultInterface::class); |
48
|
|
|
$this->factory = m::mock(MessageFactoryInterface::class); |
49
|
|
|
|
50
|
|
|
$this->messageA = $a = m::mock(MessageInterface::class); |
|
|
|
|
51
|
|
|
$this->messageB = $b = m::mock(MessageInterface::class); |
|
|
|
|
52
|
|
|
$this->messageC = $c = m::mock(MessageInterface::class); |
|
|
|
|
53
|
|
|
$this->messages = [$a, $b, $c]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $body |
58
|
|
|
* @param int $id |
59
|
|
|
* @param string $handle |
60
|
|
|
*/ |
61
|
|
|
protected function stubCreateDequeueMessage($body, $id, $handle) |
62
|
|
|
{ |
63
|
|
|
$this->factory->shouldReceive('createMessage')->once()->with( |
|
|
|
|
64
|
|
|
$body, |
65
|
|
|
m::on(function ($opts) use ($id, $handle) { |
66
|
|
|
$meta = ['Attributes' => [], 'MessageAttributes' => [], 'MessageId' => $id, 'ReceiptHandle' => $handle]; |
67
|
|
|
$validator = isset($opts['validator']) && is_callable($opts['validator']); |
68
|
|
|
|
69
|
|
|
return isset($opts['metadata']) && $opts['metadata'] === $meta && $validator; |
70
|
|
|
}) |
71
|
|
|
)->andReturn($this->messageA); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $name |
76
|
|
|
* @param array $options |
77
|
|
|
* |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
|
View Code Duplication |
protected function stubCreateQueue($name, array $options = []) |
|
|
|
|
81
|
|
|
{ |
82
|
|
|
$url = 'foo://bar'; |
83
|
|
|
$model = m::mock(ResultInterface::class); |
84
|
|
|
$model->shouldReceive('get')->once()->with('QueueUrl')->andReturn($url); |
85
|
|
|
|
86
|
|
|
$this->client->shouldReceive('createQueue')->once()->with([ |
87
|
|
|
'QueueName' => $name, |
88
|
|
|
'Attributes' => $options, |
89
|
|
|
])->andReturn($model); |
90
|
|
|
|
91
|
|
|
return $url; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $url |
96
|
|
|
* |
97
|
|
|
* @return int |
98
|
|
|
*/ |
99
|
|
View Code Duplication |
protected function stubQueueVisibilityTimeout($url) |
|
|
|
|
100
|
|
|
{ |
101
|
|
|
$timeout = 120; |
102
|
|
|
$model = m::mock(ResultInterface::class); |
103
|
|
|
$model->shouldReceive('get')->once()->with('Attributes')->andReturn(['VisibilityTimeout' => $timeout]); |
104
|
|
|
|
105
|
|
|
$this->client->shouldReceive('getQueueAttributes')->once()->with([ |
106
|
|
|
'QueueUrl' => $url, |
107
|
|
|
'AttributeNames' => ['VisibilityTimeout'], |
108
|
|
|
])->andReturn($model); |
109
|
|
|
|
110
|
|
|
return $timeout; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function testInterface() |
114
|
|
|
{ |
115
|
|
|
assertThat(new SqsAdapter($this->client, 'foo'), is(anInstanceOf('Graze\Queue\Adapter\AdapterInterface'))); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function testAcknowledge() |
119
|
|
|
{ |
120
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
121
|
|
|
$url = $this->stubCreateQueue('foo'); |
122
|
|
|
|
123
|
|
|
$this->messageA->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('foo'); |
|
|
|
|
124
|
|
|
$this->messageB->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('bar'); |
125
|
|
|
$this->messageC->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('baz'); |
126
|
|
|
|
127
|
|
|
$this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
|
|
|
|
128
|
|
|
|
129
|
|
|
$this->client->shouldReceive('deleteMessageBatch')->once()->with([ |
130
|
|
|
'QueueUrl' => $url, |
131
|
|
|
'Entries' => [ |
132
|
|
|
['Id' => 0, 'ReceiptHandle' => 'foo'], |
133
|
|
|
['Id' => 1, 'ReceiptHandle' => 'bar'], |
134
|
|
|
['Id' => 2, 'ReceiptHandle' => 'baz'], |
135
|
|
|
], |
136
|
|
|
])->andReturn($this->model); |
137
|
|
|
|
138
|
|
|
$adapter->acknowledge($this->messages); |
|
|
|
|
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function testReject() |
142
|
|
|
{ |
143
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
144
|
|
|
$url = $this->stubCreateQueue('foo'); |
145
|
|
|
|
146
|
|
|
$this->messageA->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('foo'); |
|
|
|
|
147
|
|
|
$this->messageB->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('bar'); |
148
|
|
|
$this->messageC->shouldReceive('getMetadata->get')->once()->with('ReceiptHandle')->andReturn('baz'); |
149
|
|
|
|
150
|
|
|
$this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
|
|
|
|
151
|
|
|
|
152
|
|
|
$this->client->shouldReceive('changeMessageVisibilityBatch')->once()->with([ |
153
|
|
|
'QueueUrl' => $url, |
154
|
|
|
'Entries' => [ |
155
|
|
|
['Id' => 0, 'ReceiptHandle' => 'foo', 'VisibilityTimeout' => 0], |
156
|
|
|
['Id' => 1, 'ReceiptHandle' => 'bar', 'VisibilityTimeout' => 0], |
157
|
|
|
['Id' => 2, 'ReceiptHandle' => 'baz', 'VisibilityTimeout' => 0], |
158
|
|
|
], |
159
|
|
|
])->andReturn($this->model); |
160
|
|
|
|
161
|
|
|
$adapter->reject($this->messages); |
|
|
|
|
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function testDequeue() |
165
|
|
|
{ |
166
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
167
|
|
|
$url = $this->stubCreateQueue('foo'); |
168
|
|
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
169
|
|
|
|
170
|
|
|
$this->stubCreateDequeueMessage('foo', 0, 'a'); |
171
|
|
|
$this->stubCreateDequeueMessage('bar', 1, 'b'); |
172
|
|
|
$this->stubCreateDequeueMessage('baz', 2, 'c'); |
173
|
|
|
|
174
|
|
|
$this->model->shouldReceive('get')->once()->with('Messages')->andReturn([ |
|
|
|
|
175
|
|
|
['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], |
176
|
|
|
['Body' => 'bar', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 1, 'ReceiptHandle' => 'b'], |
177
|
|
|
['Body' => 'baz', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 2, 'ReceiptHandle' => 'c'], |
178
|
|
|
]); |
179
|
|
|
|
180
|
|
|
$this->client->shouldReceive('receiveMessage')->once()->with([ |
181
|
|
|
'QueueUrl' => $url, |
182
|
|
|
'AttributeNames' => ['All'], |
183
|
|
|
'MaxNumberOfMessages' => 3, |
184
|
|
|
'VisibilityTimeout' => $timeout, |
185
|
|
|
])->andReturn($this->model); |
186
|
|
|
|
187
|
|
|
$iterator = $adapter->dequeue($this->factory, 3); |
188
|
|
|
|
189
|
|
|
assertThat($iterator, is(anInstanceOf('Generator'))); |
190
|
|
|
assertThat(iterator_to_array($iterator), is(equalTo($this->messages))); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function testDequeueInBatches() |
194
|
|
|
{ |
195
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
196
|
|
|
$url = $this->stubCreateQueue('foo'); |
197
|
|
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
198
|
|
|
|
199
|
|
|
$limit = SqsAdapter::BATCHSIZE_RECEIVE; |
200
|
|
|
|
201
|
|
|
$return = []; |
202
|
|
|
$messages = []; |
203
|
|
|
|
204
|
|
|
for ($i = 0; $i < $limit; $i++) { |
205
|
|
|
$this->stubCreateDequeueMessage('tmp' . $i, $i, 'h' . $i); |
206
|
|
|
$return[] = [ |
207
|
|
|
'Body' => 'tmp' . $i, |
208
|
|
|
'Attributes' => [], |
209
|
|
|
'MessageAttributes' => [], |
210
|
|
|
'MessageId' => $i, |
211
|
|
|
'ReceiptHandle' => 'h' . $i, |
212
|
|
|
]; |
213
|
|
|
$messages[] = $this->messageA; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
$this->model->shouldReceive('get')->once()->with('Messages')->andReturn($return); |
|
|
|
|
217
|
|
|
|
218
|
|
|
$this->client->shouldReceive('receiveMessage')->once()->with([ |
219
|
|
|
'QueueUrl' => $url, |
220
|
|
|
'AttributeNames' => ['All'], |
221
|
|
|
'MaxNumberOfMessages' => $limit, |
222
|
|
|
'VisibilityTimeout' => $timeout, |
223
|
|
|
])->andReturn($this->model); |
224
|
|
|
|
225
|
|
|
$iterator = $adapter->dequeue($this->factory, $limit); |
226
|
|
|
|
227
|
|
|
assertThat($iterator, is(anInstanceOf('Generator'))); |
228
|
|
|
assertThat(iterator_to_array($iterator), is(equalTo($messages))); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
public function testEnqueue() |
232
|
|
|
{ |
233
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
234
|
|
|
$url = $this->stubCreateQueue('foo'); |
235
|
|
|
|
236
|
|
|
$metadata = m::mock(ContainerInterface::class); |
237
|
|
|
$metadata->shouldReceive('get') |
238
|
|
|
->with('MessageAttributes') |
239
|
|
|
->times(3) |
240
|
|
|
->andReturn(null); |
241
|
|
|
$metadata->shouldReceive('get') |
242
|
|
|
->with('DelaySeconds') |
243
|
|
|
->andReturn(null); |
244
|
|
|
|
245
|
|
|
$this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo'); |
|
|
|
|
246
|
|
|
$this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar'); |
247
|
|
|
$this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz'); |
248
|
|
|
$this->messageA->shouldReceive('getMetadata')->andReturn($metadata); |
249
|
|
|
$this->messageB->shouldReceive('getMetadata')->andReturn($metadata); |
250
|
|
|
$this->messageC->shouldReceive('getMetadata')->andReturn($metadata); |
251
|
|
|
|
252
|
|
|
$this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
|
|
|
|
253
|
|
|
|
254
|
|
|
$this->client->shouldReceive('sendMessageBatch')->once()->with([ |
255
|
|
|
'QueueUrl' => $url, |
256
|
|
|
'Entries' => [ |
257
|
|
|
['Id' => 0, 'MessageBody' => 'foo', 'MessageAttributes' => []], |
258
|
|
|
['Id' => 1, 'MessageBody' => 'bar', 'MessageAttributes' => []], |
259
|
|
|
['Id' => 2, 'MessageBody' => 'baz', 'MessageAttributes' => []], |
260
|
|
|
], |
261
|
|
|
])->andReturn($this->model); |
262
|
|
|
|
263
|
|
|
$adapter->enqueue($this->messages); |
|
|
|
|
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
public function testEnqueueWithDelaySecondsMetadata() |
267
|
|
|
{ |
268
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
269
|
|
|
$url = $this->stubCreateQueue('foo'); |
270
|
|
|
|
271
|
|
|
$metadataA = m::mock(ContainerInterface::class); |
272
|
|
|
$metadataA->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
273
|
|
|
$metadataA->shouldReceive('get')->with('DelaySeconds')->andReturn(1); |
274
|
|
|
$metadataB = m::mock(ContainerInterface::class); |
275
|
|
|
$metadataB->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
276
|
|
|
$metadataB->shouldReceive('get')->with('DelaySeconds')->andReturn(2); |
277
|
|
|
$metadataC = m::mock(ContainerInterface::class); |
278
|
|
|
$metadataC->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
279
|
|
|
$metadataC->shouldReceive('get')->with('DelaySeconds')->andReturn(3); |
280
|
|
|
|
281
|
|
|
$this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo'); |
|
|
|
|
282
|
|
|
$this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar'); |
283
|
|
|
$this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz'); |
284
|
|
|
$this->messageA->shouldReceive('getMetadata')->andReturn($metadataA); |
285
|
|
|
$this->messageB->shouldReceive('getMetadata')->andReturn($metadataB); |
286
|
|
|
$this->messageC->shouldReceive('getMetadata')->andReturn($metadataC); |
287
|
|
|
|
288
|
|
|
$this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
|
|
|
|
289
|
|
|
|
290
|
|
|
$this->client->shouldReceive('sendMessageBatch')->once()->with([ |
291
|
|
|
'QueueUrl' => $url, |
292
|
|
|
'Entries' => [ |
293
|
|
|
['Id' => 0, 'MessageBody' => 'foo', 'MessageAttributes' => [], 'DelaySeconds' => 1], |
294
|
|
|
['Id' => 1, 'MessageBody' => 'bar', 'MessageAttributes' => [], 'DelaySeconds' => 2], |
295
|
|
|
['Id' => 2, 'MessageBody' => 'baz', 'MessageAttributes' => [], 'DelaySeconds' => 3], |
296
|
|
|
], |
297
|
|
|
])->andReturn($this->model); |
298
|
|
|
|
299
|
|
|
$adapter->enqueue($this->messages); |
|
|
|
|
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
public function testEnqueueWithDelaySecondsQueueConfiguration() |
303
|
|
|
{ |
304
|
|
|
$options = ['DelaySeconds' => 10]; |
305
|
|
|
|
306
|
|
|
$adapter = new SqsAdapter($this->client, 'foo', $options); |
307
|
|
|
$url = $this->stubCreateQueue('foo', $options); |
308
|
|
|
|
309
|
|
|
$metadataA = m::mock(ContainerInterface::class); |
310
|
|
|
$metadataA->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
311
|
|
|
$metadataA->shouldReceive('get')->with('DelaySeconds')->andReturn(null); |
312
|
|
|
$metadataB = m::mock(ContainerInterface::class); |
313
|
|
|
$metadataB->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
314
|
|
|
$metadataB->shouldReceive('get')->with('DelaySeconds')->andReturn(0); |
315
|
|
|
$metadataC = m::mock(ContainerInterface::class); |
316
|
|
|
$metadataC->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null); |
317
|
|
|
$metadataC->shouldReceive('get')->with('DelaySeconds')->andReturn(2); |
318
|
|
|
|
319
|
|
|
$this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo'); |
|
|
|
|
320
|
|
|
$this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar'); |
321
|
|
|
$this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz'); |
322
|
|
|
$this->messageA->shouldReceive('getMetadata')->andReturn($metadataA); |
323
|
|
|
$this->messageB->shouldReceive('getMetadata')->andReturn($metadataB); |
324
|
|
|
$this->messageC->shouldReceive('getMetadata')->andReturn($metadataC); |
325
|
|
|
|
326
|
|
|
$this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
|
|
|
|
327
|
|
|
|
328
|
|
|
$this->client->shouldReceive('sendMessageBatch')->once()->with([ |
329
|
|
|
'QueueUrl' => $url, |
330
|
|
|
'Entries' => [ |
331
|
|
|
['Id' => 0, 'MessageBody' => 'foo', 'MessageAttributes' => []], |
332
|
|
|
['Id' => 1, 'MessageBody' => 'bar', 'MessageAttributes' => [], 'DelaySeconds' => 0], |
333
|
|
|
['Id' => 2, 'MessageBody' => 'baz', 'MessageAttributes' => [], 'DelaySeconds' => 2], |
334
|
|
|
], |
335
|
|
|
])->andReturn($this->model); |
336
|
|
|
|
337
|
|
|
$adapter->enqueue($this->messages); |
|
|
|
|
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
public function testReceiveMessageWaitTimeSecondsOption() |
341
|
|
|
{ |
342
|
|
|
$options = ['ReceiveMessageWaitTimeSeconds' => 20]; |
343
|
|
|
|
344
|
|
|
$adapter = new SqsAdapter($this->client, 'foo', $options); |
345
|
|
|
$url = $this->stubCreateQueue('foo', $options); |
346
|
|
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
347
|
|
|
|
348
|
|
|
$this->stubCreateDequeueMessage('foo', 0, 'a'); |
349
|
|
|
$this->stubCreateDequeueMessage('bar', 1, 'b'); |
350
|
|
|
$this->stubCreateDequeueMessage('baz', 2, 'c'); |
351
|
|
|
|
352
|
|
|
$this->model->shouldReceive('get')->once()->with('Messages')->andReturn([ |
|
|
|
|
353
|
|
|
['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], |
354
|
|
|
['Body' => 'bar', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 1, 'ReceiptHandle' => 'b'], |
355
|
|
|
['Body' => 'baz', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 2, 'ReceiptHandle' => 'c'], |
356
|
|
|
]); |
357
|
|
|
|
358
|
|
|
$this->client->shouldReceive('receiveMessage')->once()->with([ |
359
|
|
|
'QueueUrl' => $url, |
360
|
|
|
'AttributeNames' => ['All'], |
361
|
|
|
'MaxNumberOfMessages' => 3, |
362
|
|
|
'VisibilityTimeout' => $timeout, |
363
|
|
|
'WaitTimeSeconds' => 20, |
364
|
|
|
])->andReturn($this->model); |
365
|
|
|
|
366
|
|
|
$iterator = $adapter->dequeue($this->factory, 3); |
367
|
|
|
|
368
|
|
|
assertThat($iterator, is(anInstanceOf('Generator'))); |
369
|
|
|
assertThat(iterator_to_array($iterator), is(equalTo($this->messages))); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
View Code Duplication |
public function testPurge() |
|
|
|
|
373
|
|
|
{ |
374
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
375
|
|
|
$url = $this->stubCreateQueue('foo'); |
376
|
|
|
|
377
|
|
|
$this->client->shouldReceive('purgeQueue')->once()->with([ |
378
|
|
|
'QueueUrl' => $url, |
379
|
|
|
])->andReturn($this->model); |
380
|
|
|
|
381
|
|
|
assertThat($adapter->purge(), is(nullValue())); |
382
|
|
|
} |
383
|
|
|
|
384
|
|
View Code Duplication |
public function testDelete() |
|
|
|
|
385
|
|
|
{ |
386
|
|
|
$adapter = new SqsAdapter($this->client, 'foo'); |
387
|
|
|
$url = $this->stubCreateQueue('foo'); |
388
|
|
|
|
389
|
|
|
$this->client->shouldReceive('deleteQueue')->once()->with([ |
390
|
|
|
'QueueUrl' => $url, |
391
|
|
|
])->andReturn($this->model); |
392
|
|
|
|
393
|
|
|
assertThat($adapter->delete(), is(nullValue())); |
394
|
|
|
} |
395
|
|
|
} |
396
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.