Beispiel #1
0
 public function testEnqueue()
 {
     $adapter = new SqsAdapter($this->client, 'foo');
     $url = $this->stubCreateQueue('foo');
     $this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo');
     $this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar');
     $this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz');
     $this->messageA->shouldReceive('getMetadata->get')->once()->with('MessageAttributes')->andReturn(null);
     $this->messageB->shouldReceive('getMetadata->get')->once()->with('MessageAttributes')->andReturn(null);
     $this->messageC->shouldReceive('getMetadata->get')->once()->with('MessageAttributes')->andReturn(null);
     $this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]);
     $this->client->shouldReceive('sendMessageBatch')->once()->with(['QueueUrl' => $url, 'Entries' => [['Id' => 0, 'MessageBody' => 'foo', 'MessageAttributes' => []], ['Id' => 1, 'MessageBody' => 'bar', 'MessageAttributes' => []], ['Id' => 2, 'MessageBody' => 'baz', 'MessageAttributes' => []]]])->andReturn($this->model);
     $adapter->enqueue($this->messages);
 }
Beispiel #2
0
 public function testEnqueueWithDelaySecondsQueueConfiguration()
 {
     $options = ['DelaySeconds' => 10];
     $adapter = new SqsAdapter($this->client, 'foo', $options);
     $url = $this->stubCreateQueue('foo', $options);
     $metadataA = m::mock(ContainerInterface::class);
     $metadataA->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null);
     $metadataA->shouldReceive('get')->with('DelaySeconds')->andReturn(null);
     $metadataB = m::mock(ContainerInterface::class);
     $metadataB->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null);
     $metadataB->shouldReceive('get')->with('DelaySeconds')->andReturn(0);
     $metadataC = m::mock(ContainerInterface::class);
     $metadataC->shouldReceive('get')->with('MessageAttributes')->once()->andReturn(null);
     $metadataC->shouldReceive('get')->with('DelaySeconds')->andReturn(2);
     $this->messageA->shouldReceive('getBody')->once()->withNoArgs()->andReturn('foo');
     $this->messageB->shouldReceive('getBody')->once()->withNoArgs()->andReturn('bar');
     $this->messageC->shouldReceive('getBody')->once()->withNoArgs()->andReturn('baz');
     $this->messageA->shouldReceive('getMetadata')->andReturn($metadataA);
     $this->messageB->shouldReceive('getMetadata')->andReturn($metadataB);
     $this->messageC->shouldReceive('getMetadata')->andReturn($metadataC);
     $this->model->shouldReceive('get')->once()->with('Failed')->andReturn([]);
     $this->client->shouldReceive('sendMessageBatch')->once()->with(['QueueUrl' => $url, 'Entries' => [['Id' => 0, 'MessageBody' => 'foo', 'MessageAttributes' => []], ['Id' => 1, 'MessageBody' => 'bar', 'MessageAttributes' => [], 'DelaySeconds' => 0], ['Id' => 2, 'MessageBody' => 'baz', 'MessageAttributes' => [], 'DelaySeconds' => 2]]])->andReturn($this->model);
     $adapter->enqueue($this->messages);
 }