/**
  * @covers MicrosoftAzure\Storage\Queue\Models\PeekMessagesResult::setQueueMessages
  */
 public function testSetQueueMessages()
 {
     // Setup
     $sample = TestResources::listMessagesSample();
     $expectedMessageId = '1234b585-0ac3-4e2a-ad0c-18e3992brca1';
     $result = PeekMessagesResult::create($sample);
     $expected = $result->getQueueMessages();
     $expected[0]->setMessageId($expectedMessageId);
     // Test
     $result->setQueueMessages($expected);
     $this->assertEquals($expected, $result->getQueueMessages());
 }
Ejemplo n.º 2
0
 /**
  * Retrieves a message from the front of the queue, without changing 
  * the message visibility.
  * 
  * @param string              $queueName The queue name.
  * @param PeekMessagesOptions $options   The optional parameters.
  * 
  * @return MicrosoftAzure\Storage\Common\Models\PeekMessagesResult
  */
 public function peekMessages($queueName, $options = null)
 {
     Validate::isString($queueName, 'queueName');
     Validate::notNullOrEmpty($queueName, 'queueName');
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $path = $queueName . '/messages';
     $statusCode = Resources::STATUS_OK;
     if (is_null($options)) {
         $options = new PeekMessagesOptions();
     }
     $messagesCount = $options->getNumberOfMessages();
     $timeout = $options->getTimeout();
     $this->addOptionalQueryParam($queryParams, Resources::QP_PEEK_ONLY, 'true');
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $timeout);
     $this->addOptionalQueryParam($queryParams, Resources::QP_NUM_OF_MESSAGES, $messagesCount);
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     $parsed = $this->dataSerializer->unserialize($response->getBody());
     return PeekMessagesResult::create($parsed);
 }