|
@@ 79-108 (lines=30) @@
|
| 76 |
|
return $timeout; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
public function testReceive() |
| 80 |
|
{ |
| 81 |
|
$url = $this->stubCreateQueue(); |
| 82 |
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
| 83 |
|
|
| 84 |
|
$receiveModel = m::mock(ResultInterface::class); |
| 85 |
|
$receiveModel->shouldReceive('get')->once()->with('Messages')->andReturn([ |
| 86 |
|
['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], |
| 87 |
|
]); |
| 88 |
|
$this->sqsClient->shouldReceive('receiveMessage')->once()->with([ |
| 89 |
|
'QueueUrl' => $url, |
| 90 |
|
'AttributeNames' => ['All'], |
| 91 |
|
'MaxNumberOfMessages' => 1, |
| 92 |
|
'VisibilityTimeout' => $timeout, |
| 93 |
|
])->andReturn($receiveModel); |
| 94 |
|
|
| 95 |
|
$deleteModel = m::mock(ResultInterface::class); |
| 96 |
|
$deleteModel->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
| 97 |
|
$this->sqsClient->shouldReceive('deleteMessageBatch')->once()->with([ |
| 98 |
|
'QueueUrl' => $url, |
| 99 |
|
'Entries' => [['Id' => 0, 'ReceiptHandle' => 'a']], |
| 100 |
|
])->andReturn($deleteModel); |
| 101 |
|
|
| 102 |
|
$msgs = []; |
| 103 |
|
$this->client->receive(function ($msg) use (&$msgs) { |
| 104 |
|
$msgs[] = $msg; |
| 105 |
|
}); |
| 106 |
|
|
| 107 |
|
assertThat($msgs, is(arrayWithSize(1))); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
public function testReceiveWithReceiveMessageReturningLessThanMaxNumberOfMessages() |
| 111 |
|
{ |
|
@@ 215-245 (lines=31) @@
|
| 212 |
|
assertThat($msgs, is(arrayWithSize(11))); |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
public function testReceiveWithLimit() |
| 216 |
|
{ |
| 217 |
|
$url = $this->stubCreateQueue(); |
| 218 |
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
| 219 |
|
|
| 220 |
|
$receiveModel = m::mock(ResultInterface::class); |
| 221 |
|
$receiveModel->shouldReceive('get')->once()->with('Messages')->andReturn([ |
| 222 |
|
['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], |
| 223 |
|
]); |
| 224 |
|
$this->sqsClient->shouldReceive('receiveMessage')->once()->with([ |
| 225 |
|
'QueueUrl' => $url, |
| 226 |
|
'AttributeNames' => ['All'], |
| 227 |
|
'MaxNumberOfMessages' => SqsAdapter::BATCHSIZE_RECEIVE, |
| 228 |
|
'VisibilityTimeout' => $timeout, |
| 229 |
|
])->andReturn($receiveModel); |
| 230 |
|
|
| 231 |
|
$deleteModel = m::mock(ResultInterface::class); |
| 232 |
|
$deleteModel->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
| 233 |
|
$this->sqsClient->shouldReceive('deleteMessageBatch')->once()->with([ |
| 234 |
|
'QueueUrl' => $url, |
| 235 |
|
'Entries' => [['Id' => 0, 'ReceiptHandle' => 'a']], |
| 236 |
|
])->andReturn($deleteModel); |
| 237 |
|
|
| 238 |
|
$msgs = []; |
| 239 |
|
$this->client->receive(function ($msg, $done) use (&$msgs) { |
| 240 |
|
$msgs[] = $msg; |
| 241 |
|
$done(); |
| 242 |
|
}, 100); |
| 243 |
|
|
| 244 |
|
assertThat($msgs, is(arrayWithSize(1))); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
public function testReceiveWithPolling() |
| 248 |
|
{ |
|
@@ 247-277 (lines=31) @@
|
| 244 |
|
assertThat($msgs, is(arrayWithSize(1))); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
public function testReceiveWithPolling() |
| 248 |
|
{ |
| 249 |
|
$url = $this->stubCreateQueue(); |
| 250 |
|
$timeout = $this->stubQueueVisibilityTimeout($url); |
| 251 |
|
|
| 252 |
|
$receiveModel = m::mock(ResultInterface::class); |
| 253 |
|
$receiveModel->shouldReceive('get')->once()->with('Messages')->andReturn([ |
| 254 |
|
['Body' => 'foo', 'Attributes' => [], 'MessageAttributes' => [], 'MessageId' => 0, 'ReceiptHandle' => 'a'], |
| 255 |
|
]); |
| 256 |
|
$this->sqsClient->shouldReceive('receiveMessage')->once()->with([ |
| 257 |
|
'QueueUrl' => $url, |
| 258 |
|
'AttributeNames' => ['All'], |
| 259 |
|
'MaxNumberOfMessages' => SqsAdapter::BATCHSIZE_RECEIVE, |
| 260 |
|
'VisibilityTimeout' => $timeout, |
| 261 |
|
])->andReturn($receiveModel); |
| 262 |
|
|
| 263 |
|
$deleteModel = m::mock(ResultInterface::class); |
| 264 |
|
$deleteModel->shouldReceive('get')->once()->with('Failed')->andReturn([]); |
| 265 |
|
$this->sqsClient->shouldReceive('deleteMessageBatch')->once()->with([ |
| 266 |
|
'QueueUrl' => $url, |
| 267 |
|
'Entries' => [['Id' => 0, 'ReceiptHandle' => 'a']], |
| 268 |
|
])->andReturn($deleteModel); |
| 269 |
|
|
| 270 |
|
$msgs = []; |
| 271 |
|
$this->client->receive(function ($msg, $done) use (&$msgs) { |
| 272 |
|
$msgs[] = $msg; |
| 273 |
|
$done(); |
| 274 |
|
}, null); |
| 275 |
|
|
| 276 |
|
assertThat($msgs, is(arrayWithSize(1))); |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
public function testSend() |
| 280 |
|
{ |