public function testRemove()
 {
     $queue = new Queue();
     $queue->setUrl('Testurl!');
     $queueStorage = new QueueStorage();
     $queueStorage->add($queue);
     $queueStorage->remove($queue);
     $this->assertFalse($queueStorage->exists($queue), 'Queue should be not exists');
 }
 /**
  * Exists a Queue object in the storage
  * 
  * @param \AmazonSQS\Model\Queue $queue Queue object
  * 
  * @return bool 
  */
 public function exists(Queue $queue)
 {
     return isset($this->storage[$queue->getUniqueKey()]);
 }
Exemple #3
0
 /**
  * Load all attributes of the queue
  * 
  * @param \AmazonSQS\Model\Queue $queue
  * 
  * @return \AmazonSQS\Model\Queue
  */
 public function loadQueueAttributes(Queue $queue)
 {
     $params['AttributeName.1'] = 'All';
     $response = $this->call('GetQueueAttributes', $params, $queue->getUrl());
     $data = array();
     foreach ($response['Attribute'] as $attribute) {
         $key = lcfirst($attribute['Name']);
         $data[$key] = $attribute['Value'];
     }
     $data = array_merge($this->getSerializer()->normalize($queue), $data);
     $queue = $this->getSerializer()->denormalize($data, '\\AmazonSQS\\Model\\Queue');
     $this->getQueueStorage()->add($queue);
     return $queue;
 }
Exemple #4
0
 public function testLoadQueueAttributes()
 {
     $queue = new Queue();
     $queue->setUrl('http://test.x/blub');
     $queue->setDelaySeconds(123);
     $queue2 = new Queue();
     $queue2->setUrl('http://test.x/blub');
     $queue2->setDelaySeconds(51);
     $manager = $this->getMockBuilder('AmazonSQS\\Manager')->setConstructorArgs(array('accesskey', 'secretkey'))->setMethods(array('call'))->getMock();
     $manager->expects($this->once())->method('call')->with('GetQueueAttributes', array('AttributeName.1' => 'All'), 'http://test.x/blub')->will($this->returnValue(array('Attribute' => array(array('Name' => 'DelaySeconds', 'Value' => '51')))));
     $serializer = $this->getMockBuilder('Symfony\\Component\\Serializer\\Serializer')->getMock();
     $serializer->expects($this->at(0))->method('normalize')->with($queue)->will($this->returnValue(array('delaySeconds' => '123')));
     $serializer->expects($this->at(1))->method('denormalize')->with(array('delaySeconds' => '51'), '\\AmazonSQS\\Model\\Queue')->will($this->returnValue($queue2));
     $queueStorage = $this->getMockBuilder('AmazonSQS\\Storage\\QueueStorage')->getMock();
     $queueStorage->expects($this->once())->method('add')->with($queue2);
     $manager->setQueueStorage($queueStorage);
     $manager->setSerializer($serializer);
     $queue = $manager->loadQueueAttributes($queue);
     $this->assertEquals(51, $queue->getDelaySeconds(), 'Wrong queue');
 }